From 0b2bc05cd7bcd92a2be7c1f9edd6584d304cd62b Mon Sep 17 00:00:00 2001 From: augushong Date: Sun, 4 May 2025 18:23:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=80=E5=A7=8B=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Post.php | 51 ++++++++++++++++-------------- view/admin/common/left_system.html | 3 ++ view/admin/post/output.html | 20 +++++++++++- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/app/admin/controller/Post.php b/app/admin/controller/Post.php index bb1cb16..e7256f2 100644 --- a/app/admin/controller/Post.php +++ b/app/admin/controller/Post.php @@ -4,22 +4,19 @@ declare(strict_types=1); namespace app\admin\controller; -use app\common\tools\PostBlock; -use app\model\Category; +use app\model\Nav; use app\model\Post as ModelPost; use app\model\PostCategory; use app\model\PostTag; -use app\model\Tag; use League\HTMLToMarkdown\HtmlConverter; use think\facade\Cache; -use think\facade\Route; use think\facade\View; use think\Request; class Post extends Common { /** - * 显示资源列表 + * 显示资源列表. * * @return \think\Response */ @@ -33,12 +30,12 @@ class Post extends Common $category_id = $this->request->param('category_id', 0); - if(!empty($category_id)){ + if (!empty($category_id)) { $model_list = $model_list->where('category_id', $category_id); } $list = $model_list->paginate([ - 'query' => $this->request->get() + 'query' => $this->request->get(), ]); View::assign('list', $list); @@ -59,9 +56,9 @@ class Post extends Common } /** - * 保存新建的资源 + * 保存新建的资源. * - * @param \think\Request $request + * @param Request $request * @return \think\Response */ public function save(Request $request) @@ -87,19 +84,19 @@ class Post extends Common foreach ($categorys as $category) { PostCategory::create([ 'post_id' => $model_post->id, - 'category_id' => $category + 'category_id' => $category, ]); } foreach ($tags as $tag) { PostTag::create([ 'post_id' => $model_post->id, - 'tag_id' => $tag + 'tag_id' => $tag, ]); } return $this->success('添加成功', url('index', [ 'type' => $this->request->param('type'), - 'category_id'=>$this->request->param('category_id'), + 'category_id' => $this->request->param('category_id'), ])); } @@ -115,7 +112,7 @@ class Post extends Common } /** - * 显示指定的资源 + * 显示指定的资源. * * @param int $id * @return \think\Response @@ -137,7 +134,6 @@ class Post extends Common $model_post = ModelPost::find($id); - View::assign('post', $model_post); return View::fetch(); @@ -147,23 +143,32 @@ class Post extends Common { $model_post = ModelPost::find($id); - View::assign('post', $model_post); + return View::fetch(); } public function output($id) { $model_post = ModelPost::find($id); + $list_post_platform = Nav::where('type', 12)->order('sort asc')->select(); + + foreach ($list_post_platform as $model_platform) { + $platform_info = explode("\n",$model_platform->desc); + $model_platform->home_url = $platform_info[0]?? ''; + $model_platform->account = $platform_info[1] ?? ''; + } View::assign('post', $model_post); + View::assign('list_post_platform', $list_post_platform); + return View::fetch(); } /** - * 保存更新的资源 + * 保存更新的资源. * - * @param \think\Request $request + * @param Request $request * @param int $id * @return \think\Response */ @@ -181,7 +186,7 @@ class Post extends Common unset($post_data['categorys']); $old_category_list = PostCategory::where('post_id', $id)->select(); - $old_category_id_list = array_column((array)$old_category_list, 'id'); + $old_category_id_list = array_column((array) $old_category_list, 'id'); // 旧的有新的没有 foreach ($old_category_list as $model_category) { @@ -193,10 +198,9 @@ class Post extends Common // 旧的没有新的有 foreach ($categorys as $category) { if (!in_array($category, $old_category_id_list)) { - PostCategory::create([ 'post_id' => $model_post->id, - 'category_id' => $category + 'category_id' => $category, ]); } } @@ -206,7 +210,7 @@ class Post extends Common unset($post_data['tags']); $old_tag_list = PostTag::where('post_id', $id)->select(); - $old_tag_id_list = array_column((array)$old_tag_list, 'id'); + $old_tag_id_list = array_column((array) $old_tag_list, 'id'); foreach ($old_tag_list as $model_tag) { if (!in_array($model_tag->id, $tags)) { @@ -216,10 +220,9 @@ class Post extends Common foreach ($tags as $tag) { if (!in_array($tag, $old_tag_id_list)) { - PostTag::create([ 'post_id' => $model_post->id, - 'tag_id' => $tag + 'tag_id' => $tag, ]); } } @@ -233,7 +236,7 @@ class Post extends Common } /** - * 删除指定资源 + * 删除指定资源. * * @param int $id * @return \think\Response diff --git a/view/admin/common/left_system.html b/view/admin/common/left_system.html index 14ff5ed..0903d58 100644 --- a/view/admin/common/left_system.html +++ b/view/admin/common/left_system.html @@ -8,6 +8,9 @@
  • 第三方管理
  • +
  • + 三方同步平台 +
  • 用户协议管理 diff --git a/view/admin/post/output.html b/view/admin/post/output.html index 31f21f3..85f2126 100644 --- a/view/admin/post/output.html +++ b/view/admin/post/output.html @@ -30,7 +30,7 @@ .options-box { position: fixed; right: 0; - top: 20%; + top: 0; margin: 15px; padding: 15px; border-radius: 5; @@ -102,6 +102,24 @@
    选中markdown +
    + +
    + {volist name='list_post_platform' id='vo'} +
    +
    + + {$vo.title} + +
    +
    + +
    +
    +
    + + {/volist} +