Compare commits
3 Commits
e6e5f260fb
...
fbd479f69a
| Author | SHA1 | Date | |
|---|---|---|---|
| fbd479f69a | |||
| 26b83d2037 | |||
| 941e103258 |
@@ -11,20 +11,48 @@ use app\admin\validate\v1\AttachmentCategoryValidate;
|
||||
*/
|
||||
class AttachmentCategory
|
||||
{
|
||||
/**
|
||||
* 列表树形结构
|
||||
*/
|
||||
public function tree()
|
||||
{
|
||||
$params = request()->param([
|
||||
'name',
|
||||
'is_show'
|
||||
]);
|
||||
|
||||
$categorys = AttachmentCategoryModel::field([
|
||||
'id',
|
||||
'pid',
|
||||
'name'
|
||||
])
|
||||
->withSearch(['name'], [
|
||||
'name' => $params['name']??null
|
||||
])
|
||||
->where(function($query) use($params) {
|
||||
if (isset($params['is_show'])) {
|
||||
$query->where('is_show', '=', $params['is_show']);
|
||||
}
|
||||
})
|
||||
->language(request()->lang_id)
|
||||
->order(['sort' => 'asc', 'id' => 'desc'])
|
||||
->select();
|
||||
|
||||
return success('获取成功', array_to_tree($categorys->toArray(), 0, 'pid', 1, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页数据
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$params = request()->param([
|
||||
'name',
|
||||
'is_show',
|
||||
'page/d' => 1,
|
||||
'size/d' => 10
|
||||
'name'
|
||||
]);
|
||||
|
||||
$categorys = AttachmentCategoryModel::field([
|
||||
'id',
|
||||
'pid',
|
||||
'name',
|
||||
'sort',
|
||||
'is_show'
|
||||
@@ -33,23 +61,10 @@ class AttachmentCategory
|
||||
'name' => $params['name']??null
|
||||
])
|
||||
->language(request()->lang_id)
|
||||
->order(['sort' => 'asc', 'id' => 'desc']);
|
||||
if (!request()->has('scene')) {
|
||||
$categorys = $categorys->paginate([
|
||||
'list_rows' => $params['size'],
|
||||
'page' => $params['page']
|
||||
]);
|
||||
} else if ('all' == request()->param('scene')) {
|
||||
$categorys = $categorys->where(function($query) use($params) {
|
||||
if (isset($params['is_show'])) {
|
||||
$query->where('is_show', '=', $params['is_show']);
|
||||
}
|
||||
})
|
||||
->select()
|
||||
->hidden(['sort', 'is_show']);
|
||||
}
|
||||
->order(['sort' => 'asc', 'id' => 'desc'])
|
||||
->select();
|
||||
|
||||
return success('获取成功', $categorys);
|
||||
return success('获取成功', array_to_tree($categorys->toArray(), 0, 'pid', 1, false));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,6 +95,7 @@ class AttachmentCategory
|
||||
public function save()
|
||||
{
|
||||
$post = request()->post([
|
||||
'pid' => 0,
|
||||
'name',
|
||||
'sort',
|
||||
'is_show'
|
||||
@@ -105,6 +121,7 @@ class AttachmentCategory
|
||||
{
|
||||
$id = request()->param('id');
|
||||
$put = request()->put([
|
||||
'pid' => 0,
|
||||
'name',
|
||||
'sort',
|
||||
'is_show'
|
||||
|
||||
@@ -373,12 +373,12 @@ Route::group('v1', function () {
|
||||
// 附件(下载管理)删除
|
||||
Route::delete('delete/:id', 'Attachment/delete');
|
||||
|
||||
// 附件(下载管理)分类列表
|
||||
Route::get('categorys', 'AttachmentCategory/index')->append(['scene' => 'all']);
|
||||
// 附件(下载管理)分类列表树
|
||||
Route::get('tree', 'AttachmentCategory/tree');
|
||||
|
||||
// 附件(下载管理)分类
|
||||
Route::group('category', function () {
|
||||
// 附件(下载管理)分类分页
|
||||
// 附件(下载管理)分类树
|
||||
Route::get('index', 'AttachmentCategory/index');
|
||||
|
||||
// 附件(下载管理)分类详情
|
||||
|
||||
@@ -43,7 +43,7 @@ class ArticleCategoryValidate extends Validate
|
||||
'name.max' => '分类名称最多64个字符',
|
||||
'pid.integer' => '父级分类ID必须为整数',
|
||||
'pid.different' => '父级分类ID不能为自身',
|
||||
'pid.checkPidNotBeChildren' => '父级分类不能为子分类',
|
||||
'pid.checkPidNotBeChildren' => '父级分类不能为自身或自身的子分类',
|
||||
'sort.require' => '排序不能为空',
|
||||
'sort.integer' => '排序必须为整数',
|
||||
'is_show.require' => '是否显示不能为空',
|
||||
|
||||
@@ -3,6 +3,8 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\validate\v1;
|
||||
|
||||
use app\admin\model\v1\AttachmentCategoryModel;
|
||||
use think\facade\Db;
|
||||
use think\Validate;
|
||||
|
||||
class AttachmentCategoryValidate extends Validate
|
||||
@@ -15,6 +17,7 @@ class AttachmentCategoryValidate extends Validate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|integer',
|
||||
'pid' => 'integer|checkPidNotBeChildren',
|
||||
'language_id' => 'require|integer',
|
||||
'name' => 'require|max:64',
|
||||
'sort' => 'integer',
|
||||
@@ -28,22 +31,50 @@ class AttachmentCategoryValidate extends Validate
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'id.require' => 'ID不能为空',
|
||||
'id.integer' => 'ID必须是整数',
|
||||
'language_id.require' => '语言ID不能为空',
|
||||
'language_id.integer' => '语言ID必须是整数',
|
||||
'name.require' => '名称不能为空',
|
||||
'name.max' => '名称不能超过64个字符',
|
||||
'sort.integer' => '排序必须是整数',
|
||||
'is_show.in' => '是否显示必须是0或1',
|
||||
'id.require' => 'ID不能为空',
|
||||
'id.integer' => 'ID必须是整数',
|
||||
'pid.integer' => '父级ID必须是整数',
|
||||
'pid.checkPidNotBeChildren' => '父级分类不能为自身或自身的子分类',
|
||||
'language_id.require' => '语言ID不能为空',
|
||||
'language_id.integer' => '语言ID必须是整数',
|
||||
'name.require' => '名称不能为空',
|
||||
'name.max' => '名称不能超过64个字符',
|
||||
'sort.integer' => '排序必须是整数',
|
||||
'is_show.in' => '是否显示必须是0或1',
|
||||
];
|
||||
|
||||
// 验证pid
|
||||
protected function checkPidNotBeChildren($value, $rule, $data = [])
|
||||
{
|
||||
if ($value == 0) {
|
||||
return true;
|
||||
}
|
||||
$table_name = (new AttachmentCategoryModel)->getTable();
|
||||
$children = Db::query(
|
||||
preg_replace(
|
||||
'/\s+/u',
|
||||
' ',
|
||||
"WITH RECURSIVE attachment_tree_by AS (
|
||||
SELECT a.id, a.pid FROM $table_name a WHERE a.id = {$data['id']}
|
||||
UNION ALL
|
||||
SELECT k.id, k.pid FROM $table_name k INNER JOIN attachement_tree_by t ON t.id = k.pid
|
||||
)
|
||||
SELECT id FROM attachment_tree_by WHERE id <> {$data['id']};"
|
||||
)
|
||||
);
|
||||
if (!empty($children) && in_array($data['pid'], array_column($children, 'id'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增场景
|
||||
*/
|
||||
public function sceneCreate()
|
||||
{
|
||||
return $this->remove('id', 'require|integer');
|
||||
return $this->remove('id', 'require|integer')->remove('pid', 'checkPidNotBeChildren');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
23
app/index/controller/Attachment.php
Normal file
23
app/index/controller/Attachment.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\index\model\AttachmentCategoryModel;
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
* 附件控制器
|
||||
*/
|
||||
class Attachment extends Common
|
||||
{
|
||||
// 分页列表
|
||||
public function index()
|
||||
{
|
||||
// 获取分类
|
||||
$category = AttachmentCategoryModel::language($this->lang_id)->select();
|
||||
View::assign('category', $category);
|
||||
|
||||
return View::fetch('index');
|
||||
}
|
||||
}
|
||||
@@ -31,5 +31,11 @@ return [
|
||||
'detail_leave_reply_comment' => 'Comment',
|
||||
'detail_leave_reply_submit' => 'POST COMMENT',
|
||||
'detail_recommend' => 'Recommended for you',
|
||||
],
|
||||
'attachment' => [
|
||||
'software_drives' => 'Software and Drivers',
|
||||
'software_download' => 'Software Drives',
|
||||
'manual_download' => 'Manual',
|
||||
'video' => 'Videos'
|
||||
]
|
||||
];
|
||||
@@ -31,5 +31,11 @@ return [
|
||||
'detail_leave_reply_comment' => '留言',
|
||||
'detail_leave_reply_submit' => '提交留言',
|
||||
'detail_recommend' => '你可能还喜欢',
|
||||
],
|
||||
'attachment' => [
|
||||
'software_drives' => '软件和驱动程序',
|
||||
'software_download' => '软件下载',
|
||||
'manual_download' => '手册',
|
||||
'video' => '视频'
|
||||
]
|
||||
];
|
||||
25
app/index/model/AttachmentCategoryModel.php
Normal file
25
app/index/model/AttachmentCategoryModel.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\AttachmentCategoryBaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* 附件分类模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class AttachmentCategoryModel extends AttachmentCategoryBaseModel
|
||||
{
|
||||
// 启用软删除
|
||||
use SoftDelete;
|
||||
// 软删除时间字段名
|
||||
protected $deleteTime = 'deleted_at';
|
||||
|
||||
// 所属语言范围查询
|
||||
public function scopeLanguage($query, $language)
|
||||
{
|
||||
return $query->where('language_id', '=', $language);
|
||||
}
|
||||
}
|
||||
19
app/index/model/AttachmentModel.php
Normal file
19
app/index/model/AttachmentModel.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\index\model;
|
||||
|
||||
use app\common\model\AttachmentBaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* 附件模型
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class AttachmentModel extends AttachmentBaseModel
|
||||
{
|
||||
// 启用软删除
|
||||
use SoftDelete;
|
||||
// 软删除时间字段名
|
||||
protected $deleteTime = 'deleted_at';
|
||||
}
|
||||
@@ -34,6 +34,11 @@ Route::group('article', function() {
|
||||
Route::post('comment', 'Article/comment');
|
||||
});
|
||||
|
||||
// 附件下载
|
||||
Route::group('attachment', function() {
|
||||
Route::get('index', 'Attachment/index');
|
||||
});
|
||||
|
||||
// 问答中心
|
||||
Route::group('faq', function() {
|
||||
// 问答列表页
|
||||
|
||||
166
app/index/view/attachment/index.html
Normal file
166
app/index/view/attachment/index.html
Normal file
@@ -0,0 +1,166 @@
|
||||
{extend name="public/base" /}
|
||||
{block name="style"}
|
||||
<link rel="stylesheet" href="__CSS__/download.css" />
|
||||
{/block}
|
||||
{block name="main"}
|
||||
<div class="orico_Page_download">
|
||||
<!-- 内容 -->
|
||||
<div class="downloadMain">
|
||||
<div class="topimg">
|
||||
<img src="__IMAGES__/banner_01.png" />
|
||||
<div class="banner_title">{:lang('attachment.software_drives')}</div>
|
||||
</div>
|
||||
<div class="contact_c">
|
||||
<!-- 搜索 -->
|
||||
<div class="search_all">
|
||||
<input type="text" name="textfield" placeholder="Search model" id="search_software">
|
||||
<div class="searchbtn" id="search-btn">
|
||||
<img src="downloadImg/search.png" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- tab切换 -->
|
||||
<div class="tab">
|
||||
<div class="tabit on">{:lang('attachment.software_download')}</div>
|
||||
<div class="tabit">{:lang('attachment.manual_download')}</div>
|
||||
<div class="tabit">{:lang('attachment.video')}</div>
|
||||
</div>
|
||||
<!-- 切换的内容 -->
|
||||
<div class="softlist">
|
||||
<div class="softit">
|
||||
<div class="left_img"><img src="downloadImg/10G.jpg" alt=""></div>
|
||||
<div>
|
||||
<p class="title">Driver for USB-C 10Gb Ethernet Adapter</p>
|
||||
<p class="sub_title">Supported Models: </p>
|
||||
<p class="des">ORICO-REA-10</p>
|
||||
<p class="sub_title">Supported Systems: </p>
|
||||
<p class="des">Windows 10-11, Linux</p>
|
||||
<p>
|
||||
<a href="/uploads/download/2024/Linux-Driver.zip" data-cod="dl" data-id="332"
|
||||
target="_blank"><span class="l_button">Linux</span></a>
|
||||
<a href="/uploads/download/2024/Windows 10-11.zip" data-cod="dl" data-id="332"
|
||||
target="_blank"><span class="l_button">Windows 10-11</span></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="softit">
|
||||
<div class="left_img"><img src="downloadImg/10G.jpg" alt=""></div>
|
||||
<div>
|
||||
<p class="title">Driver for USB-C 10Gb Ethernet Adapter</p>
|
||||
<p class="sub_title">Supported Models: </p>
|
||||
<p class="des">ORICO-REA-10</p>
|
||||
<p class="sub_title">Supported Systems: </p>
|
||||
<p class="des">Windows 10-11, Linux</p>
|
||||
<p>
|
||||
<a href="/uploads/download/2024/Linux-Driver.zip" data-cod="dl" data-id="332"
|
||||
target="_blank"><span class="l_button">Linux</span></a>
|
||||
<a href="/uploads/download/2024/Windows 10-11.zip" data-cod="dl" data-id="332"
|
||||
target="_blank"><span class="l_button">Windows 10-11</span></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="softit">
|
||||
<div class="left_img"><img src="downloadImg/10G.jpg" alt=""></div>
|
||||
<div>
|
||||
<p class="title">Driver for USB-C 10Gb Ethernet Adapter</p>
|
||||
<p class="sub_title">Supported Models: </p>
|
||||
<p class="des">ORICO-REA-10</p>
|
||||
<p class="sub_title">Supported Systems: </p>
|
||||
<p class="des">Windows 10-11, Linux</p>
|
||||
<p>
|
||||
<a href="/uploads/download/2024/Linux-Driver.zip" data-cod="dl" data-id="332"
|
||||
target="_blank"><span class="l_button">Linux</span></a>
|
||||
<a href="/uploads/download/2024/Windows 10-11.zip" data-cod="dl" data-id="332"
|
||||
target="_blank"><span class="l_button">Windows 10-11</span></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Page">
|
||||
<span class="p_page">
|
||||
<a class="a_prev"></a>
|
||||
<em class="num">
|
||||
<a class="a_cur">1</a>
|
||||
<a>2</a>
|
||||
<a>3</a>
|
||||
<a>4</a>
|
||||
</em>
|
||||
<a class="a_next"></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- VIDEO 切换 -->
|
||||
<div class="vidotabs" style="display: none;">
|
||||
<div class="hd">
|
||||
<ul>
|
||||
<li class="vli von">Data Storage</li>
|
||||
<li class="vli">Power Transmission</li>
|
||||
<li class="vli">Smart Life</li>
|
||||
<li class="vli">Accessories</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- 视频内容 -->
|
||||
<div class="bdconten">
|
||||
<ul >
|
||||
<dl class="video_hotul">
|
||||
<dd>
|
||||
<div class="hot1">
|
||||
<video preload="none" controls="controls">
|
||||
<source src="/uploads/uk/video/entertainment/RP1 .mp4" type="video/mp4">
|
||||
</video>
|
||||
</div>
|
||||
<div class="htit">
|
||||
<div class="htit1">ORICO RP1 Headphones</div>
|
||||
<div class="htit2"> 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. </div>
|
||||
</div>
|
||||
</dd>
|
||||
<dd>
|
||||
<div class="hot1">
|
||||
<video preload="none" controls="controls">
|
||||
<source src="/uploads/uk/video/entertainment/BS16.mp4" type="video/mp4">
|
||||
</video>
|
||||
</div>
|
||||
<div class="htit">
|
||||
<div class="htit1">ORICO BS16 Bluetooth Speaker</div>
|
||||
<div class="htit2"> 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. </div>
|
||||
</div>
|
||||
</dd>
|
||||
<div class="clear"></div>
|
||||
</dl>
|
||||
<div id="page39">
|
||||
<!-- 分页 s -->
|
||||
<!-- 分页 e -->
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 如果切换的是 Videos-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
{block name="script"}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
// 为所有具有 tabitme 类的元素添加点击事件
|
||||
$('.tabit').click(function() {
|
||||
// 移除所有 tabitme 元素的 on 类
|
||||
$('.tabit').removeClass('on');
|
||||
// 为当前点击的元素添加 on 类
|
||||
$(this).addClass('on');
|
||||
});
|
||||
// 为所有具有 tabitme 类的元素添加点击事件
|
||||
$('.vli').click(function() {
|
||||
// 移除所有 tabitme 元素的 on 类
|
||||
$('.vli').removeClass('von');
|
||||
// 为当前点击的元素添加 on 类
|
||||
$(this).addClass('von');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
@@ -1,7 +1,7 @@
|
||||
.orico_Page_download {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
height: 100vh;
|
||||
height: auto;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
background: #f2f2f2;
|
||||
|
||||
Reference in New Issue
Block a user