From d5da3a6ea8f6a928c08d3592f553108677f65d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E6=B3=BD=E7=BD=91?= <”357099073@qq.com“> Date: Fri, 9 May 2025 23:53:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=BA=94=E7=94=A8=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E6=A8=A1=E5=9D=97=E5=B9=B6=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Article.php | 112 ++--- app/admin/view/article/add.php | 72 +++- app/admin/view/article/articlelist.php | 9 +- app/admin/view/article/edit.php | 285 +++++++++++++ app/index/controller/Index.php | 58 +++ app/index/view/component/main.php | 86 ++-- public/nginx.htaccess | 8 +- public/static/css/style.css | 11 +- .../024e24cd8b2cd80e0c6935a125a7736d.png | Bin 0 -> 32297 bytes .../0bea9ba73b62b6c109ec2d62e9a3882c.jpg | Bin 0 -> 534907 bytes .../334563a77ed77e9e636d74cad9892972.png | Bin 0 -> 117273 bytes .../33eb59c60f31ced639faee0db08ac964.png | Bin 0 -> 32297 bytes .../4efe94d5b4f4e5787b2d159235114c71.png | Bin 0 -> 117273 bytes .../54f52cc657c7dd5f3455452253be7fe1.png | Bin 0 -> 117273 bytes .../5af8142195f9534f179c70d3ec451646.png | Bin 0 -> 92032 bytes .../611fe51ca1cbe75c6d77e1dc9ac4e5c3.png | Bin 0 -> 68703 bytes .../66910fc5193487fe1611328fe2a8316f.png | Bin 0 -> 117273 bytes .../6ba093debba35838b68effb20283a6b8.png | Bin 0 -> 90337 bytes .../784e08e6843a647600752fdd5d8cdc66.png | Bin 0 -> 90337 bytes .../7b3382a65865e29a3627037204d6c568.png | Bin 0 -> 90337 bytes .../858d1635fa6a3f1fb393bea8a09a8c5b.png | Bin 0 -> 32297 bytes .../89b3cfd2e2a8f017b7f38c8fc68a7a91.png | Bin 0 -> 68703 bytes .../961374e540c20ddb0e5348f3c4644a2f.png | Bin 0 -> 90337 bytes .../9b04857df9a55582124d98c2d24c4c41.png | Bin 0 -> 68703 bytes .../b3c2cb74e5ac0c8f0e50a4deb66387e8.png | Bin 0 -> 62794 bytes .../b890181a9083f028e1fc9ce14da06d61.png | Bin 0 -> 68703 bytes .../baf3cb4940adc99242e2110f3d3e7e93.png | Bin 0 -> 32297 bytes .../bd3888d4a964b80e7001f59f8c959f73.png | Bin 0 -> 92032 bytes .../d3a963542e2ae93c900ffcbde3a8284b.png | Bin 0 -> 62794 bytes .../fb77becd27f8a28a01aa2c4ad95c2f00.png | Bin 0 -> 32297 bytes .../temp/02890b205219b043551566c44acd91e7.php | 130 ++++++ .../temp/33fe660e71fd18dda768b12bc1ec5aac.php | 379 +++++++++++++++++ .../temp/533c54f343e8a61c5a95c12da17f30ac.php | 171 ++++++++ .../temp/705995d2a8e3fb66a54834e54543f090.php | 189 +++++++++ .../temp/766d6e3eeeea6e24fe0ab12371e8dfbf.php | 184 ++++++++ .../temp/792969fb591a0f355761a1b3bf3d1226.php | 272 ++++++++++++ .../temp/a7bfd508279dfa35c2e6ff0e3f27da40.php | 229 ++++++++++ .../temp/c5f36a7772c20379b8b97ddafceff134.php | 184 ++++++++ .../temp/d80737d8d32a9fbe1181b34e1ecda47e.php | 343 +++++++++++++++ .../temp/69170ce622adbb0032543cdbee52d3fd.php | 397 ++++++++++++++++++ 40 files changed, 2990 insertions(+), 129 deletions(-) create mode 100644 app/admin/view/article/edit.php create mode 100644 public/storage/uploads/20250509/024e24cd8b2cd80e0c6935a125a7736d.png create mode 100644 public/storage/uploads/20250509/0bea9ba73b62b6c109ec2d62e9a3882c.jpg create mode 100644 public/storage/uploads/20250509/334563a77ed77e9e636d74cad9892972.png create mode 100644 public/storage/uploads/20250509/33eb59c60f31ced639faee0db08ac964.png create mode 100644 public/storage/uploads/20250509/4efe94d5b4f4e5787b2d159235114c71.png create mode 100644 public/storage/uploads/20250509/54f52cc657c7dd5f3455452253be7fe1.png create mode 100644 public/storage/uploads/20250509/5af8142195f9534f179c70d3ec451646.png create mode 100644 public/storage/uploads/20250509/611fe51ca1cbe75c6d77e1dc9ac4e5c3.png create mode 100644 public/storage/uploads/20250509/66910fc5193487fe1611328fe2a8316f.png create mode 100644 public/storage/uploads/20250509/6ba093debba35838b68effb20283a6b8.png create mode 100644 public/storage/uploads/20250509/784e08e6843a647600752fdd5d8cdc66.png create mode 100644 public/storage/uploads/20250509/7b3382a65865e29a3627037204d6c568.png create mode 100644 public/storage/uploads/20250509/858d1635fa6a3f1fb393bea8a09a8c5b.png create mode 100644 public/storage/uploads/20250509/89b3cfd2e2a8f017b7f38c8fc68a7a91.png create mode 100644 public/storage/uploads/20250509/961374e540c20ddb0e5348f3c4644a2f.png create mode 100644 public/storage/uploads/20250509/9b04857df9a55582124d98c2d24c4c41.png create mode 100644 public/storage/uploads/20250509/b3c2cb74e5ac0c8f0e50a4deb66387e8.png create mode 100644 public/storage/uploads/20250509/b890181a9083f028e1fc9ce14da06d61.png create mode 100644 public/storage/uploads/20250509/baf3cb4940adc99242e2110f3d3e7e93.png create mode 100644 public/storage/uploads/20250509/bd3888d4a964b80e7001f59f8c959f73.png create mode 100644 public/storage/uploads/20250509/d3a963542e2ae93c900ffcbde3a8284b.png create mode 100644 public/storage/uploads/20250509/fb77becd27f8a28a01aa2c4ad95c2f00.png create mode 100644 runtime/admin/temp/02890b205219b043551566c44acd91e7.php create mode 100644 runtime/admin/temp/33fe660e71fd18dda768b12bc1ec5aac.php create mode 100644 runtime/admin/temp/533c54f343e8a61c5a95c12da17f30ac.php create mode 100644 runtime/admin/temp/705995d2a8e3fb66a54834e54543f090.php create mode 100644 runtime/admin/temp/766d6e3eeeea6e24fe0ab12371e8dfbf.php create mode 100644 runtime/admin/temp/792969fb591a0f355761a1b3bf3d1226.php create mode 100644 runtime/admin/temp/a7bfd508279dfa35c2e6ff0e3f27da40.php create mode 100644 runtime/admin/temp/c5f36a7772c20379b8b97ddafceff134.php create mode 100644 runtime/admin/temp/d80737d8d32a9fbe1181b34e1ecda47e.php create mode 100644 runtime/index/temp/69170ce622adbb0032543cdbee52d3fd.php diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php index c3dbe14..d907c53 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/Article.php @@ -13,31 +13,21 @@ class Article extends Base // 文章列表 public function articlelist() { - if (Request::isPost()) { - $lists = Db::table('yz_article') - ->where('delete_time', null) - ->where('status', '<>', 3) - ->order('id DESC') - ->select() - ->each(function ($item) { - $item['create_time'] = date('Y-m-d H:i:s', strtotime($item['create_time'])); - $item['publishdate'] = $item['publishdate'] ? date('Y-m-d H:i:s', strtotime($item['publishdate'])) : ''; - return $item; - }); - return json(['code' => 0, 'msg' => '获取成功', 'data' => $lists]); - } else { - $lists = Db::table('yz_article') - ->where('delete_time', null) - ->where('status', '<>', 3) - ->order('id DESC') - ->select() - ->each(function ($item) { - $item['create_time'] = date('Y-m-d H:i:s', strtotime($item['create_time'])); - return $item; - }); - View::assign(['lists' => $lists]); - return View::fetch(); - } + $lists = Db::table('yz_article') + ->where('delete_time', null) + ->where('status', '<>', 3) + ->order('id DESC') + ->select() + ->each(function ($item) { + $item['cate'] = Db::table('yz_article_category')->where('id', $item['cate'])->value('name'); + $item['create_time'] = date('Y-m-d H:i:s', $item['create_time']); + $item['publishdate'] = $item['publishdate'] ? date('Y-m-d H:i:s', $item['publishdate']) : ''; + return $item; + }); + View::assign([ + 'lists' => $lists + ]); + return View::fetch(); } // 添加文章 @@ -52,8 +42,8 @@ class Article extends Base 'author' => input('post.author'), 'desc' => input('post.desc'), 'status' => input('post.status', 2), - 'publishdate' => date('Y-m-d H:i:s', time()), - 'create_time' => date('Y-m-d H:i:s', time()) + 'publishdate' => time(), + 'create_time' => time() ]; $insert = Db::table('yz_article')->insert($data); @@ -66,7 +56,7 @@ class Article extends Base ->order('id DESC') ->select() ->each(function ($item, $key) { - $item['create_time'] = date('Y-m-d H:i:s', $item['create_time']); + $item['create_time'] = time(); return $item; }); View::assign([ @@ -80,28 +70,46 @@ class Article extends Base public function edit() { if (Request::isPost()) { - $article_id = input('post.article_id'); + $id = input('get.id'); $data = [ 'title' => input('post.title'), + 'cate' => input('post.cate'), + 'image' => input('post.image'), 'content' => input('post.content'), 'author' => input('post.author'), - 'status' => input('post.status', 1), + 'desc' => input('post.desc'), + 'status' => input('post.status', 2), 'update_time' => time() ]; - $update = Db::table('yz_article') - ->where('article_id', $article_id) - ->update($data); - - if ($update === false) { - return json(['code' => 1, 'msg' => '更新失败', 'data' => []]); - } - return json(['code' => 0, 'msg' => '更新成功', 'data' => []]); + $update = Db::table('yz_article')->where('id', $id)->update($data); + return json(['code' => $update === false ? 1 : 0, 'msg' => $update === false ? '更新失败' : '更新成功', 'data' => []]); } else { - $article_id = input('get.article_id'); - $info = Db::table('yz_article')->where('article_id', $article_id)->find(); + $id = input('get.id'); + $info = Db::table('yz_article')->where('id', $id)->find(); + if ($info === null) { + return json(['code' => 1, 'msg' => '文章不存在', 'data' => []]); + } + + $cates = Db::table('yz_article_category') + ->where('delete_time', null) + ->where('status', 1) + ->order('sort asc, id asc') + ->select() + ->toArray(); + + $info['content'] = !empty($info['content']) ? htmlspecialchars_decode(str_replace(["\r\n", "\r", "\n"], '', addslashes($info['content']))) : ''; + + $currentCate = Db::table('yz_article_category') + ->where('id', $info['cate']) + ->where('delete_time', null) + ->where('status', 1) + ->find(); + $info['cate_name'] = $currentCate ? $currentCate['name'] : ''; + View::assign([ - 'info' => $info + 'info' => $info, + 'cates' => $cates ]); return View::fetch(); } @@ -112,7 +120,7 @@ class Article extends Base { $id = input('post.id'); $data = [ - 'delete_time' => date('Y-m-d H:i:s', time()), + 'delete_time' => time(), ]; $delete = Db::table('yz_article')->where('id', $id)->update($data); if ($delete === false) { @@ -136,7 +144,11 @@ class Article extends Base ->where('status', 1) ->order('id asc') ->page($page, $limit) - ->select(); + ->select() + ->each(function ($item) { + $item['create_time'] = date('Y-m-d H:i:s', $item['create_time']); + return $item; + }); return json(['code' => 0, 'msg' => '获取成功', 'data' => $lists]); } else { // 获取分类列表 @@ -144,7 +156,11 @@ class Article extends Base ->where('delete_time', null) ->where('status', 1) ->order('id asc') - ->select(); + ->select() + ->each(function ($item) { + $item['create_time'] = date('Y-m-d H:i:s', $item['create_time']); + return $item; + }); View::assign([ 'lists' => $lists @@ -192,7 +208,7 @@ class Article extends Base { if (Request::isPost()) { // 将时间戳转换为 'Y-m-d H:i:s' 格式 - $currentDateTime = date('Y-m-d H:i:s'); + $currentDateTime = time(); $data = [ 'name' => input('post.name'), 'cid' => input('post.cid'), @@ -211,7 +227,7 @@ class Article extends Base ->order('id DESC') ->select() ->each(function ($item, $key) { - $item['create_time'] = date('Y-m-d H:i:s', strtotime($item['create_time'])); + $item['create_time'] = time(); return $item; }); View::assign([ @@ -231,7 +247,7 @@ class Article extends Base 'cid' => input('post.cid'), 'sort' => input('post.sort', 0), 'status' => input('post.status', 1), - 'update_time' => date('Y-m-d H:i:s') + 'update_time' => time() ]; $update = Db::table('yz_article_category') @@ -269,7 +285,7 @@ class Article extends Base $delete = Db::table('yz_article_category') ->where('id', $id) - ->update(['delete_time' => date('Y-m-d H:i:s')]); + ->update(['delete_time' => time()]); if ($delete === false) { return json(['code' => 1, 'msg' => '删除失败', 'data' => []]); diff --git a/app/admin/view/article/add.php b/app/admin/view/article/add.php index 2f519b6..26d7da8 100644 --- a/app/admin/view/article/add.php +++ b/app/admin/view/article/add.php @@ -68,7 +68,7 @@