From e8d1f455ab72125eac0a5e707b705bf435a20a14 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Fri, 28 Mar 2025 16:11:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E5=AF=BC=E5=87=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/v1/Article.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/admin/controller/v1/Article.php b/app/admin/controller/v1/Article.php index 94ad0431..30bf2d1f 100644 --- a/app/admin/controller/v1/Article.php +++ b/app/admin/controller/v1/Article.php @@ -187,13 +187,13 @@ class Article { $schema = [ 'id' => 'ID', - 'category_name' => '分类名称', - 'title' => '标题', + 'category_name' => '文章分类', + 'title' => '文章名称', 'author' => '作者', 'source' => '来源', 'image' => '封面图片', - 'link' => '外链', - 'desc' => '描述', + 'link' => '跳转链接', + 'desc' => '文章描述', 'content' => '内容详情', 'recommend' => '是否推荐', 'sort' => '排序值', @@ -223,7 +223,7 @@ class Article $param = request()->param(['title', 'category_id', 'created_at']); $data = ArticleModel::field([ '*', - 'CONCAT("' . $image_host . '", `image`)' => 'image', + 'image', 'CASE WHEN recommend = 1 THEN "是" ELSE "否" END' => 'recommend', 'CASE WHEN enabled = 1 THEN "是" ELSE "否" END' => 'enabled', ]) @@ -243,7 +243,11 @@ class Article 'category_id', 'category', ]) - ->bindAttr('category', ['category_name' => 'name']); + ->bindAttr('category', ['category_name' => 'name']) + ->each(function ($item) use($image_host) { + $item->image = !empty($item->image) ? $image_host . $item->image : ''; + return $item; + }); return $data->toArray(); }