From c6a0489fa8360a3fcce038c281a3bbc46d7318fd Mon Sep 17 00:00:00 2001
From: muzi_ys <1099438829@qq.com>
Date: Mon, 4 Jul 2022 00:54:39 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=BC=E8=88=AA=E5=92=8C?=
=?UTF-8?q?=E5=8D=95=E9=A1=B5=E9=9D=A2=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/admin/controller/Index.php | 79 ++++
app/admin/controller/Nav.php | 144 ++++++++
app/admin/controller/Page.php | 278 ++++++++++++++
app/admin/view/nav/index.html | 340 +++++++++++++++++
app/admin/view/page/add.html | 300 +++++++++++++++
app/admin/view/page/comment.html | 286 +++++++++++++++
app/admin/view/page/edit.html | 317 ++++++++++++++++
app/admin/view/page/index.html | 254 +++++++++++++
app/api/controller/Index.php | 100 +++++
app/common/constant/Data.php | 1 +
app/common/model/Nav.php | 195 ++++++++++
app/common/taglib/Ape.php | 34 ++
app/index/common.php | 217 ++++++++++-
app/index/controller/Article.php | 21 +-
app/index/controller/Index.php | 64 +++-
app/index/controller/Page.php | 345 ++++++++++++++++++
config/filesystem.php | 6 +-
public/template/default/pc/index/about.html | 327 +++++++++++++++++
public/template/default/pc/page/article.html | 327 +++++++++++++++++
public/template/default/pc/public/footer.html | 2 +-
public/template/default/pc/public/header.html | 22 +-
vendor/composer/autoload_files.php | 4 +-
vendor/composer/autoload_static.php | 4 +-
vendor/composer/installed.json | 48 +--
vendor/composer/installed.php | 22 +-
vendor/services.php | 2 +-
vendor/symfony/polyfill-mbstring/Mbstring.php | 2 +-
vendor/symfony/polyfill-mbstring/README.md | 2 +-
.../symfony/polyfill-mbstring/composer.json | 2 +-
vendor/symfony/polyfill-php72/README.md | 9 +-
vendor/symfony/polyfill-php72/composer.json | 2 +-
vendor/symfony/polyfill-php80/README.md | 7 +-
vendor/symfony/polyfill-php80/composer.json | 2 +-
33 files changed, 3675 insertions(+), 90 deletions(-)
create mode 100644 app/admin/controller/Nav.php
create mode 100644 app/admin/controller/Page.php
create mode 100644 app/admin/view/nav/index.html
create mode 100644 app/admin/view/page/add.html
create mode 100644 app/admin/view/page/comment.html
create mode 100644 app/admin/view/page/edit.html
create mode 100644 app/admin/view/page/index.html
create mode 100644 app/api/controller/Index.php
create mode 100644 app/common/model/Nav.php
create mode 100644 app/index/controller/Page.php
create mode 100644 public/template/default/pc/index/about.html
create mode 100644 public/template/default/pc/page/article.html
diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php
index 46f96d6..5fb68c3 100644
--- a/app/admin/controller/Index.php
+++ b/app/admin/controller/Index.php
@@ -4,7 +4,9 @@ namespace app\admin\controller;
use app\common\model\AdminAuth;
use app\common\model\Document;
+use app\common\model\Document as DocumentModel;
use app\common\model\DocumentCategory;
+use app\common\model\DocumentCategory as DocumentCategoryModel;
use app\common\model\MessageForm;
use Exception;
use think\db\exception\DataNotFoundException;
@@ -67,4 +69,81 @@ class Index extends AuthController
}
return app("json")->success($menuList);
}
+
+ /**
+ * 生成sitemap.xml
+ */
+ public function sitemap()
+ {
+ //获取协议
+ $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ?
+ "https://" : "http://";
+ //获取域名
+ $domain = $protocol . $_SERVER['HTTP_HOST'];
+ //获取页码
+ $page = input('page/d');
+ if (!$page) {
+ $page = 1;
+ }
+ $str = '';
+ if ($page == 1) {
+ if(file_exists('sitemap.xml'))
+ unlink('sitemap.xml');
+ $str .= '';
+ $str .= '';
+ //首页
+ $str .= '';
+ $str .= '' . $domain . '';
+ $str .= '' . date('Y-m-d', time()) . '';
+ $str .= 'daily';
+ $str .= '1.0';
+ $str .= '';
+ }
+ $pagesize = 100;
+
+ //获取文章分类url
+ $documentCategoryModel=new DocumentCategoryModel();
+ $categoryInfo = $documentCategoryModel->field('id,title,create_time')
+ ->where('display', 1)->where('status', 1)
+ ->page($page, $pagesize)
+ ->order('id desc')->select();
+
+ foreach ($categoryInfo as $v) {
+ $str .= '';
+ $str .= '' . $domain . url('article/lists?id=' . $v['id']) . '';
+ $str .= '' . $v['create_time']. '';
+ $str .= 'always';
+ $str .= '0.8';
+ $str .= '';
+ }
+ //获取详细页分类url
+ $documentModel=new DocumentModel();
+ $documentInfo =$documentModel->field('id,create_time')
+ ->where('status', 1)
+ ->page($page, $pagesize)
+ ->order('id desc')->select();
+
+ foreach ($documentInfo as $v) {
+ $str .= '';
+ $str .= '' . $domain . url('article/detail?id=' . $v['id']) . $v['id'] . '';
+ $str .= '' . $v['create_time'] . '';
+ $str .= 'monthly';
+ $str .= '0.6';
+ $str .= '';
+ }
+ if (count($categoryInfo) < $pagesize && count($documentInfo) < $pagesize) {
+ $str .= '';
+ if (!(file_put_contents('sitemap.xml', $str, FILE_APPEND | LOCK_EX))) {
+ $this->error('站点地图更新失败!');
+ } else {
+ $this->success('站点地图全部更新完成!', null,'stop');
+ }
+ }
+ //写入
+ if (!(file_put_contents('sitemap.xml', $str, FILE_APPEND | LOCK_EX))) {
+ $this->error('站点地图更新失败!');
+ } else {
+ $this->success('站点地图正在生成,请稍后(' . $page . ')...', 'sitemap?page=' . ($page + 1));
+ }
+ }
}
\ No newline at end of file
diff --git a/app/admin/controller/Nav.php b/app/admin/controller/Nav.php
new file mode 100644
index 0000000..efa3e1a
--- /dev/null
+++ b/app/admin/controller/Nav.php
@@ -0,0 +1,144 @@
+fetch();
+ }
+
+ /**
+ * 导航列表
+ * @param Request $request
+ * @return array
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ */
+ public function lst(Request $request)
+ {
+ $where = Util::postMore([
+ ['title', ''],
+ ['status', '']
+ ]);
+ return app("json")->layui(\app\common\model\Nav::systemPage($where));
+ }
+
+ /**
+ * 添加
+ * @param int $pid
+ * @return string
+ * @throws FormBuilderException
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @throws Exception
+ */
+ public function add($pid = 0)
+ {
+ $form = array();
+ $form[] = Elm::select('pid', '上级导航', (int)$pid)->options(aModel::returnOptions())->col(10);
+ $form[] = Elm::input('title', '导航名称')->col(10);
+ // $form[] = Elm::frameInput('icon', '图标', Url::buildUrl('admin/icon/index', array('fodder' => 'icon')))->icon("ios-ionic")->width('96%')->height('390px')->col(10);
+ $form[] = Elm::input('url', '链接地址')->col(10);
+ $form[] = Elm::input('params', '参数')->placeholder("php数组,不懂不要填写")->col(10);
+ $form[] = Elm::number('sort', '排序')->col(10);
+ $form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
+ $form = Form::make_post_form($form, url('save')->build());
+ $this->assign(compact('form'));
+ return $this->fetch("public/form-builder");
+ }
+
+ /**
+ * 添加
+ * @param int $id
+ * @return string
+ * @throws FormBuilderException
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ */
+ public function edit($id = 0)
+ {
+ if (!$id) return app("json")->fail("导航id不能为空");
+ $ainfo = aModel::get($id);
+ if (!$ainfo) return app("json")->fail("没有该导航");
+ $form = array();
+ $form[] = Elm::select('pid', '上级导航', $ainfo['pid'])->options(aModel::returnOptions())->col(10);
+ $form[] = Elm::input('title', '导航名称', $ainfo['title'])->col(10);
+ //$form[] = Elm::frameInput('icon', '图标', Url::buildUrl('admin/widget.icon/index', array('fodder' => 'icon')), $ainfo['icon'])->icon("ios-ionic")->width('96%')->height('390px')->col(10);
+ $form[] = Elm::input('url', '链接地址', $ainfo['url'])->col(10);
+ $form[] = Elm::input('params', '参数', $ainfo['params'])->placeholder("php数组,不懂不要填写")->col(10);
+ $form[] = Elm::number('sort', '排序', $ainfo['sort'])->col(10);
+ $form[] = Elm::radio('status', '状态', $ainfo['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
+ $form = Form::make_post_form($form, url('save', ['id' => $id])->build());
+ $this->assign(compact('form'));
+ return $this->fetch("public/form-builder");
+ }
+
+ /**
+ * 保存
+ * @param $id
+ * @return
+ */
+ public function save($id = "")
+ {
+ $data = Util::postMore([
+ ['title', ''],
+ ['pid', 0],
+ ['icon', ''],
+ ['url', ''],
+ ['params', ''],
+ ['sort', 0],
+ ['status', 1]
+ ]);
+ if ($data['title'] == "") return app("json")->fail("导航名称不能为空");
+ if ($data['pid'] == "") return app("json")->fail("上级归属不能为空");
+ if ($data['url'] == "") return app("json")->fail("链接不能为空");
+ if ($id == "") {
+ $data['create_time'] = time();
+ $res = aModel::insert($data);
+ } else {
+ $data['update_time'] = time();
+ $res = aModel::update($data, ['id' => $id]);
+ }
+ //清理缓存
+ aModel::clearCache($this->adminId);
+ return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败");
+ }
+
+ /**
+ * 修改字段
+ * @param $id
+ * @return aModel
+ */
+ public function field($id)
+ {
+ if (!$id) return app("json")->fail("参数有误,Id为空!");
+ $where = Util::postMore([['field', ''], ['value', '']]);
+ if ($where['field'] == '' || $where['value'] == '') return app("json")->fail("参数有误!");
+ //清理缓存
+ aModel::clearCache($this->adminId);
+ return aModel::update([$where['field'] => $where['value']], ['id' => $id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
+ }
+}
\ No newline at end of file
diff --git a/app/admin/controller/Page.php b/app/admin/controller/Page.php
new file mode 100644
index 0000000..fe62267
--- /dev/null
+++ b/app/admin/controller/Page.php
@@ -0,0 +1,278 @@
+fetch();
+ }
+
+ /**
+ * 文章列表
+ * @return mixed
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @author 李玉坤
+ * @date 2021-02-15 23:26
+ */
+ public function lst()
+ {
+ $where = Util::postMore([
+ ['title', ''],
+ ['start_time', ''],
+ ['end_time', ''],
+ ['status', ''],
+ ['page', 1],
+ ['limit', 20],
+ ]);
+ return app("json")->layui(aModel::systemPage($where));
+ }
+
+ /**
+ * 保存
+ * @param string $id
+ * @return mixed
+ * @author 李玉坤
+ * @date 2021-02-28 22:43
+ */
+ public function save($id = "")
+ {
+ $data = Util::postMore([
+ ['id', ''],
+ ['author', ''],
+ ['title', ''],
+ ['alias', ''],
+ ['category_id', ''],
+ ['type', 'page'],
+ ['abstract', ''],
+ ['keywords', ''],
+ ['content', ''],
+ ['description', ''],
+ ['is_recommend', 0],
+ ['is_top', 0],
+ ['is_hot', 0],
+ ['link_str', ''],
+ ['cover_path', ''],
+ ['display', 1],
+ ['tags', ''],
+ ['sort', ''],
+ ['status', 1],
+ ]);
+
+ if ($data['title'] == "") return app("json")->fail("文章名称不能为空");
+ if ($data['category_id'] == "") return app("json")->fail("栏目分类不能为空");
+ if ($data['cover_path'] == "") return app("json")->fail("主图不能为空");
+ $error = "";
+ try {
+ $data['author'] = $data['author'] ?: $this->adminInfo['nickname'];
+ $data['uid'] = $this->adminId;
+ $content = '';
+ if (!empty($data['content'])) {
+ $content = $data['content'];
+ }
+ //判断摘要是否为空,为空则从内容摘取
+ $data['abstract'] = $data['abstract'] ?: mb_substr(strip_tags($content), 0, 100);
+ //判断是否写了别名,没写则需要生成
+ if ($data['alias'] == "") $data['alias'] = get_rand_str(6);
+ unset($data['content']);
+ if ($data['is_recommend']) $data['is_recommend'] = 1;
+ if ($data['is_hot']) $data['is_hot'] = 1;
+ if ($data['display']) $data['display'] = 1;
+ if ($data['is_top']) $data['is_top'] = 1;
+ if ($id == "") {
+ $data['uid'] = $this->adminInfo['uid'];
+ $data['author'] = $data['author'] ?: $this->adminInfo['nickname'];
+ $data['create_date'] = date("Y-m-d");
+ $data['create_time'] = time();
+ $data['update_time'] = time();
+ $id = aModel::insertGetId($data);
+ if (!empty($content)) {
+ $updateData = [
+ 'id' => $id,
+ 'content' => $content
+ ];
+ DocumentArticle::insert($updateData);
+ }
+ if (!empty($data['tags'])) {
+ $tagModel = new TagModel();
+ $tagModel->createTags($data['tags'], $id, $this->adminId);
+ }
+ } else {
+ $ainfo = aModel::get($id);
+ if (!$ainfo) return app("json")->fail("数据不存在");
+ aModel::where('id', $id)->save($data);
+ if (!empty($content)) {
+ $contentInfo = DocumentArticle::where('id', $id)->find();
+ if (!$contentInfo) {
+ $updateData = [
+ 'id' => $id,
+ 'content' => $content
+ ];
+ DocumentArticle::insert($updateData);
+ } else {
+ //更新文档
+ DocumentArticle::where('id', $id)->save(['content' => $content]);
+ }
+ }
+ if (!empty($data['tags'])) {
+ $tagModel = new TagModel();
+ $tagModel->createTags($data['tags'], $id, $this->adminId);
+ }
+ }
+ $res = true;
+ } catch (Exception $e) {
+ Log::error('文章修改失败:失败原因:' . $e->getMessage());
+ $error = $e->getMessage();
+ $res = false;
+ }
+ return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:".$error);
+ }
+
+
+ /**
+ * 修改字段
+ * @param $id
+ * @return mixed
+ * @author 李玉坤
+ * @date 2021-02-16 23:12
+ */
+ public function field($id)
+ {
+ if (!$id) return app("json")->fail("参数有误,Id为空!");
+ $where = Util::postMore([['field', ''], ['value', '']]);
+ if ($where['field'] == '' || $where['value'] == '') return app("json")->fail("参数有误!");
+ return aModel::update([$where['field'] => $where['value']], ['id' => $id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
+ }
+
+ /**
+ * 新增文章
+ * @param $category_id
+ * @return string
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @author 李玉坤
+ * @date 2021-03-10 14:46
+ */
+ public function add($category_id = '')
+ {
+ $where = [
+ 'name' => '',
+ 'status' => ''
+ ];
+ $category = cModel::systemPage($where);
+ $category = get_tree_list($category);
+ $this->assign("category", $category);
+ $this->assign("category_id", $category_id);
+ return $this->fetch();
+ }
+
+ /**
+ * 编辑页
+ * @return string
+ * @throws \Exception
+ * @author 李玉坤
+ * @date 2021-02-20 17:00
+ */
+ public function edit()
+ {
+ $where = Util::postMore([
+ ['name', ''],
+ ['id', '']
+ ]);
+ if ($where['id'] == '') {
+ return $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 = '';
+ }
+ $this->assign("category", $category);
+ $this->assign("info", $info);
+ return $this->fetch();
+ }
+
+ /**
+ * 文章管理主页
+ * @return string
+ * @throws \Exception
+ */
+ public function comment()
+ {
+ return $this->fetch();
+ }
+
+ /**
+ * 文章评论列表
+ * @return mixed
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @author 李玉坤
+ * @date 2021-11-03 23:28
+ */
+ public function commentList()
+ {
+ $where = Util::postMore([
+ ['document_id', ''],
+ ['name', ''],
+ ['tel', ''],
+ ['email', ''],
+ ['start_time', ''],
+ ['end_time', ''],
+ ['page', 1],
+ ['limit', 20],
+ ]);
+ if ($where['document_id'] == "") return app("json")->fail("参数错误");
+ return app("json")->layui(CommentModel::systemPage($where));
+ }
+
+
+ /**
+ * 修改字段
+ * @param $id
+ * @return mixed
+ * @author 李玉坤
+ * @date 2021-02-16 23:12
+ */
+ public function commentField($id)
+ {
+ if (!$id) return app("json")->fail("参数有误,Id为空!");
+ $where = Util::postMore([['field', ''], ['value', '']]);
+ if ($where['field'] == '' || $where['value'] == '') return app("json")->fail("参数有误!");
+ return CommentModel::update([$where['field'] => $where['value']], ['id' => $id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
+ }
+
+}
\ No newline at end of file
diff --git a/app/admin/view/nav/index.html b/app/admin/view/nav/index.html
new file mode 100644
index 0000000..0a79d0e
--- /dev/null
+++ b/app/admin/view/nav/index.html
@@ -0,0 +1,340 @@
+
+
+
+ 登录页面 - {:system_config('title')}后台管理系统
+ {include file="public/header" /}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{include file="public/footer"/}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/admin/view/page/add.html b/app/admin/view/page/add.html
new file mode 100644
index 0000000..6083161
--- /dev/null
+++ b/app/admin/view/page/add.html
@@ -0,0 +1,300 @@
+
+
+
+ 添加文章 - {:system_config('title')}后台管理系统
+ {include file="public/header" /}
+
+
+
+
+
+
+
+{include file="public/footer"/}
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/admin/view/page/comment.html b/app/admin/view/page/comment.html
new file mode 100644
index 0000000..bdd945d
--- /dev/null
+++ b/app/admin/view/page/comment.html
@@ -0,0 +1,286 @@
+
+
+
+ 文章评论管理 - {:system_config('title')}后台管理系统
+ {include file="public/header" /}
+
+
+
+{include file="public/footer"/}
+
+
+
\ No newline at end of file
diff --git a/app/admin/view/page/edit.html b/app/admin/view/page/edit.html
new file mode 100644
index 0000000..da5691d
--- /dev/null
+++ b/app/admin/view/page/edit.html
@@ -0,0 +1,317 @@
+
+
+
+ 编辑文章 - {:system_config('title')}后台管理系统
+ {include file="public/header" /}
+
+
+
+
+
+
+
+{include file="public/footer"/}
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/admin/view/page/index.html b/app/admin/view/page/index.html
new file mode 100644
index 0000000..5360f26
--- /dev/null
+++ b/app/admin/view/page/index.html
@@ -0,0 +1,254 @@
+
+
+
+ 文章管理 - {:system_config('title')}后台管理系统
+ {include file="public/header" /}
+
+
+
+{include file="public/footer"/}
+
+
+
\ No newline at end of file
diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php
new file mode 100644
index 0000000..fa383c9
--- /dev/null
+++ b/app/api/controller/Index.php
@@ -0,0 +1,100 @@
+urlrecord('网站首页');
+ }
+ //清除可能存在的栏目分类树id
+ cache(Data::CURR_CATEGORY_PATENT_ID, false);
+ //模板兼容性标签
+ $this->assign('id', false);
+ $this->assign('cid', false);
+ return $this->fetch();
+ }
+
+ /**
+ * 留言页面
+ * @param Request $request
+ * @return string
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @author 李玉坤
+ * @date 2021-10-17 1:03
+ */
+ public function msg(Request $request)
+ {
+ if (request()->isPost()) {
+ $data = Util::postMore([
+ ['author', ''],
+ ['tel', ''],
+ ['email', ''],
+ ['content', ''],
+ ]);
+ $data['create_time'] = time();
+ $messageFormValidate = new MessageFormValidate();
+ if (!$messageFormValidate->check($data)) {
+ $this->error($messageFormValidate->getError());
+ }
+ $res = MessageFormModel::create($data);
+ if ($res) {
+ $this->success('留言成功');
+ } else {
+ $this->error('留言失败');
+ }
+ } else {
+ //清除可能存在的栏目分类树id
+ cache(Data::CURR_CATEGORY_PATENT_ID, false);
+ //模板兼容性标签
+ $this->assign('id', false);
+ $this->assign('cid', false);
+ return $this->fetch();
+ }
+ }
+
+ /**
+ * 标签列表
+ * @return mixed
+ * @author 李玉坤
+ * @date 2021-11-11 0:27
+ */
+ public function tagList()
+ {
+ $where = Util::postMore([
+ ['name', ''],
+ ['document_id', ''],
+ ['start_time', ''],
+ ['end_time', ''],
+ ['page', 1],
+ ['limit', 10]
+ ]);
+ return app("json")->layui(TagModel::getList($where));
+ }
+}
\ No newline at end of file
diff --git a/app/common/constant/Data.php b/app/common/constant/Data.php
index 6952d77..31c6fea 100644
--- a/app/common/constant/Data.php
+++ b/app/common/constant/Data.php
@@ -11,6 +11,7 @@ class Data
{
//缓存数据key
const DATA_FRIEND_LINK = 'data_friend_link'; //友链
+ const DATA_NAV_LIST = 'data_nav_list'; //页面导肮
const DATA_DOCUMENT_CATEGORY_LIST = 'data_document_category_list'; //文章分类
const CURR_CATEGORY_PATENT_ID = 'curr_category_patent_id'; //当前分类父级id
const DATA_SYSTEM_CONFIG = 'data_system_config'; //系统配置
diff --git a/app/common/model/Nav.php b/app/common/model/Nav.php
new file mode 100644
index 0000000..fd61526
--- /dev/null
+++ b/app/common/model/Nav.php
@@ -0,0 +1,195 @@
+where("status", $where['status']);
+ if (isset($where['title']) && $where['title'] != '') $model = $model->where("name|id", "like", "%$where[name]%");
+ $model = $model->field(['id', 'title', 'icon', 'pid', 'params', 'url', 'sort', 'status']);
+ $model = $model->order(["sort desc", "id"]);
+ $data = $model->select();
+ return $data->toArray() ?: [];
+ }
+
+ /**
+ * 获取选择数据
+ * @param int $pid
+ * @param array $auth
+ * @return array
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ */
+ public static function lst(int $pid = 0, array $auth = []): array
+ {
+ $model = new self;
+ $model = $model->where("pid", $pid);
+ if ($auth != []) $model = $model->where("id", 'in', $auth);
+ $model = $model->field(['title', 'id']);
+ $model = $model->order(["sort desc", "id"]);
+ $data = $model->select()->each(function ($item) use ($auth) {
+ $item['children'] = self::lst($item['id'], $auth);
+ });
+ return $data->toArray() ?: [];
+ }
+
+ /**
+ * 获取菜单列表缓存key
+ * @param $adminId
+ * @return string
+ * @author 李玉坤
+ * @date 2021-06-09 17:24
+ */
+ public static function getMenuCacheKey($adminId)
+ {
+ return 'menu:List:' . $adminId;
+ }
+
+ /**
+ * @return string
+ * @author 李玉坤
+ * @date 2021-06-15 11:11
+ */
+ public static function getAuthCacheKey()
+ {
+ return 'auth:key:list';
+ }
+
+ public static function clearCache($adminId)
+ {
+ cache(AdminAuth::getMenuCacheKey($adminId), null);
+ cache(AdminAuth::getAuthCacheKey(), null);
+ }
+
+ /**
+ * 遍历选择项
+ * @param array $data
+ * @param $list
+ * @param int $num
+ * @param bool $clear
+ */
+ public static function myOptions(array $data, &$list, $num = 0, $clear = true)
+ {
+ foreach ($data as $k => $v) {
+ $list[] = ['value' => $v['id'], 'label' => self::cross($num) . $v['title']];
+ if (is_array($v['children']) && !empty($v['children'])) {
+ self::myOptions($v['children'], $list, $num + 1, false);
+ }
+ }
+ }
+
+ /**
+ * 返回选择项
+ * @return array
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ */
+ public static function returnOptions(): array
+ {
+ $list = [];
+ $list[] = ['value' => 0, 'label' => '总后台'];
+ self::myOptions(self::lst(), $list, 1, true);
+ return $list;
+ }
+
+ /**
+ * 横线
+ * @param int $num
+ * @return string
+ */
+ public static function cross(int $num = 0): string
+ {
+ $str = "";
+ if ($num == 1) $str .= "|--";
+ elseif ($num > 1) for ($i = 0; $i < $num; $i++)
+ if ($i == 0) $str .= "|--";
+ else $str .= "--";
+ return $str . " ";
+ }
+
+ /**
+ * 生成treeData
+ * @param int $pid
+ * @param array $auth
+ * @param array $list
+ * @return array
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ */
+ public static function selectAndBuildTree(int $pid = 0, array $auth = [], array $list = [])
+ {
+ $model = new self;
+ $model = $model->where("pid", $pid);
+ if ($auth != []) $model = $model->where("id", 'in', $auth);
+ $model = $model->where("status", 1);
+ $model = $model->field(['title', 'id']);
+ $model = $model->order(["sort desc", "id"]);
+ $data = $model->select();
+ foreach ($data as $k => $v) {
+ $list[] = self::buildTreeData($v['id'], $v['title'], self::selectAndBuildTree($v['id'], $auth));
+ }
+ return $list;
+ }
+
+ /**
+ * 获取所有权限id
+ * @param array $ids
+ * @return array
+ */
+ public static function getIds(array $ids = []): array
+ {
+ if (empty($ids)) return self::where("status", 1)->column("id");
+ $pids = self::where("id", "in", $ids)->column("pid");
+ return array_merge($ids, $pids) ?: [];
+ }
+
+ /**
+ * 获取操作名
+ * @param string $module
+ * @param string $controller
+ * @param string $action
+ * @return string
+ */
+ public static function getNameByAction(string $module, string $controller, string $action)
+ {
+ return self::where("module", $module)->where("controller", $controller)->where("action", $action)->value("title") ?: '未知操作';
+ }
+ /**
+ * 生成单个节点
+ * @param $id
+ * @param $title
+ * @return array
+ */
+ public static function buildTreeData($id, $title, $children = []): array
+ {
+ $tree = Elm::TreeData($id, $title);
+ if (!empty($children)) $tree = $tree->children($children);
+ return $tree->getOption();
+ }
+}
\ No newline at end of file
diff --git a/app/common/taglib/Ape.php b/app/common/taglib/Ape.php
index 4649a13..9ba61da 100644
--- a/app/common/taglib/Ape.php
+++ b/app/common/taglib/Ape.php
@@ -24,8 +24,42 @@ class Ape extends TagLib
'relevant' => ['attr' => 'id,model,void,row', 'close' => 1],
'tags' => ['attr' => 'tags,void', 'close' => 1],
'archive' => ['attr' => 'type,format,void', 'close' => 1],
+ 'nav' => ['attr' => 'type,typeId,row,void,where,orderBy,display', 'close' => 1],
];
+ /**
+ * 导航列表
+ * type,栏目分类数据读取分类
+ * typeId,导航列表分类,数字,字符串,或者变量
+ */
+ public function tagNav($tag, $content)
+ {
+ $type = isset($tag['type']) ? $tag['type'] : 'son';
+ $typeId = isset($tag['typeId']) ? $tag['typeId'] : '$cid';
+ $row = isset($tag['row']) ? $tag['row'] : 100;
+ $void = isset($tag['void']) ? $tag['void'] : 'field';
+ $where = isset($tag['where']) ? $tag['where'] : '';
+ $orderBy = isset($tag['orderBy']) ? $tag['orderBy'] : 'sort asc';
+
+ $display = isset($tag['display']) ? $tag['display'] : 1;
+ $display = $display == 1 ? 1 : 0;
+ //3中传参类型
+ //1、栏目id,数字类型
+ //2、多个栏目id,逗号隔开
+ //3、变量
+ //只有当多个栏目id时,才需要单引号加持。保证生成的为字符串
+ if (strpos($typeId, ',')) {
+ $typeId = "'$typeId'";
+ }
+
+ $parse = '';
+ $parse .= '{volist name="__LIST__" id="' . $void . '"}';
+ $parse .= $content;
+ $parse .= '{/volist}';
+ return $parse;
+ }
/**
* 栏目列表
diff --git a/app/index/common.php b/app/index/common.php
index c268ce8..6437594 100644
--- a/app/index/common.php
+++ b/app/index/common.php
@@ -7,6 +7,7 @@ use app\common\model\DocumentCategory;
use app\common\model\DocumentCategoryContent;
use app\common\model\FriendLink;
use app\common\model\Tag;
+use app\common\model\Nav;
use think\App;
use think\Collection;
use think\db\exception\DataNotFoundException;
@@ -14,6 +15,7 @@ use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\facade\Db;
+use think\facade\Route as Url;
// 应用公共文件
/**
@@ -63,7 +65,7 @@ function get_document_category_list()
$documentCategoryList = DocumentCategory::where('status', 1)->order('sort asc')->select()->toArray();
//转换,让id作为数组的键
$documentCategory = [];
- foreach ($documentCategoryList as $key => $item) {
+ foreach ($documentCategoryList as $item) {
//根据栏目类型,生成栏目url
$item['url'] = make_category_url($item);
$documentCategory[$item['id']] = $item;
@@ -73,7 +75,6 @@ function get_document_category_list()
return $documentCategory;
}
-
/**
* 获取一个文章分类
*/
@@ -90,6 +91,7 @@ function get_document_category($x, $field = false)
if ($field) {
return $documentCategoryList[$x][$field];
} else {
+ $documentCategoryList[$x]['child'] = implode(",",array_column(getSubs($documentCategoryList,$x),"id"));
return $documentCategoryList[$x];
}
}
@@ -262,6 +264,21 @@ function get_document_category_by_parent($pid, $row)
return $tempArr;
}
+/*
+ * 获取所有子集元素
+ */
+function getSubs($categorys,$catId=0,$level=1){
+ $subs=array();
+ foreach($categorys as $item){
+ if($item['pid']==$catId){
+ $item['level']=$level;
+ $subs[]=$item;
+ $subs=array_merge($subs,getSubs($categorys,$item['id'],$level+1));
+ }
+ }
+ return $subs;
+}
+
function get_document_category_all()
{
$documentCategoryList = get_document_category_list();
@@ -1025,3 +1042,199 @@ function comment_face($incoming_comment,$path)
}
return $incoming_comment;
}
+
+
+/**
+ * 模板-获取导航
+ * @param $type
+ * @param $typeId
+ * @param int $row
+ * @param string $where
+ * @param string $orderby
+ * @return DocumentCategory[]|array|bool|Collection
+ * @throws Exception
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @author 李玉坤
+ * @date 2021-11-12 21:48
+ */
+function tpl_get_nav($type, $typeId, $row = 100, $where = '', $orderby = '')
+{
+ switch ($type) {
+ case "all":
+ //获取顶级导航
+ return get_nav_all();
+ break;
+ case 'top':
+ //获取顶级导航
+ return get_nav_by_parent(0, $row);
+ break;
+ case 'son':
+ //获取子级导航
+ if (!$typeId) {
+ throw new Exception('请指定要获取的栏目导航id!');
+ }
+ return get_nav_by_parent($typeId, $row);
+ break;
+ case 'self':
+ //获取同级导航
+ if (!$typeId) {
+ throw new Exception('请指定要获取的栏目导航id!');
+ }
+ $dc = get_nav($typeId);
+ if (!$dc) {
+ return false;
+ }
+ return get_nav_by_parent($dc['pid'], $row);
+ break;
+ case 'find':
+ //获取所有子孙导航,此操作读取数据库,非缓存!
+ if (!$typeId) {
+ throw new Exception('请指定要获取的栏目导航id!');
+ }
+ $dc = get_nav($typeId);
+ if (!$dc) {
+ throw new Exception('导航不存在或已删除!');
+ }
+ $tempArr = Nav::where('id', 'in', $dc['child'])->where('status', 1)->limit($row);
+ $tempArr = $tempArr->select();
+ foreach ($tempArr as $key => $item) {
+ //根据栏目类型,生成栏目url
+ $item['url'] = make_category_url($item);
+ $tempArr[$key] = $item;
+ }
+ return $tempArr;
+ break;
+ case 'parent':
+ //获取父级导航
+ if (!$typeId) {
+ throw new Exception('请指定要获取的栏目导航id!');
+ }
+ $dc = get_nav($typeId);
+ $tempArr = array();
+ $parent = get_nav($dc['pid']);
+ array_push($tempArr, $parent);
+ return $tempArr;
+ break;
+ case 'root':
+ if (!$typeId) {
+ throw new Exception('请指定要获取的栏目导航id!');
+ }
+ $dc = get_nav($typeId);
+ if ($dc['pid'] != 0) {
+ //获取根导航,此操作读取数据库,非缓存!
+ $dc = Nav::where('pid', 0)->where('status', 1)
+ ->where("CONCAT(',',child,',') like '%,$typeId,%'")->limit($row);
+ $dc = $dc->find();
+ }
+ //根据栏目类型,生成栏目url
+ $dc['url'] = make_category_url($dc);
+ $tempArr = [];
+ array_push($tempArr, $dc);
+ return $tempArr;
+ break;
+ case 'where':
+ //根据自定义条件获取导航(where语句),此操作读取数据库,非缓存!
+ $tempArr = Nav::where('status', 1)->where($where)->order($orderby)->limit($row);
+ $tempArr = $tempArr->select();
+ foreach ($tempArr as $key => $item) {
+ //根据栏目类型,生成栏目url
+ $item['url'] = make_category_url($item);
+ $tempArr[$key] = $item;
+ }
+ return $tempArr;
+ break;
+ case 'ids':
+ //根据多个栏目id,逗号隔开的那种,获得栏目列表
+ $tempArr = Nav::where('status', 1)->where('id', 'in', $typeId)->order($orderby)->limit($row);
+ $tempArr = $tempArr->select();
+ foreach ($tempArr as $key => $item) {
+ //根据栏目类型,生成栏目url
+ $item['url'] = make_category_url($item);
+ $tempArr[$key] = $item;
+ }
+ return $tempArr;
+ break;
+ default:
+ $tempArr = [];
+ return $tempArr;
+ break;
+ }
+}
+
+
+/**
+ * 获取一个文章导航
+ */
+function get_nav($x, $field = false)
+{
+ if (!$x) {
+ throw new Exception('请指定要获取的栏目导航id!');
+ }
+ //获取缓存的文章菜单
+ $list = get_nav_list();
+ if (!isset($list[$x])) {
+ return false;
+ }
+ if ($field) {
+ return $list[$x][$field];
+ } else {
+ return $list[$x];
+ }
+}
+
+/**
+ * 获取导航列表
+ */
+function get_nav_list()
+{
+ //缓存文章菜单
+ $navList = cache(Data::DATA_NAV_LIST);
+ if ($navList === null) {
+ $list = Nav::where('status', 1)->order('sort asc')->select()->toArray();
+ //转换,让id作为数组的键
+ $navList = [];
+ foreach ($list as $item) {
+ $navList[$item['id']] = $item;
+ }
+ cache(Data::DATA_NAV_LIST, $navList);
+ }
+ return $navList;
+}
+
+function get_nav_all()
+{
+ $list = get_nav_list();
+ $tempArr = array();
+ foreach ($list as $item) {
+ if ($item['pid'] == 0) {
+ $tempArr[$item['id']] = $item;
+ } else {
+ $tempArr[$item['pid']]['child'][] = $item;
+ }
+ }
+ return $tempArr;
+}
+
+/**
+ * 根据父级导航id获取子导航
+ * $pid=父级id
+ * $row=获取多少数目
+ */
+function get_nav_by_parent($pid, $row)
+{
+ $list = get_nav_list();
+ $x = 1;
+ $tempArr = array();
+ foreach ($list as $item) {
+ if ($x > $row) {
+ break;
+ }
+ if ($item['pid'] == $pid) {
+ $x = $x + 1;
+ array_push($tempArr, $item);
+ }
+ }
+ return $tempArr;
+}
\ No newline at end of file
diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php
index 09ad2c9..7e27e08 100644
--- a/app/index/controller/Article.php
+++ b/app/index/controller/Article.php
@@ -18,7 +18,7 @@ use think\facade\Log;
/**
* 应用入口
- * Class Index
+ * Class Article
* @package app\index\controller
*/
class Article extends Base
@@ -249,25 +249,6 @@ class Article extends Base
return $this->fetch();
}
- /**
- * 标签列表
- * @return mixed
- * @author 李玉坤
- * @date 2021-11-11 0:27
- */
- public function tagList()
- {
- $where = Util::postMore([
- ['name', ''],
- ['document_id', ''],
- ['start_time', ''],
- ['end_time', ''],
- ['page', 1],
- ['limit', 10]
- ]);
- return app("json")->layui(TagModel::getList($where));
- }
-
/**
* 搜索页面
* @return string
diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php
index 412b2f6..9674cba 100644
--- a/app/index/controller/Index.php
+++ b/app/index/controller/Index.php
@@ -4,6 +4,7 @@ namespace app\index\controller;
use app\admin\extend\Util as Util;
use app\common\constant\Data;
+use app\common\model\Document;
use app\common\model\FriendLink as friendLinkModel;
use app\common\model\MessageForm as MessageFormModel;
use app\common\validate\MessageForm as MessageformValidate;
@@ -11,6 +12,7 @@ use app\Request;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
+use think\facade\Log;
/**
* 应用入口
@@ -83,7 +85,7 @@ class Index extends Base
}
/**
- * 留言
+ * 留言页面
* @param Request $request
* @return string
* @throws DataNotFoundException
@@ -121,4 +123,64 @@ class Index extends Base
return $this->fetch();
}
}
+
+ /**
+ * 关于页面
+ * @param Request $request
+ * @author 李玉坤
+ * @date 2022-06-21 23:48
+ */
+ public function about(Request $request)
+ {
+ $id = "about";
+ //获取该文章
+ $documentModel = new Document();
+ $article = $documentModel->where('status', 1)->where('id|alias', $id)->find();
+ if (!$article) {
+ $this->error('文章不存在或已删除!');
+ }
+ $article = $article->toArray();
+ //根据分类id找分类信息
+ $dc = get_document_category($article['category_id']);
+ if (!$dc) {
+ $this->error('栏目不存在或已删除!');
+ }
+ //获取该文章内容
+ //根据文章类型,加载不同的内容。
+ $articleType = $article['type'] ? $article['type'] : 'article';
+ $articleExt = $documentModel::name('document_' . $articleType)->where('id', $article['id'])->find();
+ if (!$articleExt) {
+ $this->error('文章不存在或已删除!');
+ }
+ $articleExt = $articleExt->toArray();
+ $article = array_merge($article, $articleExt);
+ //添加当前页面的位置信息
+ $article['position'] = tpl_get_position($dc);
+ //更新浏览次数
+ $documentModel->where('id', $article['id'])->inc('view')->update();
+ $templateFile = config('view.view_path') . 'article/' . $articleType . '.html';
+ if (!is_file($templateFile)) {
+ $this->error('模板文件不存在!');
+ }
+ $article['category_title'] = $dc['title'];
+ //判断SEO 为空则取系统
+ $article['keywords'] = $article['keywords'] ?: web_config('keywords');
+ $article['description'] = $article['description'] ?: web_config('description');
+ //输出文章内容
+ $this->assign('apeField', $article);
+ $this->assign('id', $id);
+ //当前页面所属分类id
+ $this->assign('cid', $article['category_id']);
+ //缓存当前页面栏目分类树ids
+ cache(Data::CURR_CATEGORY_PATENT_ID, $dc['pid'] ? $dc['pid'] . ',' . $article['category_id'] : $article['category_id']);
+ //设置文章的url
+ $article['link_str'] = make_detail_url($article);
+ //判断后台统计配置是否开启 1 开启
+ if (web_config("web_statistics") == 1) {
+ //统计url
+ $this->urlrecord($article['title']);
+ }
+ Log::info('详情页模板路径:' . $templateFile);
+ return $this->fetch('article/' . $articleType);
+ }
}
\ No newline at end of file
diff --git a/app/index/controller/Page.php b/app/index/controller/Page.php
new file mode 100644
index 0000000..b37ecd3
--- /dev/null
+++ b/app/index/controller/Page.php
@@ -0,0 +1,345 @@
+error('栏目不存在或已删除!');
+ }
+ //赋值分类id,可能是通过栏目分类id获取的栏目分类数据
+ $id = $dc['id'];
+ $documentCategoryModel = new DocumentCategory();
+ //栏目存在 增加访问量
+ $documentCategoryModel->where('id|alias', $id)->inc('view')->update();
+ //判断后台统计配置是否开启 1 开启
+ if (web_config("web_statistics") == 1) {
+ //统计url
+ $this->urlrecord($dc['title']);
+ }
+ //读取列表页模板
+ if ($dc['type'] == 0) {
+ if (empty($dc['template'])) {
+ $this->error('请在栏目分类中,指定当前栏目的列表模板!');
+ }
+ } elseif ($dc['type'] == 1) {
+ if (empty($dc['template'])) {
+ $this->error('请在栏目分类中,指定当前栏目的单篇模板!');
+ }
+ //如果是单篇栏目,加载内容
+ $contentModel = new DocumentCategoryContent();
+ $dcContent = $contentModel->find($id);
+ $dc['content'] = $dcContent['content'];
+ }
+ $listTmp = $dc['template'];
+ if (!is_file(config('view.view_path') . 'category/' . $listTmp)) {
+ $this->error('模板文件不存在!');
+ }
+ Log::info('列表页模板路径:' . config('view.view_path') . 'category/' . $listTmp);
+ //文章兼容字段
+ $dc['category_id'] = $dc['id'];
+ //判断seo标题是否存在
+ $dc['meta_title'] = $dc['meta_title'] ? $dc['meta_title'] : $dc['title'];
+ //判断SEO 为空则取系统
+ $article['keywords'] = $dc['keywords'] ?: web_config('keywords');
+ $article['description'] = $dc['description'] ?: web_config('description');
+ //添加当前页面的位置信息
+ $dc['position'] = tpl_get_position($dc);
+ //输出文章分类
+ $this->assign('apeField', $dc);
+ $this->assign('id', $id);
+ //当前页面所属分类id
+ $this->assign('cid', $id);
+ //缓存当前页面栏目分类树ids
+ cache(Data::CURR_CATEGORY_PATENT_ID, $dc['pid'] ? $dc['pid'] . ',' . $id : $id);
+ //去除后缀
+ $listTmp = substr($listTmp, 0, strpos($listTmp, '.'));
+ return $this->fetch('category/' . $listTmp);
+ }
+
+ /**
+ * 详情页
+ * @return string
+ * @throws Exception
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @author 李玉坤
+ * @date 2021-10-29 0:17
+ */
+ public function detail()
+ {
+ $id = input('id');
+ if (!$id) {
+ $this->error('参数错误!');
+ }
+ //获取该文章
+ $documentModel = new Document();
+ $article = $documentModel->where('status', 1)->where('id|alias', $id)->find();
+ if (!$article) {
+ $this->error('文章不存在或已删除!');
+ }
+ $article = $article->toArray();
+ //根据分类id找分类信息
+ $dc = get_document_category($article['category_id']);
+ if (!$dc) {
+ $this->error('栏目不存在或已删除!');
+ }
+ //获取该文章内容
+ //根据文章类型,加载不同的内容。
+ $articleType = $article['type'] ? $article['type'] : 'article';
+ $articleExt = $documentModel::name('document_' . $articleType)->where('id', $article['id'])->find();
+ if (!$articleExt) {
+ $this->error('文章不存在或已删除!');
+ }
+ $articleExt = $articleExt->toArray();
+ $article = array_merge($article, $articleExt);
+ //添加当前页面的位置信息
+ $article['position'] = tpl_get_position($dc);
+ //更新浏览次数
+ $documentModel->where('id', $article['id'])->inc('view')->update();
+ $templateFile = config('view.view_path') . 'article/' . $articleType . '.html';
+ if (!is_file($templateFile)) {
+ $this->error('模板文件不存在!');
+ }
+ $article['category_title'] = $dc['title'];
+ //判断SEO 为空则取系统
+ $article['keywords'] = $article['keywords'] ?: web_config('keywords');
+ $article['description'] = $article['description'] ?: web_config('description');
+ //输出文章内容
+ $this->assign('apeField', $article);
+ $this->assign('id', $id);
+ //当前页面所属分类id
+ $this->assign('cid', $article['category_id']);
+ //缓存当前页面栏目分类树ids
+ cache(Data::CURR_CATEGORY_PATENT_ID, $dc['pid'] ? $dc['pid'] . ',' . $article['category_id'] : $article['category_id']);
+ //设置文章的url
+ $article['link_str'] = make_detail_url($article);
+ //判断后台统计配置是否开启 1 开启
+ if (web_config("web_statistics") == 1) {
+ //统计url
+ $this->urlrecord($article['title']);
+ }
+ Log::info('详情页模板路径:' . $templateFile);
+ return $this->fetch('article/' . $articleType);
+ }
+
+ /**
+ * 创建评论
+ * @param Request $request
+ * @return mixed
+ * @author 李玉坤
+ * @date 2021-10-17 19:13
+ */
+ public function create_comment(Request $request)
+ {
+ $data = Util::postMore([
+ ['document_id', ''],
+ ['pid', ''],
+ ['author', ''],
+ ['url', ''],
+ ['email', ''],
+ ['content', ''],
+ ]);
+ if (!web_config('comment_close')){
+ $this->error('非法操作,请检查后重试', null);
+ }
+ if (web_config('comment_visitor')){
+ if ($data['author'] == "") $this->error("昵称不能为空");
+ if ($data['email'] == "") $this->error("邮箱不能为空");
+ if ($data['url'] == "") $this->error("url不能为空");
+ }else{
+ $data['author'] = $this->userInfo['nickname']?:$this->userInfo['username'];
+ $data['email'] = $this->userInfo['email']?:'';
+ $data['url'] = '';
+ }
+ if ($data['document_id'] == "") $this->error("文章id不能为空");
+ if ($data['content'] == "") $this->error("内容能为空");
+ $data['status'] = web_config('comment_review') ? 0 : 1;
+ $res = commentModel::create($data);
+ if ($res) {
+ cookie(Data::COOKIE_KEY_COMMENT_AUTHOR,$data['author'],Data::COOKIE_KEY_COMMENT_EXPIRE);
+ cookie(Data::COOKIE_KEY_COMMENT_AUTHOR_EMAIL,$data['email'],Data::COOKIE_KEY_COMMENT_EXPIRE);
+ cookie(Data::COOKIE_KEY_COMMENT_AUTHOR_URL,$data['url'],Data::COOKIE_KEY_COMMENT_EXPIRE);
+ $this->success('提交成功', url('detail', ['id' => $data['document_id']]));
+ } else {
+ $this->error('提交失败,请联系站长查看', null);
+ }
+ }
+
+ /**
+ * 文章标签页面
+ * @return string
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @author 李玉坤
+ * @date 2021-10-29 0:19
+ */
+ public function tag()
+ {
+ $tag = input('t');
+ if (!trim($tag)) {
+ $this->error('请输入标签');
+ }
+ if (!mb_check_encoding($tag, 'utf-8')) {
+ $tag = iconv('gbk', 'utf-8', $tag);
+ }
+ $apeField['id'] = '0';
+ $apeField['title'] = $tag;
+ $apeField['meta_title'] = $tag;
+ $apeField['keywords'] = web_config('keywords');
+ $apeField['description'] = web_config('description');
+ $apeField['position'] = '首页 > ' . $tag . '';
+ $this->assign('apeField', $apeField);
+ $this->assign('tag', $tag);
+
+ //清除可能存在的栏目分类树id
+ cache(Data::CURR_CATEGORY_PATENT_ID, false);
+ //模板兼容性标签
+ $this->assign('id', false);
+ $this->assign('cid', false);
+ $templateFile = config('view.view_path') . 'article/tag.html';
+ if (!is_file($templateFile)) {
+ $this->error('模板文件不存在!');
+ }
+ return $this->fetch();
+ }
+
+ /**
+ * 标签列表
+ * @return mixed
+ * @author 李玉坤
+ * @date 2021-11-11 0:27
+ */
+ public function tagList()
+ {
+ $where = Util::postMore([
+ ['name', ''],
+ ['document_id', ''],
+ ['start_time', ''],
+ ['end_time', ''],
+ ['page', 1],
+ ['limit', 10]
+ ]);
+ return app("json")->layui(TagModel::getList($where));
+ }
+
+ /**
+ * 搜索页面
+ * @return string
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @author 李玉坤
+ * @date 2021-10-29 0:18
+ */
+ public function search()
+ {
+ $kw = input('kw');
+ if (!trim($kw)) {
+ $this->error('请输入搜索关键词');
+ }
+ if (!mb_check_encoding($kw, 'utf-8')) {
+ $kw = iconv('gbk', 'utf-8', $kw);
+ }
+ $apeField['id'] = '0';
+ $apeField['title'] = '搜索';
+ $apeField['meta_title'] = '搜索';
+ $apeField['keywords'] = web_config('keywords');
+ $apeField['description'] = web_config('description');
+ $apeField['position'] = '首页 > 搜索';
+ $this->assign('apeField', $apeField);
+ $this->assign('kw', $kw);
+ //清除可能存在的栏目分类树id
+ cache(Data::CURR_CATEGORY_PATENT_ID, false);
+ //模板兼容性标签
+ $this->assign('id', false);
+ $this->assign('cid', false);
+ $templateFile = config('view.view_path') . 'article/search.html';
+ if (!is_file($templateFile)) {
+ $this->error('模板文件不存在!');
+ }
+ return $this->fetch();
+ }
+
+ /**
+ * 用户首页
+ * @return string
+ * @throws Exception
+ * @author 李玉坤
+ * @date 2022-01-24 1:23
+ */
+ public function user()
+ {
+ $author = input('author');
+ if (!trim($author)) {
+ $this->error('请输入搜索关键词');
+ }
+ if (!mb_check_encoding($author, 'utf-8')) {
+ $kw = iconv('gbk', 'utf-8', $author);
+ }
+ $apeField['id'] = '0';
+ $apeField['title'] = $author;
+ $apeField['meta_title'] = $author;
+ $apeField['keywords'] = web_config('keywords');
+ $apeField['description'] = web_config('description');
+ $apeField['position'] = '首页 > ' . $author . '';
+ $this->assign('apeField', $apeField);
+ $this->assign('author', $author);
+
+ //清除可能存在的栏目分类树id
+ cache(Data::CURR_CATEGORY_PATENT_ID, false);
+ //模板兼容性标签
+ $this->assign('id', false);
+ $this->assign('cid', false);
+ $templateFile = config('view.view_path') . 'article/user.html';
+ if (!is_file($templateFile)) {
+ $this->error('模板文件不存在!');
+ }
+ return $this->fetch();
+ }
+}
\ No newline at end of file
diff --git a/config/filesystem.php b/config/filesystem.php
index a9d9a36..965297e 100644
--- a/config/filesystem.php
+++ b/config/filesystem.php
@@ -7,11 +7,7 @@ return [
'disks' => [
'local' => [
'type' => 'local',
- 'root' => app()->getRootPath() . 'public/upload',
- // 磁盘路径对应的外部URL路径
- 'url' => '/upload',
- // 可见性
- 'visibility' => 'public',
+ 'root' => app()->getRuntimePath() . 'storage',
],
'public' => [
// 磁盘类型
diff --git a/public/template/default/pc/index/about.html b/public/template/default/pc/index/about.html
new file mode 100644
index 0000000..37e1df5
--- /dev/null
+++ b/public/template/default/pc/index/about.html
@@ -0,0 +1,327 @@
+
+
+
+ {$apeField['title']} - {:web_config('title')}
+
+
+ {include file="public/head" /}
+
+
+
+
+
+
+
+
+
+
+
+ {include file="public/header" /}
+
+
+
+
+
+
+
+ {$apeField['position']|raw}
+
+
+
+
{$apeField['title']}
+
+
+
{$apeField['author']}
+
+
•
+
+
•
+
{$apeField['category_title']}
+
•
+
{$apeField['view']} 阅读
+
+
+
+
+
+
+
+ {$apeField['content']|raw}
+
+
+
+
版权声明:
+
作者:{$apeField['author']}
+
链接:
+
+
+ {$Request.domain . $Request.url}
+
+
+
来源:{:web_config('title')}
+
文章版权归作者所有,未经允许请勿转载。
+
+
THE END
+
+
+
+ {:file_echo_svg('__IMG__/share-btn.svg')}分享
+
+ {:file_echo_svg('__IMG__/svg-ewm.svg')}二维码
+
+ {:file_echo_svg('__IMG__/reward.svg')}打赏
+
+
+
+ {notempty name="(web_config('web_weixin_pay'))"}
)})
{/notempty}
+ {notempty name="(web_config('web_zhifubao_pay'))"}
)})
{/notempty}
+
+
+
+
+
+ {ape:prenext get="pre" cid="$apeField['category_id']"}
+
+
+ {/ape:prenext}
+
+
+
+ {ape:prenext get="next" cid="$apeField['category_id']"}
+
+ {/ape:prenext}
+
+
+
+
+
+
+
+
+
相关内容
+
+
+ {ape:relevant row="5" id="$apeField['id']"}
+ - {$field['title']}
+ {/ape:relevant}
+
+
+
+ {if web_config('comment_close') ==1}
+
+ {/if}
+
+
+
+
+ {include file="public/footer"/}
+
+
+
+
+
+
+
+
+
diff --git a/public/template/default/pc/page/article.html b/public/template/default/pc/page/article.html
new file mode 100644
index 0000000..37e1df5
--- /dev/null
+++ b/public/template/default/pc/page/article.html
@@ -0,0 +1,327 @@
+
+
+
+ {$apeField['title']} - {:web_config('title')}
+
+
+ {include file="public/head" /}
+
+
+
+
+
+
+
+
+
+
+
+ {include file="public/header" /}
+
+
+
+
+
+
+
+ {$apeField['position']|raw}
+
+
+
+
{$apeField['title']}
+
+
+
{$apeField['author']}
+
+
•
+
+
•
+
{$apeField['category_title']}
+
•
+
{$apeField['view']} 阅读
+
+
+
+
+
+
+
+ {$apeField['content']|raw}
+
+
+
+
版权声明:
+
作者:{$apeField['author']}
+
链接:
+
+
+ {$Request.domain . $Request.url}
+
+
+
来源:{:web_config('title')}
+
文章版权归作者所有,未经允许请勿转载。
+
+
THE END
+
+
+
+ {:file_echo_svg('__IMG__/share-btn.svg')}分享
+
+ {:file_echo_svg('__IMG__/svg-ewm.svg')}二维码
+
+ {:file_echo_svg('__IMG__/reward.svg')}打赏
+
+
+
+ {notempty name="(web_config('web_weixin_pay'))"}
)})
{/notempty}
+ {notempty name="(web_config('web_zhifubao_pay'))"}
)})
{/notempty}
+
+
+
+
+
+ {ape:prenext get="pre" cid="$apeField['category_id']"}
+
+
+ {/ape:prenext}
+
+
+
+ {ape:prenext get="next" cid="$apeField['category_id']"}
+
+ {/ape:prenext}
+
+
+
+
+
+
+
+
+
相关内容
+
+
+ {ape:relevant row="5" id="$apeField['id']"}
+ - {$field['title']}
+ {/ape:relevant}
+
+
+
+ {if web_config('comment_close') ==1}
+
+ {/if}
+
+
+
+
+ {include file="public/footer"/}
+
+
+
+
+
+
+
+
+
diff --git a/public/template/default/pc/public/footer.html b/public/template/default/pc/public/footer.html
index da78ffb..72da8cf 100644
--- a/public/template/default/pc/public/footer.html
+++ b/public/template/default/pc/public/footer.html
@@ -25,7 +25,7 @@
{$field['author']}
+{:comment_face($field['content'],'__IMG__/face/')}
++-
+
+
+
+
+
+
+
+
+
+
+
+ {$vo.create_time}
+
+
+
+
+
+
+
+ {/ape:comment} +{$vo['author']}@{$field['author']}
+{:comment_face($vo['content'],'__IMG__/face/')}
+