From 0450e849612ff501cd339fa3aaf4a4a3884f9877 Mon Sep 17 00:00:00 2001 From: muzi_ys <1099438829@qq.com> Date: Fri, 8 Jul 2022 00:12:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Article.php | 7 +- app/admin/controller/Page.php | 60 +++--- app/admin/view/article/add.html | 12 +- app/admin/view/article/edit.html | 2 +- app/admin/view/category/add.html | 2 +- app/admin/view/category/edit.html | 2 +- app/admin/view/page/add.html | 53 ++--- app/admin/view/page/comment.html | 286 --------------------------- app/admin/view/page/edit.html | 228 +++++++++------------ app/common/model/Document.php | 6 + app/common/model/DocumentArticle.php | 31 ++- app/common/model/DocumentPage.php | 36 ++++ app/index/controller/Article.php | 6 +- 13 files changed, 232 insertions(+), 499 deletions(-) delete mode 100644 app/admin/view/page/comment.html create mode 100644 app/common/model/DocumentPage.php diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php index 9bc6116..793ce4b 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/Article.php @@ -4,6 +4,7 @@ namespace app\admin\controller; use app\common\model\Document as aModel; use app\common\model\DocumentCategory as cModel; +use app\common\model\DocumentPage; use app\common\model\Tag as TagModel; use app\common\model\DocumentArticle; use app\common\model\Comment as CommentModel; @@ -208,7 +209,11 @@ class Article extends AuthController ['id', ''] ]); if ($where['id'] == '') { - return $this->error('数据不存在'); + $this->error('数据不存在'); + } + $info = (new DocumentArticle())->getInfo($where["id"]); + if (empty($info)) { + $this->error('数据不存在'); } $category = cModel::systemPage($where); $category = get_tree_list($category); diff --git a/app/admin/controller/Page.php b/app/admin/controller/Page.php index de3bb8d..d4ba6f8 100644 --- a/app/admin/controller/Page.php +++ b/app/admin/controller/Page.php @@ -4,6 +4,7 @@ namespace app\admin\controller; use app\common\model\Document as aModel; use app\common\model\DocumentCategory as cModel; +use app\common\model\DocumentPage; use app\common\model\Tag as TagModel; use app\common\model\DocumentArticle; use app\common\model\Comment as CommentModel; @@ -52,6 +53,7 @@ class Page extends AuthController ['page', 1], ['limit', 20], ]); + $where["type"] = aModel::DOCUMENT_TYPE_PAGE; return app("json")->layui(aModel::systemPage($where)); } @@ -173,7 +175,6 @@ class Page extends AuthController /** * 新增文章 - * @param $category_id * @return string * @throws DataNotFoundException * @throws DbException @@ -181,44 +182,57 @@ class Page extends AuthController * @author 李玉坤 * @date 2021-03-10 14:46 */ - public function add($category_id = '') + public function add() { - $where = [ - 'name' => '', - 'status' => '' - ]; + // 获取页面模板列表 + $themeList = []; + $themeDir = public_path('template').system_config('web_template').'/pc/page'; + if ($dh = opendir($themeDir)) { + while (($file = readdir($dh)) !== false) { - $this->assign("category", $category); - $this->assign("category_id", $category_id); + if ( $file != "." && $file != "..") { + $themeList[] = $file; + } + } + closedir($dh); + } + $this->assign("themeList", $themeList); return $this->fetch(); } /** * 编辑页 - * @return string - * @throws \Exception - * @author 李玉坤 - * @date 2021-02-20 17:00 + * @return string|void + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException */ public function edit() { $where = Util::postMore([ - ['name', ''], ['id', ''] ]); if ($where['id'] == '') { - return $this->error('数据不存在'); + $this->error('数据不存在'); } - $category = cModel::systemPage($where); - $category = get_tree_list($category); - $info = aModel::get($where['id']); - $content = DocumentArticle::get($where['id']); - if ($content) { - $info->content = $content->content; - } else { - $info->content = ''; + $info = (new DocumentPage())->getInfo($where["id"]); + if (empty($info)) { + $this->error('数据不存在'); } - $this->assign("category", $category); + // 获取页面模板列表 + $themeList = []; + $themeDir = public_path('template/'); + $defaultTheme = system_config('web_template'); + if ($dh = opendir($themeDir.'/'.$defaultTheme.'/pc/page')) { + if ((is_dir($themeDir . "/" . $file)) && $file != "." && $file != "..") { + while (($file = readdir($dh)) !== false) { + $pageList[] = $file; + } + } + + closedir($dh); + } + $this->assign("themeList", $themeList); $this->assign("info", $info); return $this->fetch(); } diff --git a/app/admin/view/article/add.html b/app/admin/view/article/add.html index 6083161..7701688 100644 --- a/app/admin/view/article/add.html +++ b/app/admin/view/article/add.html @@ -17,20 +17,18 @@