From bc5022b2d69e1a5a1276a36e9c322432b895b73b Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Wed, 16 Apr 2025 13:39:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=99=84=E4=BB=B6/=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Attachment.php | 4 ++++ app/index/lang/en-us.php | 9 +++++---- app/index/lang/zh-cn.php | 9 +++++---- app/index/model/AttachmentModel.php | 9 +++++++++ app/index/model/VideoModel.php | 9 +++++++++ app/index/view/attachment/index.html | 17 ++++++++++------- app/index/view/attachment/video.html | 16 +++++++++------- public/static/index/css/download.css | 5 +++++ public/static/index/images/search_blue.png | Bin 0 -> 571 bytes 9 files changed, 56 insertions(+), 22 deletions(-) create mode 100755 public/static/index/images/search_blue.png diff --git a/app/index/controller/Attachment.php b/app/index/controller/Attachment.php index 468bb3c8..ae49b874 100644 --- a/app/index/controller/Attachment.php +++ b/app/index/controller/Attachment.php @@ -21,6 +21,7 @@ class Attachment extends Common { $param = request()->param([ 'id', + 'keyword', 'page/d' => 1, 'size/d' => 12, ]); @@ -47,6 +48,7 @@ class Attachment extends Common 'support_platform', 'attach', ]) + ->withSearch(['name'], ['name' => $param['keyword']??null]) ->language($this->lang_id) ->category($param['id']??null) ->order(['sort' => 'asc', 'id' => 'desc']) @@ -70,6 +72,7 @@ class Attachment extends Common { $param = request()->param([ 'id', + 'keyword', 'page/d' => 1, 'size/d' => 12 ]); @@ -106,6 +109,7 @@ class Attachment extends Common 'video', 'link' ]) + ->withSearch(['name'], ['name' => $param['keyword']??null]) ->language($this->lang_id) ->category($param['id']??null) ->order(['sort' => 'asc', 'id' => 'desc']) diff --git a/app/index/lang/en-us.php b/app/index/lang/en-us.php index ad0a50b9..0c90a2f7 100644 --- a/app/index/lang/en-us.php +++ b/app/index/lang/en-us.php @@ -33,9 +33,10 @@ return [ 'detail_recommend' => 'Recommended for you', ], 'attachment' => [ - 'software_drives' => 'Software and Drivers', - 'video' => 'Videos', - 'support_model' => 'Supported Models', - 'support_platform' => 'Supported Systems', + 'software_drives' => 'Software and Drivers', + 'video' => 'Videos', + 'support_model' => 'Supported Models', + 'support_platform' => 'Supported Systems', + 'search_placeholder' => 'Search model', ] ]; \ No newline at end of file diff --git a/app/index/lang/zh-cn.php b/app/index/lang/zh-cn.php index 1aeb67eb..10f84691 100644 --- a/app/index/lang/zh-cn.php +++ b/app/index/lang/zh-cn.php @@ -33,9 +33,10 @@ return [ 'detail_recommend' => '你可能还喜欢', ], 'attachment' => [ - 'software_drives' => '软件和驱动程序', - 'video' => '视频', - 'support_model' => '支持型号', - 'support_platform' => '支持系统', + 'software_drives' => '软件和驱动程序', + 'video' => '视频', + 'support_model' => '支持型号', + 'support_platform' => '支持系统', + 'search_placeholder' => '搜索型号', ] ]; \ No newline at end of file diff --git a/app/index/model/AttachmentModel.php b/app/index/model/AttachmentModel.php index d358f4ed..590d2a8f 100644 --- a/app/index/model/AttachmentModel.php +++ b/app/index/model/AttachmentModel.php @@ -22,6 +22,15 @@ class AttachmentModel extends AttachmentBaseModel // 设置JSON数据返回数组 protected $jsonAssoc = true; + // 附件名称搜索器 + public function searchNameAttr($query, $value, $data) + { + if (is_null($value)) { + return; + } + $query->where('name', 'like', "%{$value}%"); + } + // 所属语言范围查询 public function scopeLanguage($query, $language) { diff --git a/app/index/model/VideoModel.php b/app/index/model/VideoModel.php index 3ebbb1a1..3708ac91 100644 --- a/app/index/model/VideoModel.php +++ b/app/index/model/VideoModel.php @@ -18,6 +18,15 @@ class VideoModel extends VideoBaseModel // 软删除字段 protected $deleteTime = 'deleted_at'; + // 视频名称搜索器 + public function searchNameAttr($query, $value, $data) + { + if (is_null($value)) { + return; + } + $query->where('name', 'like', "%{$value}%"); + } + // 所属语言范围查询 public function scopeLanguage($query, $language) { diff --git a/app/index/view/attachment/index.html b/app/index/view/attachment/index.html index 03821bf2..fda7c37a 100644 --- a/app/index/view/attachment/index.html +++ b/app/index/view/attachment/index.html @@ -12,12 +12,13 @@
+
+