From 4700442a08bb168da35445cfdb9c685072488b62 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 @@ +
-
{:lang('attachment.software_download')}
-
{:lang('attachment.manual_download')}
-
{:lang('attachment.video')}
+ {notempty name="categorys"} + {volist name="categorys" id="ca"} + + {if condition="(!$Request.has.id && $key == 0) || $Request.get.id == $ca.id"} +
+ {else/} +
+ {/if} + {$ca.name} +
+
+ {/volist} + {/notempty} +
{:lang('attachment.video')}
+ {notempty name="attachements"}
+ {volist name="attachements" id="att"}
-
+
+ +
-

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}

- Linux - Windows 10-11 + {notempty name="att.attach"} + {volist name="att.attach" id="ch"} + + {$ch.btn_name} + + {/volist} + {/notempty}

-
-
-
-

Driver for USB-C 10Gb Ethernet Adapter

-

Supported Models:

-

ORICO-REA-10

-

Supported Systems:

-

Windows 10-11, Linux

-

- Linux - Windows 10-11 -

-
-
-
-
-
-

Driver for USB-C 10Gb Ethernet Adapter

-

Supported Models:

-

ORICO-REA-10

-

Supported Systems:

-

Windows 10-11, Linux

-

- Linux - Windows 10-11 -

-
-
-
- - - - 1 - 2 - 3 - 4 - - - -
+ {/volist} +
{$page|raw}
- - - + {/notempty}
-{/block} -{block name="script"} - {/block} \ No newline at end of file diff --git a/app/index/view/attachment/video.html b/app/index/view/attachment/video.html new file mode 100644 index 00000000..e3754999 --- /dev/null +++ b/app/index/view/attachment/video.html @@ -0,0 +1,90 @@ +{extend name="public/base" /} +{block name="style"} + +{/block} +{block name="main"} +
+ +
+
+ + +
+
+ +
+ +
+ +
+
+ +
+ {notempty name="categorys"} + {volist name="categorys" id="ca"} + +
+ {$ca.name} +
+
+ {/volist} + {/notempty} +
{:lang('attachment.video')}
+
+ +
+
+
    +
  • Data Storage
  • +
  • Power Transmission
  • +
  • Smart Life
  • +
  • Accessories
  • +
+
+ +
+
    +
    +
    +
    + +
    +
    +
    ORICO RP1 Headphones
    +
    ORICO RP1 in-ear music headphones, skin-friendly and + comfortable for long time wearing; black, white, red and blue, four + colors for you to choose. ORICO 2169U3 full mesh 2.5 inch hard drive + enclosure, all-round heat-dissipation; compatible with SATA HDD below + 9.5mm.
    +
    +
    +
    +
    + +
    +
    +
    ORICO BS16 Bluetooth Speaker
    +
    ORICO BS16 unique and delicate pocket Bluetooth speaker, + bring you beautiful music; smaller size, unprecedented endurance. ORICO + 2169U3 full mesh 2.5 inch hard drive enclosure, all-round + heat-dissipation; compatible with SATA HDD below 9.5mm.
    +
    +
    +
    +
    +
    + + +
    +
+
+
+ +
+
+
+{/block} \ No newline at end of file diff --git a/public/static/index/css/download.css b/public/static/index/css/download.css index 0eb69edd..43d1b3f9 100755 --- a/public/static/index/css/download.css +++ b/public/static/index/css/download.css @@ -156,52 +156,27 @@ background-color: rgba(0, 75, 250, 0.05); cursor: pointer; } -.orico_Page_download .downloadMain .contact_c .softlist .Page { +.orico_Page_download .downloadMain .contact_c .pagination { zoom: 1; text-align: center; color: #555; clear: both; padding-bottom: 2rem; } -.orico_Page_download .downloadMain .contact_c .softlist .Page span { +.orico_Page_download .downloadMain .contact_c .pagination span { padding: 0px 0px; display: inline-block; } -.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page { - display: flex; - align-items: center; - justify-content: center; -} -.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .a_prev, -.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .a_next { - display: inline-block; - width: 10px; - height: 21px; -} -.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .a_prev { - background: url(../downloadImg/pfl.png) no-repeat; - margin-right: 10px; - padding: 0 10px; -} -.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .a_next { - background: url(../downloadImg/prh.png) no-repeat; - margin-left: 10px; - padding: 0 10px; -} -.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .num a { +.orico_Page_download .downloadMain .contact_c .pagination li { display: inline-block; width: 34px; height: 22px; line-height: 22px; - text-align: center; - vertical-align: middle; font-size: 16px; - color: #444; } -.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .num a.a_cur, -.orico_Page_download .downloadMain .contact_c .softlist .Page .p_page .num a:hover { - background: #444; - color: #fff; +.orico_Page_download .downloadMain .contact_c .pagination li.active { + background-color: #444444; + color: #ffffff; } .orico_Page_download .downloadMain .contact_c .vidotabs { margin-top: 32px; @@ -278,6 +253,7 @@ display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; + line-clamp: 2; overflow: hidden; font-size: 14px; margin-top: 16px;