From a09047aadbaa7627583cbf970568b8153e4ae519 Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Tue, 15 Apr 2025 17:20:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Attachment.php | 62 +++++++- app/index/lang/en-us.php | 8 +- app/index/lang/zh-cn.php | 8 +- app/index/model/AttachmentCategoryModel.php | 12 ++ app/index/model/AttachmentModel.php | 20 +++ app/index/model/VideoCategoryModel.php | 14 ++ app/index/model/VideoModel.php | 14 ++ app/index/route/route.php | 3 + app/index/view/attachment/index.html | 164 ++++---------------- app/index/view/attachment/video.html | 90 +++++++++++ public/static/index/css/download.css | 38 +---- 11 files changed, 260 insertions(+), 173 deletions(-) create mode 100644 app/index/model/VideoCategoryModel.php create mode 100644 app/index/model/VideoModel.php create mode 100644 app/index/view/attachment/video.html diff --git a/app/index/controller/Attachment.php b/app/index/controller/Attachment.php index 75177e60..bb339974 100644 --- a/app/index/controller/Attachment.php +++ b/app/index/controller/Attachment.php @@ -4,6 +4,7 @@ declare (strict_types = 1); namespace app\index\controller; use app\index\model\AttachmentCategoryModel; +use app\index\model\AttachmentModel; use think\facade\View; /** @@ -11,13 +12,66 @@ use think\facade\View; */ class Attachment extends Common { - // 分页列表 + /** + * 分页列表 + */ public function index() { - // 获取分类 - $category = AttachmentCategoryModel::language($this->lang_id)->select(); - View::assign('category', $category); + $param = request()->param([ + 'id', + 'page/d' => 1, + 'size/d' => 12, + ]); + + // 获取附件分类 + $categorys = AttachmentCategoryModel::field([ + 'id', + 'name' + ]) + ->language($this->lang_id) + ->parent(0) + ->isShow(true) + ->select(); + View::assign('categorys', $categorys); + + // 获取附件 + $attachements = AttachmentModel::field([ + 'id', + 'name', + 'desc', + 'image', + 'applicable_to', + 'support_platform', + 'attach', + ]) + ->language($this->lang_id) + ->category($param['id']??null) + ->paginate([ + 'list_rows' => $param['size'], + 'page' => $param['page'], + ]); + View::assign('attachements', $attachements); + View::assign('page', $attachements->render()); return View::fetch('index'); } + + /** + * 视频 + */ + public function video() + { + // 获取附件分类 + $categorys = AttachmentCategoryModel::field([ + 'id', + 'name' + ]) + ->language($this->lang_id) + ->parent(0) + ->isShow(true) + ->select(); + View::assign('categorys', $categorys); + + return View::fetch('video'); + } } diff --git a/app/index/lang/en-us.php b/app/index/lang/en-us.php index 0905df64..ad0a50b9 100644 --- a/app/index/lang/en-us.php +++ b/app/index/lang/en-us.php @@ -33,9 +33,9 @@ return [ 'detail_recommend' => 'Recommended for you', ], 'attachment' => [ - 'software_drives' => 'Software and Drivers', - 'software_download' => 'Software Drives', - 'manual_download' => 'Manual', - 'video' => 'Videos' + 'software_drives' => 'Software and Drivers', + 'video' => 'Videos', + 'support_model' => 'Supported Models', + 'support_platform' => 'Supported Systems', ] ]; \ No newline at end of file diff --git a/app/index/lang/zh-cn.php b/app/index/lang/zh-cn.php index e2d042a2..1aeb67eb 100644 --- a/app/index/lang/zh-cn.php +++ b/app/index/lang/zh-cn.php @@ -33,9 +33,9 @@ return [ 'detail_recommend' => '你可能还喜欢', ], 'attachment' => [ - 'software_drives' => '软件和驱动程序', - 'software_download' => '软件下载', - 'manual_download' => '手册', - 'video' => '视频' + 'software_drives' => '软件和驱动程序', + 'video' => '视频', + 'support_model' => '支持型号', + 'support_platform' => '支持系统', ] ]; \ No newline at end of file diff --git a/app/index/model/AttachmentCategoryModel.php b/app/index/model/AttachmentCategoryModel.php index 0173240d..9d52717d 100644 --- a/app/index/model/AttachmentCategoryModel.php +++ b/app/index/model/AttachmentCategoryModel.php @@ -22,4 +22,16 @@ class AttachmentCategoryModel extends AttachmentCategoryBaseModel { return $query->where('language_id', '=', $language); } + + // 上级id范围查询 + public function scopeParent($query, $pid) + { + return $query->where('pid', '=', $pid); + } + + // 是否显示状态范围查询 + public function scopeIsShow($query, bool $is_show) + { + return $query->where('is_show', '=', (int)$is_show); + } } diff --git a/app/index/model/AttachmentModel.php b/app/index/model/AttachmentModel.php index 7f774e49..d358f4ed 100644 --- a/app/index/model/AttachmentModel.php +++ b/app/index/model/AttachmentModel.php @@ -16,4 +16,24 @@ class AttachmentModel extends AttachmentBaseModel use SoftDelete; // 软删除时间字段名 protected $deleteTime = 'deleted_at'; + + // 设置JSON字段 + protected $json = ['attach']; + // 设置JSON数据返回数组 + protected $jsonAssoc = true; + + // 所属语言范围查询 + public function scopeLanguage($query, $language) + { + $query->where('language_id', '=', $language); + } + + // 所属分类范围查询 + public function scopeCategory($query, $category) + { + if (is_null($category)) { + return; + } + $query->where('category_id', '=', $category); + } } diff --git a/app/index/model/VideoCategoryModel.php b/app/index/model/VideoCategoryModel.php new file mode 100644 index 00000000..78a4b038 --- /dev/null +++ b/app/index/model/VideoCategoryModel.php @@ -0,0 +1,14 @@ +

Driver for USB-C 10Gb Ethernet Adapter
-Supported Models:
-ORICO-REA-10
-Supported Systems:
-Windows 10-11, Linux
+{$att.name}
+{:lang('attachment.support_model')}:
+{$att.applicable_to}
+{:lang('attachment.support_platform')}:
+{$att.support_platform}
- - + {notempty name="att.attach"} + {volist name="att.attach" id="ch"} + + + + {/volist} + {/notempty}


+
+
+