单页面新增url文件名称功能,并支持按照文件阅读
This commit is contained in:
parent
ed83cffe3e
commit
b3030a6f9f
@ -30,7 +30,7 @@ class Pages extends BaseController
|
||||
$where[] = ['status', '>=', 0];
|
||||
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
|
||||
$content = PagesList::where($where)
|
||||
->field('id,title,status,template,create_time')
|
||||
->field('id,title,status,name,read,template,create_time')
|
||||
->order('create_time desc')
|
||||
->paginate($rows, false, ['query' => $param]);
|
||||
return table_assign(0, '', $content);
|
||||
|
@ -17,7 +17,7 @@ class Article extends Model
|
||||
{
|
||||
$article = \think\facade\Db::name('Article')->where(['id' => $id])->find();
|
||||
if (empty($article)) {
|
||||
return $this->error('文章不存在');
|
||||
return false;
|
||||
}
|
||||
$keyword_array = \think\facade\Db::name('ArticleKeywords')
|
||||
->field('i.aid,i.keywords_id,k.title')
|
||||
|
@ -17,7 +17,7 @@ class Goods extends Model
|
||||
{
|
||||
$goods = \think\facade\Db::name('Goods')->where(['id'=>$id])->find();
|
||||
if(empty($goods)) {
|
||||
return $this->error('商品不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
//轮播图
|
||||
|
@ -17,9 +17,8 @@ class Pages extends Model
|
||||
{
|
||||
$detail = \think\facade\Db::name('Pages')->where(['id'=>$id])->find();
|
||||
if(empty($detail)) {
|
||||
return $this->error('页面不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
//轮播图
|
||||
if(!empty($detail['banner'])) {
|
||||
$detail['banner_array'] = explode(',',$detail['banner']);
|
||||
|
@ -14,6 +14,7 @@ class PagesCheck extends Validate
|
||||
protected $rule = [
|
||||
'title' => 'require|unique:pages',
|
||||
'content' => 'require',
|
||||
'name' => 'lower|min:3|unique:pages',
|
||||
'id' => 'require',
|
||||
'status' => 'require',
|
||||
];
|
||||
@ -22,12 +23,15 @@ class PagesCheck extends Validate
|
||||
'title.require' => '标题不能为空',
|
||||
'title.unique' => '同样的页面标题已经存在',
|
||||
'content.require' => '页面内容不能为空',
|
||||
'name.lower' => 'URL文件名称只能是小写字符',
|
||||
'name.min' => 'URL文件名称至少需要3个小写字符',
|
||||
'name.unique' => '同样的URL文件名称已经存在',
|
||||
'id.require' => '缺少更新条件',
|
||||
'status.require' => '状态为必选',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['title', 'content', 'status'],
|
||||
'edit' => ['title', 'content', 'id', 'status'],
|
||||
'add' => ['title', 'content', 'name', 'status'],
|
||||
'edit' => ['title', 'content', 'id', 'name', 'status'],
|
||||
];
|
||||
}
|
||||
|
@ -186,9 +186,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(71);
|
||||
layer.confirm('保存成功,关闭当前页面?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
@ -211,9 +211,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(71);
|
||||
layer.confirm('保存成功,关闭当前页面?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
|
@ -197,9 +197,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(71);
|
||||
layer.confirm('保存成功,关闭当前页面吗?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
@ -222,9 +222,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(71);
|
||||
layer.confirm('保存成功,关闭当前页面吗?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
|
@ -312,9 +312,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(77);
|
||||
layer.confirm('保存成功,关闭当前页面吗?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
@ -337,9 +337,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(77);
|
||||
layer.confirm('保存成功,关闭当前页面吗?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
|
@ -339,9 +339,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(77);
|
||||
layer.confirm('保存成功,关闭当前页面?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
@ -364,9 +364,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(77);
|
||||
layer.confirm('保存成功,关闭当前页面?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
|
@ -33,7 +33,7 @@
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td class="layui-td-gray">页面标题 <span style="color: red">*</span></td>
|
||||
<td><input type="text" name="title" lay-verify="required" lay-reqText="请输入页面标题" placeholder="请输入页面标题" class="layui-input"></td>
|
||||
<td colspan="3"><input type="text" name="title" lay-verify="required" lay-reqText="请输入页面标题" placeholder="请输入页面标题" class="layui-input"></td>
|
||||
<td class="layui-td-gray" rowspan="3">缩略图</td>
|
||||
<td rowspan="3" style="vertical-align:top">
|
||||
<div class="layui-upload" style="text-align:center;">
|
||||
@ -47,7 +47,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">关键字 <span style="color: red">*</span></td>
|
||||
<td>
|
||||
<td colspan="3">
|
||||
<input type="text" id="keyword_name" name="keyword_names" lay-verify="required" lay-reqText="请选择关键字"
|
||||
placeholder="请选择关键字" class="layui-input" readonly>
|
||||
<input type="hidden" id="keyword_id" name="keyword_ids">
|
||||
@ -61,7 +61,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">图集相册</td>
|
||||
<td colspan="3">
|
||||
<td colspan="5">
|
||||
<div class="layui-upload">
|
||||
<button type="button" class="layui-btn layui-btn-sm" id="uploadBtn2">上传图片</button>
|
||||
<div class="layui-upload-list clearfix" id="demo2">
|
||||
@ -80,7 +80,11 @@
|
||||
{/volist}
|
||||
</select>
|
||||
</td>
|
||||
<td class="layui-td-gray">状态 <span style="color: red">*</span></td>
|
||||
<td class="layui-td-gray-2">URL文件名称</td>
|
||||
<td>
|
||||
<input type="text" name="name" placeholder="请输入URL文件名称" class="layui-input">
|
||||
</td>
|
||||
<td class="layui-td-gray">状态</td>
|
||||
<td>
|
||||
<input type="radio" name="status" value="1" title="正常" checked>
|
||||
<input type="radio" name="status" value="0" title="下架">
|
||||
@ -230,9 +234,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(80);
|
||||
layer.confirm('保存成功,关闭当前页面吗?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
@ -255,9 +259,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(80);
|
||||
layer.confirm('保存成功,关闭当前页面吗?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
|
@ -33,7 +33,7 @@
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td class="layui-td-gray">页面标题 <span style="color: red">*</span></td>
|
||||
<td><input type="text" name="title" lay-verify="required" lay-reqText="请输入页面标题" placeholder="请输入页面标题" class="layui-input" value="{$detail.title}"></td>
|
||||
<td colspan="3"><input type="text" name="title" lay-verify="required" lay-reqText="请输入页面标题" placeholder="请输入页面标题" class="layui-input" value="{$detail.title}"></td>
|
||||
<td class="layui-td-gray" rowspan="3">缩略图</td>
|
||||
<td rowspan="3" style="vertical-align:top">
|
||||
<div class="layui-upload" style="text-align:center;">
|
||||
@ -47,7 +47,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">关键字 <span style="color: red">*</span></td>
|
||||
<td>
|
||||
<td colspan="3">
|
||||
<input type="text" id="keyword_name" name="keyword_names" lay-verify="required" lay-reqText="请选择关键字"
|
||||
placeholder="请选择关键字" class="layui-input" value="{$detail.keyword_names}" readonly>
|
||||
<input type="hidden" id="keyword_id" name="keyword_ids" value="{$detail.keyword_ids}">
|
||||
@ -61,7 +61,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">图集相册</td>
|
||||
<td colspan="3">
|
||||
<td colspan="5">
|
||||
<div class="layui-upload">
|
||||
<button type="button" class="layui-btn layui-btn-sm" id="uploadBtn2">上传图片</button>
|
||||
<div class="layui-upload-list" id="demo2">
|
||||
@ -85,6 +85,10 @@
|
||||
{/volist}
|
||||
</select>
|
||||
</td>
|
||||
<td class="layui-td-gray-2">URL文件名称</td>
|
||||
<td>
|
||||
<input type="text" name="name" value="{$detail.name}" placeholder="请输入URL文件名称" class="layui-input">
|
||||
</td>
|
||||
<td class="layui-td-gray">状态 <span style="color: red">*</span></td>
|
||||
<td>
|
||||
<input type="radio" name="status" value="1" title="正常" {eq name="$detail.status" value="1" }checked{/eq}>
|
||||
@ -93,31 +97,31 @@
|
||||
</tr>
|
||||
{empty name="$detail.md_content"}
|
||||
<tr>
|
||||
<td colspan="4" class="layui-td-gray" style="text-align:left">页面内容<span style="color: red">*</span></td>
|
||||
<td colspan="6" class="layui-td-gray" style="text-align:left">页面内容<span style="color: red">*</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<td colspan="6">
|
||||
<textarea class="layui-textarea" id="container">{$detail.content}</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
{else/}
|
||||
{eq name="$editor" value="1"}
|
||||
<tr>
|
||||
<td colspan="4" class="layui-td-gray" style="text-align:left">页面内容<span style="color: red">*</span><span
|
||||
<td colspan="6" class="layui-td-gray" style="text-align:left">页面内容<span style="color: red">*</span><span
|
||||
style="margin-left:30px; color: red">当前为TinyMCE富文本编辑器,可在【系统管理->其他配置】中切换为mardown编辑器</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<td colspan="6">
|
||||
<textarea placeholder="请输入内容" class="layui-textarea" id="container">{$detail.content}</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
{else/}
|
||||
<tr>
|
||||
<td colspan="4" class="layui-td-gray" style="text-align:left">页面内容<span style="color: red">*</span><span
|
||||
<td colspan="6" class="layui-td-gray" style="text-align:left">页面内容<span style="color: red">*</span><span
|
||||
style="margin-left:30px; color: red">当前为mardown编辑器,可在【系统管理->其他配置】中切换为TinyMCE富文本编辑器</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<td colspan="6">
|
||||
<div>
|
||||
<textarea id="mdContent" style="display:none;">{$detail.md_content|raw}</textarea>
|
||||
<div id="docContent"></div>
|
||||
@ -247,9 +251,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(80);
|
||||
layer.confirm('保存成功,关闭当前页面吗?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
@ -272,9 +276,9 @@
|
||||
}
|
||||
let callback = function (e) {
|
||||
if (e.code == 0) {
|
||||
tool.tabRefresh(80);
|
||||
layer.confirm('保存成功,关闭当前页面吗?', { icon: 3, title: '提示' }, function (index) {
|
||||
tool.tabClose();
|
||||
layer.close(index);
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
|
@ -49,10 +49,14 @@
|
||||
field: 'title',
|
||||
title: '页面标题',
|
||||
templet: '<div><a href="/home/pages/detail/id/{{d.id}}.html" class="layui-table-link" target="_blank">{{d.title}}</a></div>'
|
||||
},{
|
||||
field: 'name',
|
||||
title: 'URL名称',
|
||||
width: 100
|
||||
},{
|
||||
field: 'template',
|
||||
title: '模板文件',
|
||||
width: 120,
|
||||
width: 100,
|
||||
templet: function(d){
|
||||
return d.template+'.html';
|
||||
}
|
||||
@ -61,6 +65,11 @@
|
||||
title: '发布时间',
|
||||
align: 'center',
|
||||
width: 160
|
||||
},{
|
||||
field: 'read',
|
||||
align: 'center',
|
||||
title: '阅读量',
|
||||
width: 80
|
||||
},{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
|
@ -11,6 +11,7 @@ namespace app\home;
|
||||
|
||||
use think\App;
|
||||
use think\facade\View;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 控制器基础类
|
||||
@ -93,4 +94,9 @@ abstract class BaseController
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//页面跳转方法
|
||||
public function redirectTo(...$args)
|
||||
{
|
||||
throw new HttpResponseException(redirect(...$args));
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ function get_article_detail($id)
|
||||
{
|
||||
$article = \think\facade\Db::name('article')->where(['id' => $id])->find();
|
||||
if (empty($article)) {
|
||||
return $this->error('文章不存在');
|
||||
return false;
|
||||
}
|
||||
$keywrod_array = \think\facade\Db::name('ArticleKeywords')
|
||||
->field('i.aid,i.keywords_id,k.title')
|
||||
|
@ -10,7 +10,7 @@ declare (strict_types = 1);
|
||||
namespace app\home\controller;
|
||||
|
||||
use app\home\BaseController;
|
||||
use app\admin\model\Pages as ArticleModel;
|
||||
use app\admin\model\Pages as PagesModel;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
|
||||
@ -20,8 +20,17 @@ class Pages extends BaseController
|
||||
{
|
||||
$param = get_params();
|
||||
$id = isset($param['id']) ? $param['id'] : 0;
|
||||
$detail = (new ArticleModel())->detail($id);
|
||||
ArticleModel::where('id', $param['id'])->inc('read')->update();
|
||||
if (isset($param['s'])) {
|
||||
$id = Db::name('Pages')->where(['name'=>$param['s']])->value('id');
|
||||
if(empty($id)){
|
||||
$this->redirectTo('/home/login/errorshow');
|
||||
}
|
||||
}
|
||||
$detail = (new PagesModel())->detail($id);
|
||||
if(empty($detail)){
|
||||
$this->redirectTo('/home/login/errorshow');
|
||||
}
|
||||
PagesModel::where('id', $id)->inc('read')->update();
|
||||
View::assign('detail', $detail);
|
||||
return view($detail['template']);
|
||||
}
|
||||
|
@ -755,6 +755,7 @@ CREATE TABLE `cms_pages` (
|
||||
`md_content` text NOT NULL COMMENT 'markdown内容',
|
||||
`read` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '阅读量',
|
||||
`sort` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序',
|
||||
`name` varchar(200) NOT NULL DEFAULT '' COMMENT 'url文件名',
|
||||
`template` varchar(200) NOT NULL DEFAULT '' COMMENT '前端模板',
|
||||
`admin_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人',
|
||||
`create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
|
||||
@ -765,7 +766,8 @@ CREATE TABLE `cms_pages` (
|
||||
-- ----------------------------
|
||||
-- Records of cms_pages
|
||||
-- ----------------------------
|
||||
INSERT INTO `cms_pages` VALUES (1, 1, '勾股CMS介绍', 1, '', '勾股CMS是一套基于ThinkPHP6+Layui+MySql打造的轻量级、高性能快速建站的内容管理系统。后台管理模块,一目了然,操作简单,通用型后台权限管理框架,紧随潮流、极低门槛、开箱即用。', '<p>勾股CMS是一套基于ThinkPHP6 + Layui + MySql打造的轻量级、高性能极速后台开发框架。通用型的后台权限管理框架,极低门槛、操作简单、开箱即用。系统易于功能扩展,代码维护,方便二次开发,让开发者更专注于业务深度需求的开发,帮助开发者简单高效降低二次开发成本。</p>\n<p><img src=\"https://blog.gougucms.com/storage/image/202109/1630457997502502.png\" /></p>', '', 1, 0, 'default', 0, 1653984295, 1653993466);
|
||||
INSERT INTO `cms_pages` VALUES (1, 1, '关于我们', 1, '', '勾股CMS是一套基于ThinkPHP6+Layui+MySql打造的轻量级、高性能快速建站的内容管理系统。后台管理模块,一目了然,操作简单,通用型后台权限管理框架,开箱即用。', '<p>勾股CMS是一套基于ThinkPHP6 + Layui + MySql打造的轻量级、高性能极速后台开发框架。通用型的后台权限管理框架,操作简单、开箱即用。系统易于功能扩展,代码维护,方便二次开发,让开发者更专注于业务深度需求的开发,帮助开发者简单高效降低二次开发成本。</p>\n<p><img src=\"https://blog.gougucms.com/storage/image/202109/1630457997502502.png\" /></p>', '', 1, 0, '', 'default', 0, 1653984295, 1653993466);
|
||||
INSERT INTO `cms_pages` VALUES (2, 1, '勾股DEV', 0, '', '勾股DEV是一款专为IT研发团队打造的项目管理与团队协作的系统工具,可以在线管理团队的工作、项目和任务,覆盖从需求提出到研发完成上线整个过程的项目协作。', '<p >勾股DEV是一款专为IT研发团队打造的项目管理与团队协作的系统工具,可以在线管理团队的工作、项目和任务,覆盖从需求提出到研发完成上线整个过程的项目协作。</p>\n<p>勾股DEV的产品理念:通过“项目(Project)”的形式把成员、需求、任务、缺陷(BUG)、文档、互动讨论以及各种形式的资源组织在一起,团队成员参与更新任务、文档等内容来推动项目的进度,同时系统利用时间线索和各种动态的报表的形式来自动给成员汇报项目进度。</p>', '', 8, 0, 'gougudev', 'dev', 0, 1654167139, 0);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `cms_pages_keywords`
|
||||
|
@ -1,7 +1,6 @@
|
||||
layui.define(['element'], function (exports) {
|
||||
var element = layui.element;
|
||||
var tab = {
|
||||
loading: false,
|
||||
/*新增一个Tab页面
|
||||
* @id,tab页面唯一标识,可是标签中data-id的属性值
|
||||
* @url,tab页面地址
|
||||
@ -83,6 +82,12 @@ layui.define(['element'], function (exports) {
|
||||
$itemleft = $item.position().left;
|
||||
if ($itemleft + $item.outerWidth() >= $outerWidth - $left) return $tabTitle.css("left", -$itemleft), false;
|
||||
})
|
||||
},
|
||||
refresh:function(id){
|
||||
if(parent.document.getElementById(id)){
|
||||
var src = parent.document.getElementById(id).contentWindow.location.href ? parent.document.getElementById(id).contentWindow.location.href : iframe.src;
|
||||
document.getElementById(id).src = src;
|
||||
}
|
||||
}
|
||||
};
|
||||
//切换tab
|
||||
@ -219,8 +224,7 @@ layui.define(['element'], function (exports) {
|
||||
that.removeClass("refreshThis");
|
||||
var iframe = $(".gg-tab-page.layui-show").find("iframe")[0];
|
||||
if (iframe) {
|
||||
var src = parent.document.getElementById(iframe.id).contentWindow.location.href ? parent.document.getElementById(iframe.id).contentWindow.location.href : iframe.src;
|
||||
document.getElementById(iframe.id).src = src;
|
||||
tab.refresh(iframe.id);
|
||||
}
|
||||
setTimeout(function () {
|
||||
that.attr("class", "refreshThis");
|
||||
|
@ -205,8 +205,16 @@ layui.define([], function (exports) {
|
||||
else{
|
||||
console.log('父页面没引用admin模块');
|
||||
}
|
||||
},
|
||||
tabRefresh:function(id){
|
||||
if(parent.layui.admin){
|
||||
parent.layui.admin.refresh(id);
|
||||
}
|
||||
else{
|
||||
console.log('父页面没引用admin模块');
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
$('body').on('click', '.tab-a', function () {
|
||||
let url = $(this).data('href');
|
||||
|
Loading…
x
Reference in New Issue
Block a user