增加游戏模块
@ -9,7 +9,7 @@ use app\admin\model\Resource\ResourceCategory;
|
||||
use think\facade\View;
|
||||
use think\facade\Request;
|
||||
use think\facade\Db;
|
||||
use app\admin\controller\Log;
|
||||
use app\admin\controller\LogController as Log;
|
||||
use think\App;
|
||||
|
||||
class ResourcesController extends BaseController
|
||||
@ -100,14 +100,17 @@ class ResourcesController extends BaseController
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
$data = [
|
||||
'name' => input('post.name'),
|
||||
'title' => input('post.title'),
|
||||
'cate' => input('post.cate'),
|
||||
'icon' => input('post.icon'),
|
||||
'url' => input('post.url'),
|
||||
'code' => input('post.code'),
|
||||
'uploader' => input('post.uploader'),
|
||||
'desc' => input('post.desc'),
|
||||
'content' => input('post.content'),
|
||||
'number' => input('post.number'),
|
||||
'status' => input('post.status', 2),
|
||||
|
||||
'create_time' => time()
|
||||
];
|
||||
|
||||
@ -130,6 +133,64 @@ class ResourcesController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑资源
|
||||
public function edit()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
$data = input('post.');
|
||||
$id = input('id/d', 0);
|
||||
|
||||
if (!$id) {
|
||||
Log::record('编辑资源', 0, '参数错误', '资源管理');
|
||||
return json(['code' => 1, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
$updateData = [
|
||||
'title' => $data['title'],
|
||||
'cate' => $data['cate'],
|
||||
'desc' => $data['desc'],
|
||||
'uploader' => $data['uploader'],
|
||||
'icon' => $data['icon'],
|
||||
'fileurl' => $data['fileurl'],
|
||||
'url' => $data['url'],
|
||||
'code' => $data['code'],
|
||||
'sort' => $data['sort'],
|
||||
'number' => $data['number'],
|
||||
'content' => $data['content'],
|
||||
'update_time' => time()
|
||||
];
|
||||
|
||||
$result = Resource::where('id', $id)
|
||||
->update($updateData);
|
||||
|
||||
if ($result !== false) {
|
||||
Log::record('编辑资源', 1, '', '资源管理');
|
||||
return json(['code' => 0, 'msg' => '编辑成功']);
|
||||
} else {
|
||||
Log::record('编辑资源', 0, '编辑资源失败', '资源管理');
|
||||
return json(['code' => 1, 'msg' => '编辑失败']);
|
||||
}
|
||||
}
|
||||
|
||||
$id = input('id/d', 0);
|
||||
if (!$id) {
|
||||
Log::record('编辑资源', 0, '参数错误', '资源管理');
|
||||
$this->error('参数错误');
|
||||
}
|
||||
|
||||
$resource = Resource::where('id', $id)
|
||||
->where('delete_time', null)
|
||||
->find();
|
||||
|
||||
if (!$resource) {
|
||||
Log::record('编辑资源', 0, '资源不存在', '资源管理');
|
||||
$this->error('资源不存在');
|
||||
}
|
||||
|
||||
View::assign('resource', $resource);
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
// 删除资源
|
||||
public function delete()
|
||||
{
|
||||
@ -167,6 +228,29 @@ class ResourcesController extends BaseController
|
||||
->order('sort asc, id asc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 获取每个分类下的资源总数
|
||||
foreach ($lists as &$item) {
|
||||
if ($item['cid'] == 0) {
|
||||
// 父级分类 - 统计所有子分类的资源总数
|
||||
$childIds = ResourceCategory::where('cid', $item['id'])
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->column('id');
|
||||
|
||||
$item['total'] = Resource::where('cate', 'in', array_merge([$item['id']], $childIds))
|
||||
->where('delete_time', null)
|
||||
->where('status', '<>', 3)
|
||||
->count();
|
||||
} else {
|
||||
// 子分类 - 只统计当前分类的资源
|
||||
$item['total'] = Resource::where('cate', $item['id'])
|
||||
->where('delete_time', null)
|
||||
->where('status', '<>', 3)
|
||||
->count();
|
||||
}
|
||||
}
|
||||
|
||||
$tree = $this->buildParentChild($lists);
|
||||
return json(['code' => 0, 'msg' => '获取成功', 'data' => $tree]);
|
||||
}
|
||||
@ -179,6 +263,7 @@ class ResourcesController extends BaseController
|
||||
'name' => input('post.name'),
|
||||
'icon' => input('post.icon'),
|
||||
'cid' => input('post.cid'),
|
||||
'number' => input('post.number'),
|
||||
'sort' => input('post.sort', 0),
|
||||
'status' => input('post.status', 1),
|
||||
'create_time' => time()
|
||||
@ -217,6 +302,7 @@ class ResourcesController extends BaseController
|
||||
'name' => input('post.name'),
|
||||
'icon' => input('post.icon'),
|
||||
'cid' => input('post.cid'),
|
||||
'number' => input('post.number'),
|
||||
'sort' => input('post.sort', 0),
|
||||
'status' => input('post.status', 1),
|
||||
'update_time' => time()
|
||||
@ -309,64 +395,6 @@ class ResourcesController extends BaseController
|
||||
return json(['code' => 0, 'msg' => '获取成功', 'data' => $resource]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑资源
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
if (Request::isPost()) {
|
||||
$data = input('post.');
|
||||
$id = input('id/d', 0);
|
||||
|
||||
if (!$id) {
|
||||
Log::record('编辑资源', 0, '参数错误', '资源管理');
|
||||
return json(['code' => 1, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
$updateData = [
|
||||
'title' => $data['title'],
|
||||
'cate' => $data['cate'],
|
||||
'desc' => $data['desc'],
|
||||
'uploader' => $data['uploader'],
|
||||
'icon' => $data['icon'],
|
||||
'fileurl' => $data['fileurl'],
|
||||
'url' => $data['url'],
|
||||
'code' => $data['code'],
|
||||
'sort' => $data['sort'],
|
||||
'update_time' => time()
|
||||
];
|
||||
|
||||
$result = Resource::where('id', $id)
|
||||
->update($updateData);
|
||||
|
||||
if ($result !== false) {
|
||||
Log::record('编辑资源', 1, '', '资源管理');
|
||||
return json(['code' => 0, 'msg' => '编辑成功']);
|
||||
} else {
|
||||
Log::record('编辑资源', 0, '编辑资源失败', '资源管理');
|
||||
return json(['code' => 1, 'msg' => '编辑失败']);
|
||||
}
|
||||
}
|
||||
|
||||
$id = input('id/d', 0);
|
||||
if (!$id) {
|
||||
Log::record('编辑资源', 0, '参数错误', '资源管理');
|
||||
$this->error('参数错误');
|
||||
}
|
||||
|
||||
$resource = Resource::where('id', $id)
|
||||
->where('delete_time', null)
|
||||
->find();
|
||||
|
||||
if (!$resource) {
|
||||
Log::record('编辑资源', 0, '资源不存在', '资源管理');
|
||||
$this->error('资源不存在');
|
||||
}
|
||||
|
||||
View::assign('resource', $resource);
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
//统计资源数量
|
||||
public function counts()
|
||||
{
|
||||
|
||||
@ -22,12 +22,20 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="cate" lay-verify="required">
|
||||
<select name="cate" lay-verify="required" lay-filter="cate">
|
||||
<option value="">请选择分类</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="number" required lay-verify="required" placeholder="选取分类后系统自动生成" autocomplete="off"
|
||||
class="layui-input" lay-affix="clear" disabled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
@ -39,7 +47,7 @@
|
||||
<label class="layui-form-label">上传者</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="uploader" required lay-verify="required" placeholder="请输入上传者"
|
||||
autocomplete="off" class="layui-input" lay-affix="clear">
|
||||
autocomplete="off" class="layui-input" lay-affix="clear" value="{$aUser['name']}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -111,6 +119,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">内容</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="editor—wrapper" id="content" name="content" style="border: 1px solid #ccc;">
|
||||
<div id="toolbar-container" style="border-bottom: 1px solid #ccc;"><!-- 工具栏 --></div>
|
||||
<div id="editor-container" style="height: 800px;"><!-- 编辑器 --></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
|
||||
@ -120,6 +138,7 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/wangeditor.js"></script>
|
||||
<script>
|
||||
layui.use(['form', 'layer'], function () {
|
||||
var form = layui.form;
|
||||
@ -220,14 +239,92 @@
|
||||
});
|
||||
$('select[name="cate"]').html(html);
|
||||
form.render('select');
|
||||
|
||||
// 存储分类数据供后续使用
|
||||
window.categoryData = res.data;
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
|
||||
// 监听分类选择变化
|
||||
form.on('select(cate)', function(data) {
|
||||
var selectedId = data.value;
|
||||
if (!selectedId) {
|
||||
$('input[name="number"]').val('');
|
||||
return;
|
||||
}
|
||||
|
||||
// 递归查找分类信息的函数
|
||||
function findCategory(categories, targetId) {
|
||||
for (let category of categories) {
|
||||
// 检查当前分类
|
||||
if (category.id == targetId) {
|
||||
return {
|
||||
parent: null,
|
||||
current: category,
|
||||
total: category.total || 0
|
||||
};
|
||||
}
|
||||
// 检查子分类
|
||||
if (category.children && category.children.length > 0) {
|
||||
for (let child of category.children) {
|
||||
if (child.id == targetId) {
|
||||
return {
|
||||
parent: category,
|
||||
current: child,
|
||||
total: child.total || 0
|
||||
};
|
||||
}
|
||||
// 递归检查更深层级的子分类
|
||||
if (child.children && child.children.length > 0) {
|
||||
const result = findCategory([child], targetId);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 查找选中的分类信息
|
||||
const categoryInfo = findCategory(window.categoryData, selectedId);
|
||||
|
||||
if (categoryInfo) {
|
||||
// 生成资源编号
|
||||
var nextNumber = categoryInfo.total + 1;
|
||||
var numberStr = nextNumber.toString().padStart(5, '0');
|
||||
var resourceNumber = '';
|
||||
|
||||
// 构建编号前缀
|
||||
if (categoryInfo.parent) {
|
||||
resourceNumber = categoryInfo.parent.number + categoryInfo.current.number;
|
||||
} else {
|
||||
resourceNumber = categoryInfo.current.number;
|
||||
}
|
||||
|
||||
// 添加序号
|
||||
resourceNumber += numberStr;
|
||||
|
||||
// 设置资源编号
|
||||
$('input[name="number"]').val(resourceNumber);
|
||||
}
|
||||
});
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(formSubmit)', function (data) {
|
||||
// 获取编辑器内容
|
||||
var content = editor.getHtml();
|
||||
if (!content || content === '<p><br></p>') {
|
||||
layer.msg('请输入文章内容', { icon: 2 });
|
||||
return false;
|
||||
}
|
||||
|
||||
var loadIndex = layer.load(2);
|
||||
data.field.content = content;
|
||||
|
||||
$.ajax({
|
||||
url: '{:url("resources/add")}',
|
||||
type: 'POST',
|
||||
@ -272,6 +369,80 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- wangeditor编辑器脚本 -->
|
||||
<script>
|
||||
const { createEditor, createToolbar } = window.wangEditor
|
||||
|
||||
const editorConfig = {
|
||||
MENU_CONF: {},
|
||||
placeholder: '请输入内容...',
|
||||
onChange(editor) {
|
||||
const html = editor.getHtml()
|
||||
},
|
||||
}
|
||||
|
||||
// 配置图片上传
|
||||
editorConfig.MENU_CONF['uploadImage'] = {
|
||||
server: '{:url("index/upload_img")}',
|
||||
fieldName: 'file',
|
||||
maxFileSize: 10 * 1024 * 1024, // 10M
|
||||
maxNumberOfFiles: 10,
|
||||
allowedFileTypes: ['image/*'],
|
||||
meta: {
|
||||
token: 'xxx'
|
||||
},
|
||||
metaWithUrl: true,
|
||||
headers: {
|
||||
Accept: 'text/x-json'
|
||||
},
|
||||
timeout: 5 * 1000, // 5s
|
||||
|
||||
onBeforeUpload(file) {
|
||||
console.log('准备上传图片', file)
|
||||
return file
|
||||
},
|
||||
onProgress(progress) {
|
||||
console.log('上传进度', progress)
|
||||
},
|
||||
onSuccess(file, res) {
|
||||
console.log('上传成功', file, res)
|
||||
},
|
||||
onFailed(file, res) {
|
||||
layer.msg('上传失败:' + res.msg, { icon: 2 })
|
||||
console.log('上传失败', file, res)
|
||||
},
|
||||
onError(file, err, res) {
|
||||
layer.msg('上传出错:' + err.message, { icon: 2 })
|
||||
console.error('上传出错', file, err, res)
|
||||
},
|
||||
customInsert(res, insertFn) {
|
||||
// res 即服务端的返回结果
|
||||
if (res.code === 0 && res.data) {
|
||||
// 直接使用res.data作为图片地址
|
||||
insertFn(res.data);
|
||||
} else {
|
||||
layer.msg('图片上传失败', { icon: 2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const editor = createEditor({
|
||||
selector: '#editor-container',
|
||||
html: '<p><br></p>',
|
||||
config: editorConfig,
|
||||
mode: 'default', // or 'simple'
|
||||
})
|
||||
|
||||
const toolbarConfig = {}
|
||||
|
||||
const toolbar = createToolbar({
|
||||
editor,
|
||||
selector: '#toolbar-container',
|
||||
config: toolbarConfig,
|
||||
mode: 'default', // or 'simple'
|
||||
})
|
||||
</script>
|
||||
|
||||
<script>
|
||||
//返回资源列表
|
||||
function goBack() {
|
||||
|
||||
@ -50,6 +50,13 @@
|
||||
<!-- 分类表单 -->
|
||||
<form class="layui-form category-form" lay-filter="categoryForm" style="display: none;">
|
||||
<input type="hidden" name="id" id="categoryId">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="number" required lay-verify="required" placeholder="请输入分类编号"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类名称</label>
|
||||
@ -403,6 +410,7 @@
|
||||
form.val('categoryForm', {
|
||||
id: data ? data.info.id : '',
|
||||
name: data ? data.info.name : '',
|
||||
number: data ? data.info.number : '',
|
||||
cid: data ? data.info.cid : parentId,
|
||||
sort: data ? data.info.sort : 0,
|
||||
status: data ? data.info.status : 1
|
||||
|
||||
@ -23,11 +23,19 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="cate" lay-verify="required">
|
||||
<select name="cate" lay-verify="required" lay-filter="cate">
|
||||
<option value="">请选择分类</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="number" required lay-verify="required" placeholder="请输入分类编号" autocomplete="off"
|
||||
class="layui-input" value="{$resource.number|default=''}" lay-affix="clear" disabled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
@ -112,6 +120,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">内容</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="editor—wrapper" id="content" name="content" style="border: 1px solid #ccc;">
|
||||
<div id="toolbar-container" style="border-bottom: 1px solid #ccc;"><!-- 工具栏 --></div>
|
||||
<div id="editor-container" style="height: 800px;"><!-- 编辑器 --></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
|
||||
@ -121,6 +139,7 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/wangeditor.js"></script>
|
||||
<script>
|
||||
layui.use(['form', 'layer'], function () {
|
||||
var form = layui.form;
|
||||
@ -245,6 +264,9 @@
|
||||
// 获取分类列表
|
||||
$.get('{:url("resources/getcate")}', function (res) {
|
||||
if (res.code == 0) {
|
||||
// 存储分类数据供后续使用
|
||||
window.categoryData = res.data;
|
||||
|
||||
var html = '<option value="">请选择分类</option>';
|
||||
res.data.forEach(function (item) {
|
||||
html += '<option value="' + item.id + '">' + item.name + '</option>';
|
||||
@ -269,9 +291,50 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 监听分类选择变化
|
||||
form.on('select(cate)', function(data) {
|
||||
var selectedId = data.value;
|
||||
if (!selectedId) {
|
||||
$('input[name="number"]').val('');
|
||||
return;
|
||||
}
|
||||
|
||||
// 查找选中的分类信息
|
||||
var parentCategory = null;
|
||||
var childCategory = null;
|
||||
|
||||
window.categoryData.forEach(function(parent) {
|
||||
if (parent.children) {
|
||||
parent.children.forEach(function(child) {
|
||||
if (child.id == selectedId) {
|
||||
parentCategory = parent;
|
||||
childCategory = child;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (parentCategory && childCategory) {
|
||||
// 生成资源编号
|
||||
var total = childCategory.total || 0;
|
||||
// 判断是否是初始化时的分类
|
||||
var isInitialCategory = resourceData && resourceData.cate == selectedId;
|
||||
var nextNumber = isInitialCategory ? total : total + 1;
|
||||
var numberStr = nextNumber.toString().padStart(5, '0');
|
||||
var resourceNumber = parentCategory.number + childCategory.number + numberStr;
|
||||
|
||||
// 设置资源编号
|
||||
$('input[name="number"]').val(resourceNumber);
|
||||
}
|
||||
});
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(formSubmit)', function (data) {
|
||||
// 获取编辑器内容
|
||||
var content = editor.getHtml();
|
||||
var loadIndex = layer.load(2);
|
||||
data.field.content = content;
|
||||
|
||||
$.ajax({
|
||||
url: '{:url("resources/edit")}',
|
||||
type: 'POST',
|
||||
@ -324,6 +387,85 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- wangeditor编辑器脚本 -->
|
||||
<script>
|
||||
const { createEditor, createToolbar } = window.wangEditor
|
||||
|
||||
const editorConfig = {
|
||||
MENU_CONF: {},
|
||||
placeholder: '请输入内容...',
|
||||
onChange(editor) {
|
||||
const html = editor.getHtml()
|
||||
},
|
||||
}
|
||||
|
||||
// 配置图片上传
|
||||
editorConfig.MENU_CONF['uploadImage'] = {
|
||||
server: '{:url("index/upload_img")}',
|
||||
fieldName: 'file',
|
||||
maxFileSize: 10 * 1024 * 1024, // 10M
|
||||
maxNumberOfFiles: 10,
|
||||
allowedFileTypes: ['image/*'],
|
||||
meta: {
|
||||
token: 'xxx'
|
||||
},
|
||||
metaWithUrl: true,
|
||||
headers: {
|
||||
Accept: 'text/x-json'
|
||||
},
|
||||
timeout: 5 * 1000, // 5s
|
||||
|
||||
onBeforeUpload(file) {
|
||||
console.log('准备上传图片', file)
|
||||
return file
|
||||
},
|
||||
onProgress(progress) {
|
||||
console.log('上传进度', progress)
|
||||
},
|
||||
onSuccess(file, res) {
|
||||
console.log('上传成功', file, res)
|
||||
},
|
||||
onFailed(file, res) {
|
||||
layer.msg('上传失败:' + res.msg, { icon: 2 })
|
||||
console.log('上传失败', file, res)
|
||||
},
|
||||
onError(file, err, res) {
|
||||
layer.msg('上传出错:' + err.message, { icon: 2 })
|
||||
console.error('上传出错', file, err, res)
|
||||
},
|
||||
customInsert(res, insertFn) {
|
||||
// res 即服务端的返回结果
|
||||
if (res.code === 0 && res.data) {
|
||||
// 从res.data中获取src字段
|
||||
const url = String(res.data.src || '');
|
||||
if (url) {
|
||||
insertFn(url);
|
||||
} else {
|
||||
layer.msg('图片地址无效', { icon: 2 });
|
||||
}
|
||||
} else {
|
||||
layer.msg('图片上传失败', { icon: 2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const editor = createEditor({
|
||||
selector: '#editor-container',
|
||||
html: `{$resource.content|raw|default=''}`,
|
||||
config: editorConfig,
|
||||
mode: 'default', // or 'simple'
|
||||
})
|
||||
|
||||
const toolbarConfig = {}
|
||||
|
||||
const toolbar = createToolbar({
|
||||
editor,
|
||||
selector: '#toolbar-container',
|
||||
config: toolbarConfig,
|
||||
mode: 'default', // or 'simple'
|
||||
})
|
||||
</script>
|
||||
|
||||
<script>
|
||||
//返回资源列表
|
||||
function goBack() {
|
||||
|
||||
@ -60,11 +60,7 @@
|
||||
{{# if(d.status == '0'){ }}
|
||||
<span style="color:red;">未审核</span>
|
||||
{{# } else if(d.status == '1'){ }}
|
||||
<span style="color:orange;">待审核</span>
|
||||
{{# } else if(d.status == '2'){ }}
|
||||
<span style="color:green;">已发布</span>
|
||||
{{# } else if(d.status == '3'){ }}
|
||||
<span style="color:gray;">已下架</span>
|
||||
<span style="color:green;">已审核</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
@ -91,6 +87,7 @@
|
||||
method: 'post',
|
||||
cols: [[
|
||||
{ field: 'id', title: 'ID', align: 'center', width: 80 },
|
||||
{ field: 'number', title: '资源编号', width: 100 },
|
||||
{ field: 'title', title: '资源名称' },
|
||||
{ field: 'cate', title: '分类', align: 'center', width: 120 },
|
||||
{ field: 'icon', title: '图标', templet: '#iconTemplate', align: 'center', width: 100 },
|
||||
|
||||
242
app/index/controller/GameController.php
Normal file
@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* 游戏下载控制器
|
||||
*/
|
||||
namespace app\index\controller;
|
||||
use app\index\controller\BaseController;
|
||||
use think\facade\Db;
|
||||
use think\facade\View;
|
||||
use think\facade\Request;
|
||||
use app\index\model\Resources\Resources;
|
||||
use app\index\model\Resources\ResourcesCategory;
|
||||
use app\index\model\Attachments;
|
||||
|
||||
class GameController extends BaseController
|
||||
{
|
||||
// 游戏列表页
|
||||
public function list()
|
||||
{
|
||||
// 获取分类ID
|
||||
$cateId = Request::param('cate/d', 0);
|
||||
|
||||
// 构建查询条件
|
||||
$where = [
|
||||
['delete_time', '=', null],
|
||||
['status', '=', 1]
|
||||
];
|
||||
|
||||
if ($cateId > 0) {
|
||||
$where[] = ['cate', '=', $cateId];
|
||||
}
|
||||
|
||||
// 获取游戏列表
|
||||
$games = Resources::where($where)
|
||||
->order('id DESC')
|
||||
->paginate([
|
||||
'list_rows' => 10,
|
||||
'query' => Request::param()
|
||||
]);
|
||||
|
||||
// 获取分类信息
|
||||
$category = null;
|
||||
if ($cateId > 0) {
|
||||
$category = ResourcesCategory::where('id', $cateId)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 获取所有分类
|
||||
$categories = ResourcesCategory::where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 将变量传递给视图
|
||||
View::assign([
|
||||
'games' => $games,
|
||||
'category' => $category,
|
||||
'categories' => $categories
|
||||
]);
|
||||
|
||||
return View::fetch('list');
|
||||
}
|
||||
|
||||
// 游戏详情页
|
||||
public function detail()
|
||||
{
|
||||
$id = Request::param('id/d', 0);
|
||||
$game = Resources::where('id', $id)->find();
|
||||
|
||||
if (!$game) {
|
||||
return json(['code' => 0, 'msg' => '游戏不存在或已被删除']);
|
||||
}
|
||||
|
||||
// 如果size没有,从附件表中获取
|
||||
if (empty($game['size']) && !empty($game['fileurl'])) {
|
||||
$attachment = Attachments::where('src', $game['fileurl'])
|
||||
->find();
|
||||
|
||||
if ($attachment && !empty($attachment['size'])) {
|
||||
$size = $attachment['size'];
|
||||
// 转换文件大小为合适的单位
|
||||
if ($size >= 1073741824) { // 1GB = 1024MB = 1024*1024KB = 1024*1024*1024B
|
||||
$game['size'] = round($size / 1073741824, 2) . 'GB';
|
||||
} elseif ($size >= 1048576) { // 1MB = 1024KB = 1024*1024B
|
||||
$game['size'] = round($size / 1048576, 2) . 'MB';
|
||||
} else {
|
||||
$game['size'] = round($size / 1024, 2) . 'KB';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取分类名称
|
||||
$cateName = ResourcesCategory::where('id', $game['cate'])
|
||||
->value('name');
|
||||
|
||||
// 获取上一个和下一个游戏
|
||||
$prevGame = Resources::where('id', '<', $id)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->order('id DESC')
|
||||
->find();
|
||||
|
||||
$nextGame = Resources::where('id', '>', $id)
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->order('id ASC')
|
||||
->find();
|
||||
|
||||
// 获取相关游戏(同分类的其他游戏)
|
||||
$relatedGames = Db::table('yz_resources')
|
||||
->alias('g')
|
||||
->join('yz_resources_category c', 'g.cate = c.id')
|
||||
->where('g.cate', $game['cate'])
|
||||
->where('g.id', '<>', $id)
|
||||
->where('g.delete_time', null)
|
||||
->where('g.status', 1)
|
||||
->field([
|
||||
'g.id',
|
||||
'g.title',
|
||||
'g.desc',
|
||||
'IF(g.icon IS NULL OR g.icon = "", c.icon, g.icon) as icon'
|
||||
])
|
||||
->order('g.id DESC')
|
||||
->limit(3)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 如果是 AJAX 请求,返回 JSON 数据
|
||||
if (Request::isAjax()) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'game' => $game,
|
||||
'cateName' => $cateName,
|
||||
'prevGame' => $prevGame,
|
||||
'nextGame' => $nextGame,
|
||||
'relatedGames' => $relatedGames
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
// 非 AJAX 请求返回视图
|
||||
View::assign([
|
||||
'game' => $game,
|
||||
'cateName' => $cateName,
|
||||
'prevGame' => $prevGame,
|
||||
'nextGame' => $nextGame,
|
||||
'relatedGames' => $relatedGames
|
||||
]);
|
||||
|
||||
return View::fetch('detail');
|
||||
}
|
||||
|
||||
// 游戏下载
|
||||
public function downloadurl()
|
||||
{
|
||||
if (!Request::isAjax()) {
|
||||
return json(['code' => 0, 'msg' => '非法请求']);
|
||||
}
|
||||
|
||||
$id = Request::param('id/d', 0);
|
||||
|
||||
// 获取游戏信息
|
||||
$game = Resources::where('id', $id)
|
||||
->where('delete_time', null)
|
||||
->find();
|
||||
|
||||
if (!$game) {
|
||||
return json(['code' => 0, 'msg' => '游戏不存在']);
|
||||
}
|
||||
|
||||
// 更新下载次数
|
||||
$result = Resources::where('id', $id)
|
||||
->where('delete_time', null)
|
||||
->inc('downloads', 1)
|
||||
->update();
|
||||
|
||||
if ($result) {
|
||||
return json([
|
||||
'code' => 1,
|
||||
'msg' => '下载成功',
|
||||
'data' => [
|
||||
'url' => $game['url']
|
||||
]
|
||||
]);
|
||||
} else {
|
||||
return json(['code' => 0, 'msg' => '下载失败']);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取访问统计
|
||||
public function viewStats()
|
||||
{
|
||||
$id = Request::param('id/d', 0);
|
||||
|
||||
// 获取总访问量
|
||||
$totalViews = Resources::where('id', $id)
|
||||
->value('views');
|
||||
|
||||
return json([
|
||||
'code' => 1,
|
||||
'data' => [
|
||||
'total' => $totalViews
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新游戏访问次数
|
||||
*/
|
||||
public function updateViews()
|
||||
{
|
||||
if (!Request::isPost()) {
|
||||
return json(['code' => 0, 'msg' => '非法请求']);
|
||||
}
|
||||
|
||||
$id = Request::post('id');
|
||||
if (!$id) {
|
||||
return json(['code' => 0, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
try {
|
||||
// 更新访问次数
|
||||
$game = Resources::where('id', $id)->find();
|
||||
if (!$game) {
|
||||
return json(['code' => 0, 'msg' => '游戏不存在']);
|
||||
}
|
||||
|
||||
// 更新访问次数
|
||||
Resources::where('id', $id)->inc('views')->update();
|
||||
|
||||
// 获取更新后的访问次数
|
||||
$newViews = Resources::where('id', $id)->value('views');
|
||||
|
||||
return json(['code' => 1, 'msg' => '更新成功', 'data' => ['views' => $newViews]]);
|
||||
} catch (\Exception $e) {
|
||||
return json(['code' => 0, 'msg' => '更新失败:' . $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -270,4 +270,75 @@ class IndexController extends BaseController
|
||||
'categories' => $categoryData
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取游戏下载列表
|
||||
*/
|
||||
public function gameList()
|
||||
{
|
||||
// 获取游戏分类(顶级分类id为8的子分类)
|
||||
$categories = ResourcesCategory::where('cid', 8)
|
||||
->where('delete_time', null)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 组装分类数据
|
||||
$categoryData = [];
|
||||
$categoryImageMap = [];
|
||||
$programsByCategory = [];
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$categoryData[] = [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
'image' => $category['image'] ?? ''
|
||||
];
|
||||
|
||||
// 获取每个分类下的游戏,限制8条
|
||||
$programs = Resources::where('cate', $category['id'])
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->order('id', 'desc')
|
||||
->field('id, cate, title, desc, downloads, create_time, icon, views, uploader, number, url, code')
|
||||
->limit(8)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 处理游戏数据
|
||||
foreach ($programs as &$program) {
|
||||
// 如果没有图标,使用分类图片
|
||||
if (empty($program['icon']) && !empty($category['image'])) {
|
||||
$program['icon'] = $category['image'];
|
||||
}
|
||||
// 格式化时间
|
||||
$program['create_time'] = date('Y-m-d H:i:s', $program['create_time']);
|
||||
}
|
||||
unset($program);
|
||||
|
||||
$programsByCategory[$category['id']] = $programs;
|
||||
}
|
||||
|
||||
// 合并所有分类的游戏
|
||||
$allPrograms = [];
|
||||
foreach ($programsByCategory as $programs) {
|
||||
$allPrograms = array_merge($allPrograms, $programs);
|
||||
}
|
||||
|
||||
// 按上传时间排序
|
||||
usort($allPrograms, function($a, $b) {
|
||||
return strtotime($b['create_time']) - strtotime($a['create_time']);
|
||||
});
|
||||
|
||||
// 只取最新的8条
|
||||
$allPrograms = array_slice($allPrograms, 0, 8);
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'games' => $allPrograms,
|
||||
'categories' => $categoryData
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +84,27 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 游戏下载模块 -->
|
||||
<div class="core-block core-module" id="gameDownload" style="order: 3;">
|
||||
<div class="module-header">
|
||||
<div>
|
||||
<div class="ModuleTitle_titleWrapper">
|
||||
<h3 class="ModuleTitle_title">游戏下载</h3>
|
||||
<div class="tab-container">
|
||||
<div class="tab-header">
|
||||
<div class="tab-item active" data-tab="all">全部</div>
|
||||
<!-- 分类标签将通过JavaScript动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-btn">更多</div>
|
||||
</div>
|
||||
<div class="product-list" id="gameDownloadList">
|
||||
<!-- 游戏将通过JavaScript动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@ -204,6 +225,32 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 加载游戏下载
|
||||
function loadGames() {
|
||||
fetch('/index/index/gameList')
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 0) {
|
||||
// 渲染分类标签
|
||||
if (result.data.categories) {
|
||||
renderCategoryTabs(result.data.categories, 'gameDownload');
|
||||
}
|
||||
// 渲染游戏列表
|
||||
if (result.data.games && result.data.games.length > 0) {
|
||||
renderGames(result.data.games, 'gameDownloadList');
|
||||
} else {
|
||||
showNoData('gameDownloadList');
|
||||
}
|
||||
} else {
|
||||
showNoData('gameDownloadList');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
showError('gameDownloadList');
|
||||
});
|
||||
}
|
||||
|
||||
// 显示无数据提示
|
||||
function showNoData(containerId) {
|
||||
document.getElementById(containerId).innerHTML = '<div class="no-data">暂无数据</div>';
|
||||
@ -266,6 +313,9 @@
|
||||
case 'programDownload':
|
||||
loadCategoryPrograms(selectedCategoryId, 'programDownloadList');
|
||||
break;
|
||||
case 'gameDownload':
|
||||
loadCategoryGames(selectedCategoryId, 'gameDownloadList');
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -506,11 +556,70 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 渲染游戏列表
|
||||
function renderGames(games, containerId) {
|
||||
const container = document.getElementById(containerId);
|
||||
if (!container) return;
|
||||
|
||||
let html = '';
|
||||
if (Array.isArray(games)) {
|
||||
games.forEach(game => {
|
||||
html += createGameHtml(game);
|
||||
});
|
||||
}
|
||||
|
||||
container.innerHTML = html || '<div class="no-data">暂无数据</div>';
|
||||
}
|
||||
|
||||
// 创建游戏HTML
|
||||
function createGameHtml(game) {
|
||||
if (!game) return '';
|
||||
|
||||
return `
|
||||
<div class="opencourse product-item" onclick="window.open('/index/game/detail?id=${game.id || ''}', '_blank')">
|
||||
<div class="video">
|
||||
<img src="${game.icon || '/static/images/default-game.png'}" alt="" class="cover">
|
||||
</div>
|
||||
<div class="introduction">
|
||||
<div class="title">${game.title || '无标题'}</div>
|
||||
<div class="publishdate">${game.create_time || ''}</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="views"><i class="fa-solid fa-eye"></i><span style="margin-left: 5px;">${game.views || 0}</span></div>
|
||||
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;">${game.uploader || '未知作者'}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// 加载分类游戏
|
||||
function loadCategoryGames(categoryId, containerId) {
|
||||
fetch('/index/index/gameList')
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 0) {
|
||||
if (categoryId === 'all') {
|
||||
renderGames(result.data.games, containerId);
|
||||
} else {
|
||||
const filteredGames = result.data.games.filter(game => game.cate == categoryId);
|
||||
renderGames(filteredGames, containerId);
|
||||
}
|
||||
} else {
|
||||
showNoData(containerId);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
showError(containerId);
|
||||
});
|
||||
}
|
||||
|
||||
// 页面加载完成后执行
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadWebArticles();
|
||||
loadTechArticles();
|
||||
loadResources();
|
||||
loadPrograms();
|
||||
loadGames();
|
||||
});
|
||||
</script>
|
||||
414
app/index/view/game/detail.php
Normal file
@ -0,0 +1,414 @@
|
||||
{include file="component/head" /}
|
||||
{include file="component/header-simple" /}
|
||||
<div class="main">
|
||||
<div class="location">
|
||||
<div class="container">
|
||||
<div class="location-item">
|
||||
<a href="/">首页</a>
|
||||
<span>></span>
|
||||
<a href="/index/game/list" id="cateLink"><?php echo $cateName; ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="game-detail">
|
||||
<div class="game-info">
|
||||
<div class="game-header">
|
||||
<h1 class="game-title"><?php echo $game['title']; ?></h1>
|
||||
<div class="game-meta">
|
||||
<span class="game-category"><?php echo $cateName; ?></span>
|
||||
<span class="game-views"><i class="fa-solid fa-eye"></i> <?php echo $game['views']; ?> 次浏览</span>
|
||||
<span class="game-downloads"><i class="fa-solid fa-download"></i> <span
|
||||
id="gameDownloads"><?php echo $game['downloads']; ?></span> 次下载</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="game-content">
|
||||
<div class="game-cover">
|
||||
<img src="<?php echo $game['icon'] ?: '/static/images/default-game.png'; ?>"
|
||||
alt="<?php echo $game['title']; ?>">
|
||||
</div>
|
||||
<div class="game-desc">
|
||||
<?php echo $game['content']; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="game-actions">
|
||||
<div style="display: flex;gap: 30px;}">
|
||||
<button id="downloadBtn" class="btn btn-primary">
|
||||
<i class="fa-solid fa-download"></i> 立即下载
|
||||
</button>
|
||||
<button id="codeBtn" class="codebtn">
|
||||
<i class="fa-solid fa-download"></i> 分享码:<?php echo $game['code']; ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 相关游戏 -->
|
||||
<?php if (!empty($relatedGames)): ?>
|
||||
<div class="related-games">
|
||||
<h3>相关游戏</h3>
|
||||
<div class="game-list">
|
||||
<?php foreach ($relatedGames as $related): ?>
|
||||
<div class="game-item"
|
||||
onclick="window.location.href='/index/game/detail?id=<?php echo $related['id']; ?>'">
|
||||
<div class="game-cover">
|
||||
<img src="<?php echo $related['icon'] ?: '/static/images/default-game.png'; ?>"
|
||||
alt="<?php echo $related['title']; ?>">
|
||||
</div>
|
||||
<div class="game-info">
|
||||
<h4 class="game-title"><?php echo $related['title']; ?></h4>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 返回顶部按钮 -->
|
||||
<div class="go-to-top" id="goToTop">
|
||||
<i class="layui-icon layui-icon-top"></i>
|
||||
</div>
|
||||
|
||||
{include file="component/footer" /}
|
||||
|
||||
<script>
|
||||
// 页面加载完成后执行
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// 获取游戏ID
|
||||
const gameId = new URLSearchParams(window.location.search).get('id');
|
||||
if (!gameId) {
|
||||
alert('游戏ID不存在');
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新访问次数
|
||||
updateGameViews(gameId);
|
||||
|
||||
// 下载功能
|
||||
const downloadBtn = document.getElementById('downloadBtn');
|
||||
if (downloadBtn) {
|
||||
downloadBtn.addEventListener('click', function () {
|
||||
fetch('/index/game/downloadurl?id=' + gameId, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 1) {
|
||||
const downloadsElement = document.getElementById('gameDownloads');
|
||||
let downloads = parseInt(downloadsElement.textContent);
|
||||
downloadsElement.textContent = downloads + 1;
|
||||
|
||||
// 直接使用返回的URL
|
||||
if (data.data && data.data.url) {
|
||||
window.location.href = data.data.url;
|
||||
} else {
|
||||
alert('下载地址不存在');
|
||||
}
|
||||
} else {
|
||||
alert('下载失败:' + data.msg);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('下载请求失败:', error);
|
||||
alert('下载请求失败,请稍后重试');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//复制分享码
|
||||
const codeBtn = document.getElementById('codeBtn');
|
||||
if (codeBtn) {
|
||||
codeBtn.addEventListener('click', function() {
|
||||
const code = '{$game.code}';
|
||||
if (code) {
|
||||
// 创建一个临时输入框
|
||||
const tempInput = document.createElement('input');
|
||||
tempInput.value = code;
|
||||
document.body.appendChild(tempInput);
|
||||
tempInput.select();
|
||||
|
||||
try {
|
||||
// 尝试使用传统的复制方法
|
||||
document.execCommand('copy');
|
||||
layer.msg('分享码已复制到剪贴板');
|
||||
} catch (err) {
|
||||
console.error('复制失败:', err);
|
||||
layer.msg('复制失败,请手动复制');
|
||||
} finally {
|
||||
// 移除临时输入框
|
||||
document.body.removeChild(tempInput);
|
||||
}
|
||||
} else {
|
||||
layer.msg('分享码不存在');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 返回顶部功能
|
||||
const goToTop = document.getElementById('goToTop');
|
||||
|
||||
// 监听滚动事件
|
||||
window.addEventListener('scroll', function () {
|
||||
if (window.pageYOffset > 300) {
|
||||
goToTop.classList.add('show');
|
||||
} else {
|
||||
goToTop.classList.remove('show');
|
||||
}
|
||||
});
|
||||
|
||||
// 点击返回顶部
|
||||
goToTop.addEventListener('click', function () {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// 更新游戏访问次数
|
||||
function updateGameViews(gameId) {
|
||||
fetch('/index/game/updateViews', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
},
|
||||
body: 'id=' + gameId
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 1) {
|
||||
const viewsElement = document.querySelector('.game-views');
|
||||
if (viewsElement) {
|
||||
viewsElement.innerHTML = `<i class="fa-solid fa-eye"></i> ${result.data.views} 次浏览`;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('更新访问次数失败:', error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.location {
|
||||
max-width: 1000px;
|
||||
margin: 30px auto;
|
||||
}
|
||||
|
||||
.game-detail {
|
||||
max-width: 1000px;
|
||||
margin: 30px auto;
|
||||
padding: 50px;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.game-header {
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.game-title {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
margin-bottom: 15px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.game-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.game-meta span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.game-meta i {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.game-content {
|
||||
line-height: 1.8;
|
||||
color: #333;
|
||||
font-size: 16px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.game-cover {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.game-cover img {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
object-fit: cover;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.game-desc {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.game-actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 40px;
|
||||
margin: 30px 0;
|
||||
padding: 20px 0;
|
||||
border-top: 1px solid #eee;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.btn {
|
||||
/* background: #f57005; */
|
||||
color: #fff;
|
||||
padding: 15px 30px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
/* background: #e66600; */
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.codebtn{
|
||||
color:#0d6efd;
|
||||
padding: 15px 30px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #0d6efd;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.codebtn:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.related-games {
|
||||
margin: 40px 0;
|
||||
}
|
||||
|
||||
.related-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.game-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.game-item {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
.game-item:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.game-item a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.game-cover img {
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.game-info {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.game-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 5px;
|
||||
color: #333;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.go-to-top {
|
||||
position: fixed;
|
||||
right: 30px;
|
||||
bottom: 30px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #f57005;
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.go-to-top.show {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.go-to-top:hover {
|
||||
background: #e66600;
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.game-title {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.game-list {
|
||||
grid-template-columns: repeat(1, 1fr);
|
||||
}
|
||||
|
||||
.game-meta {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.go-to-top {
|
||||
right: 20px;
|
||||
bottom: 20px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
}
|
||||
|
||||
.location-item a {
|
||||
color: #000 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
{include file="component/foot" /}
|
||||
@ -561,3 +561,8 @@ pre code {
|
||||
color: #212529 !important;
|
||||
border: 1px solid #212529;
|
||||
}
|
||||
|
||||
.program-content img,.game-content img {
|
||||
width: 100%;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
After Width: | Height: | Size: 166 KiB |
|
After Width: | Height: | Size: 166 KiB |
|
After Width: | Height: | Size: 399 KiB |
|
After Width: | Height: | Size: 653 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 433 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 433 KiB |
|
After Width: | Height: | Size: 553 KiB |
|
After Width: | Height: | Size: 586 KiB |
|
After Width: | Height: | Size: 437 KiB |
|
After Width: | Height: | Size: 399 KiB |
|
After Width: | Height: | Size: 653 KiB |
|
After Width: | Height: | Size: 586 KiB |
|
After Width: | Height: | Size: 485 KiB |
|
After Width: | Height: | Size: 166 KiB |
|
After Width: | Height: | Size: 437 KiB |
|
After Width: | Height: | Size: 553 KiB |
|
After Width: | Height: | Size: 305 KiB |
|
After Width: | Height: | Size: 485 KiB |
131
runtime/admin/temp/02890b205219b043551566c44acd91e7.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php /*a:1:{s:49:"E:\Demo\PHP\yunzer\app\admin\view\login\index.php";i:1747586453;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<head>
|
||||
<title>后台管理系统</title>
|
||||
<meta name="renderer" content="yz">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/login.css">
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login">
|
||||
<div class="layadmin-user-login-main">
|
||||
<div class="layadmin-user-login-box layadmin-user-login-header">
|
||||
<img src="/static/images/logo.png" />
|
||||
<h2>后台管理系统</h2>
|
||||
</div>
|
||||
<div class="layadmin-user-login-box layadmin-user-login-body layui-form">
|
||||
<form class="layui-form login-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layadmin-user-login-icon layui-icon layui-icon-username" for="account"></label>
|
||||
<input type="text" id="account" name="account" placeholder="邮箱" class="layui-input"
|
||||
value="">
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layadmin-user-login-icon layui-icon layui-icon-password" for="password"></label>
|
||||
<input type="password" name="password" lay-affix="eye" class="layui-input" placeholder="密码" class="layui-input"
|
||||
value="">
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs7">
|
||||
<label class="layadmin-user-login-icon layui-icon layui-icon-vercode"
|
||||
for="code"></label>
|
||||
<input type="text" name="code" placeholder="图形验证码" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-col-xs5">
|
||||
<div style="margin-left:10px;">
|
||||
<img src="<?php echo captcha_src(); ?>?t=<?php echo time(); ?>" class="layadmin-user-login-codeimg" id="img"
|
||||
onclick="reloadImg()">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" style="margin-bottom: 20px;">
|
||||
<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
|
||||
</div>
|
||||
</form>
|
||||
<div class="layui-form-item">
|
||||
<button class="layui-btn layui-btn-fluid" onclick="login()">登 陆</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer', 'form'], function () {
|
||||
var form = layui.form;
|
||||
layer = layui.layer;
|
||||
$ = layui.jquery;
|
||||
// 用户名控件获取焦点
|
||||
$('#account').focus();
|
||||
// 回车登录
|
||||
$('input').keydown(function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
login();
|
||||
}
|
||||
});
|
||||
});
|
||||
// 重新生成验证码
|
||||
function reloadImg() {
|
||||
var timestamp = new Date().getTime();
|
||||
$('#img').attr('src', '<?php echo captcha_src(); ?>?t=' + timestamp);
|
||||
}
|
||||
|
||||
// 登录处理函数
|
||||
function login() {
|
||||
var account = $('input[name="account"]').val();
|
||||
var password = $('input[name="password"]').val();
|
||||
var code = $('input[name="code"]').val();
|
||||
var remember = $('input[name="remember"]:checked').val();
|
||||
|
||||
if (!account) {
|
||||
layer.msg('邮箱不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!password) {
|
||||
layer.msg('密码不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
layer.msg('验证码不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '<?php echo url("login"); ?>',
|
||||
data: {
|
||||
account: account,
|
||||
password: password,
|
||||
code: code,
|
||||
remember: remember
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, {icon: 1, time: 1000}, function() {
|
||||
window.location.href = '<?php echo url("Index/index"); ?>';
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {icon: 2});
|
||||
reloadImg();
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
layer.msg('网络错误,请重试', {icon: 2});
|
||||
reloadImg();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
568
runtime/admin/temp/3ad2724e5fb71079a54a9e6219360097.php
Normal file
@ -0,0 +1,568 @@
|
||||
<?php /*a:2:{s:52:"E:\Demo\PHP\yunzer\app\admin\view\resources\edit.php";i:1747747200;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo htmlentities((string) $config['admin_name']); ?></title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/moban.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/wangeditor.css" media="all"/>
|
||||
<style type="text/css">
|
||||
.header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
|
||||
.header div{border-bottom:solid 2px #009688;margin-top: 8px;}
|
||||
.header button{float:right;margin-top:-5px;}
|
||||
.pagination {
|
||||
display: inline-block;
|
||||
padding-left: 0;
|
||||
margin: 20px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.pagination > li {
|
||||
display: inline;
|
||||
}
|
||||
.pagination > li > a,
|
||||
.pagination > li > span {
|
||||
position: relative;
|
||||
float: left;
|
||||
padding: 6px 12px;
|
||||
margin-left: -1px;
|
||||
line-height: 1.42857143;
|
||||
color: #337ab7;
|
||||
text-decoration: none;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.pagination > li:first-child > a,
|
||||
.pagination > li:first-child > span {
|
||||
margin-left: 0;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
.pagination > li:last-child > a,
|
||||
.pagination > li:last-child > span {
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
.pagination > li > a:hover,
|
||||
.pagination > li > span:hover,
|
||||
.pagination > li > a:focus,
|
||||
.pagination > li > span:focus {
|
||||
z-index: 2;
|
||||
color: #23527c;
|
||||
background-color: #eee;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.pagination > .active > a,
|
||||
.pagination > .active > span,
|
||||
.pagination > .active > a:hover,
|
||||
.pagination > .active > span:hover,
|
||||
.pagination > .active > a:focus,
|
||||
.pagination > .active > span:focus {
|
||||
z-index: 3;
|
||||
color: #fff;
|
||||
cursor: default;
|
||||
background-color: #337ab7;
|
||||
border-color: #337ab7;
|
||||
}
|
||||
.pagination > .disabled > span,
|
||||
.pagination > .disabled > span:hover,
|
||||
.pagination > .disabled > span:focus,
|
||||
.pagination > .disabled > a,
|
||||
.pagination > .disabled > a:hover,
|
||||
.pagination > .disabled > a:focus {
|
||||
color: #777;
|
||||
cursor: not-allowed;
|
||||
background-color: #fff;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.close-img { background: url(/static/images/close_img.png); background-size: 20px 20px; width:20px; height: 20px; position: absolute; right: 5px; top: 5px; z-index: 2;}
|
||||
</style>
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','form','table','laydate','element','upload'],function(){
|
||||
layer = layui.layer; // layui 弹框
|
||||
form = layui.form; // layui form表单
|
||||
table = layui.table; // layui 表格
|
||||
laydate = layui.laydate; // layui 时间框
|
||||
element = layui.element; // layui element
|
||||
upload = layui.upload; // layui 上传
|
||||
$ = layui.jquery; // layui jquery
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body style="padding:10px; box-sizing: border-box;">
|
||||
<div class="config-container">
|
||||
<div class="config-header" style="display:flex;justify-content: space-between;">
|
||||
<div>
|
||||
<span>编辑资源</span>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="goBack()">
|
||||
<i class="layui-icon layui-icon-return"></i>返回
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form class="layui-form" action="" method="post">
|
||||
<input type="hidden" name="id" value="<?php echo htmlentities((string) (isset($resource['id']) && ($resource['id'] !== '')?$resource['id']:'')); ?>">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="title" required lay-verify="required" placeholder="请输入资源名称" autocomplete="off"
|
||||
class="layui-input" value="<?php echo htmlentities((string) (isset($resource['title']) && ($resource['title'] !== '')?$resource['title']:'')); ?>" lay-affix="clear">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="cate" lay-verify="required" lay-filter="cate">
|
||||
<option value="">请选择分类</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="number" required lay-verify="required" placeholder="请输入分类编号" autocomplete="off"
|
||||
class="layui-input" value="<?php echo htmlentities((string) (isset($resource['number']) && ($resource['number'] !== '')?$resource['number']:'')); ?>" lay-affix="clear" disabled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="desc" placeholder="请输入资源描述" class="layui-textarea" lay-affix="clear"><?php echo htmlentities((string) (isset($resource['desc']) && ($resource['desc'] !== '')?$resource['desc']:'')); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">上传者</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="uploader" required lay-verify="required" placeholder="请输入上传者"
|
||||
autocomplete="off" class="layui-input" value="<?php echo htmlentities((string) (isset($resource['uploader']) && ($resource['uploader'] !== '')?$resource['uploader']:'')); ?>" lay-affix="clear">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源图标</label>
|
||||
<div class="layui-input-block">
|
||||
<button type="button" class="layui-btn" id="upload-btn">
|
||||
<i class="layui-icon layui-icon-upload"></i> 图标上传
|
||||
</button>
|
||||
<div style="width: 120px;">
|
||||
<div class="layui-upload-list">
|
||||
<img class="layui-upload-img" id="upload-img"
|
||||
style="width: 118px; height: 118px;object-fit: cover;">
|
||||
<div id="upload-text"></div>
|
||||
</div>
|
||||
<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="icon-progress">
|
||||
<div class="layui-progress-bar" lay-percent=""></div>
|
||||
</div>
|
||||
<input type="hidden" name="icon" id="icon" value="">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">建议尺寸:128px * 128px</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源文件</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="fileurl" required placeholder="本地资源地址" autocomplete="off"
|
||||
class="layui-input" value="<?php echo htmlentities((string) (isset($resource['fileurl']) && ($resource['fileurl'] !== '')?$resource['fileurl']:'')); ?>" style="margin-bottom: 10px;" lay-affix="clear">
|
||||
<div class="layui-upload-drag" style="display: block;" id="ID-upload-demo-drag">
|
||||
<i class="layui-icon layui-icon-upload"></i>
|
||||
<div>点击上传,或将文件拖拽到此处</div>
|
||||
<div class="layui-hide" id="ID-upload-demo-preview">
|
||||
<hr>
|
||||
<div class="file-info">
|
||||
<i class="layui-icon layui-icon-file"></i>
|
||||
<span class="file-name"></span>
|
||||
<span class="file-size"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="file-progress" style="margin-top: 10px;">
|
||||
<div class="layui-progress-bar" lay-percent=""></div>
|
||||
</div>
|
||||
<input type="hidden" name="file" id="file" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源链接</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="url" required placeholder="百度网盘、115网盘、蓝奏云等" autocomplete="off"
|
||||
class="layui-input" value="<?php echo htmlentities((string) (isset($resource['url']) && ($resource['url'] !== '')?$resource['url']:'')); ?>" lay-affix="clear">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分享码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="code" required placeholder="请输入分享码" autocomplete="off"
|
||||
class="layui-input" value="<?php echo htmlentities((string) (isset($resource['code']) && ($resource['code'] !== '')?$resource['code']:'')); ?>" lay-affix="clear">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="<?php echo htmlentities((string) (isset($resource['sort']) && ($resource['sort'] !== '')?$resource['sort']:'0')); ?>" class="layui-input" placeholder="数字越大越靠前" lay-affix="clear">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">内容</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="editor—wrapper" id="content" name="content" style="border: 1px solid #ccc;">
|
||||
<div id="toolbar-container" style="border-bottom: 1px solid #ccc;"><!-- 工具栏 --></div>
|
||||
<div id="editor-container" style="height: 800px;"><!-- 编辑器 --></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/wangeditor.js"></script>
|
||||
<script>
|
||||
layui.use(['form', 'layer'], function () {
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
var $ = layui.$;
|
||||
var upload = layui.upload;
|
||||
var element = layui.element;
|
||||
|
||||
// 获取资源详情
|
||||
var resourceId = $('input[name="id"]').val();
|
||||
var resourceData = null;
|
||||
|
||||
if (resourceId) {
|
||||
$.get('<?php echo url("resources/get"); ?>', {id: resourceId}, function(res) {
|
||||
if (res.code == 0) {
|
||||
resourceData = res.data;
|
||||
console.log('Resource data:', resourceData); // 调试输出
|
||||
|
||||
// 设置表单值
|
||||
$('input[name="title"]').val(resourceData.title || '');
|
||||
$('select[name="cate"]').val(resourceData.cate || '');
|
||||
form.render('select'); // 重新渲染select以显示选中值
|
||||
$('textarea[name="desc"]').val(resourceData.desc || '');
|
||||
$('input[name="uploader"]').val(resourceData.uploader || '');
|
||||
$('input[name="url"]').val(resourceData.url || '');
|
||||
$('input[name="code"]').val(resourceData.code || '');
|
||||
$('input[name="sort"]').val(resourceData.sort || '0');
|
||||
$('input[name="icon"]').val(resourceData.icon || '');
|
||||
$('input[name="file"]').val(resourceData.file || '');
|
||||
|
||||
// 设置图标预览
|
||||
if (resourceData.icon) {
|
||||
$('#upload-img').attr('src', resourceData.icon);
|
||||
}
|
||||
|
||||
// 设置文件预览
|
||||
if (resourceData.file) {
|
||||
$('#ID-upload-demo-preview').show();
|
||||
$('.file-name').text(resourceData.file_name || '已上传文件');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 图标上传
|
||||
var iconUpload = upload.render({
|
||||
elem: '#upload-btn',
|
||||
url: '<?php echo url("index/upload_img"); ?>',
|
||||
before: function (obj) {
|
||||
obj.preview(function (index, file, result) {
|
||||
$('#upload-img').attr('src', result);
|
||||
});
|
||||
element.progress('icon-progress', '0%');
|
||||
layer.msg('图标上传中', { icon: 16, time: 0 });
|
||||
},
|
||||
done: function (res) {
|
||||
if (res.code > 0) {
|
||||
return layer.msg('图标上传失败');
|
||||
}
|
||||
$('#icon').val(res.data);
|
||||
$('#upload-text').html('');
|
||||
layer.msg('图标上传成功', { icon: 1 });
|
||||
},
|
||||
uploadError: function () {
|
||||
var demoText = $('#upload-text');
|
||||
demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
|
||||
demoText.find('.demo-reload').on('click', function () {
|
||||
iconUpload.upload();
|
||||
});
|
||||
},
|
||||
progress: function (n, elem, e) {
|
||||
element.progress('icon-progress', n + '%');
|
||||
if (n == 100) {
|
||||
layer.msg('图标上传完毕', { icon: 1 });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 文件上传
|
||||
var fileUpload = upload.render({
|
||||
elem: '#ID-upload-demo-drag',
|
||||
url: '<?php echo url("index/upload_file"); ?>',
|
||||
accept: 'file',
|
||||
exts: 'doc|docx|xls|xlsx|ppt|pptx|pdf|txt|zip|rar|7z',
|
||||
before: function (obj) {
|
||||
obj.preview(function (index, file, result) {
|
||||
$('#ID-upload-demo-preview').show();
|
||||
$('.file-name').text(file.name);
|
||||
$('.file-size').text(formatFileSize(file.size));
|
||||
});
|
||||
element.progress('file-progress', '0%');
|
||||
layer.msg('文件上传中', { icon: 16, time: 0 });
|
||||
},
|
||||
done: function (res) {
|
||||
if (res.code > 0) {
|
||||
return layer.msg('文件上传失败');
|
||||
}
|
||||
$('#file').val(res.data.src);
|
||||
$('input[name="fileurl"]').val(res.data.src);
|
||||
layer.msg('文件上传成功', { icon: 1 });
|
||||
},
|
||||
uploadError: function () {
|
||||
layer.msg('文件上传失败', { icon: 2 });
|
||||
},
|
||||
progress: function (n, elem, e) {
|
||||
element.progress('file-progress', n + '%');
|
||||
if (n == 100) {
|
||||
layer.msg('文件上传完毕', { icon: 1 });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 格式化文件大小
|
||||
function formatFileSize(bytes) {
|
||||
if (bytes === 0) return '0 B';
|
||||
const k = 1024;
|
||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
// 获取分类列表
|
||||
$.get('<?php echo url("resources/getcate"); ?>', function (res) {
|
||||
if (res.code == 0) {
|
||||
// 存储分类数据供后续使用
|
||||
window.categoryData = res.data;
|
||||
|
||||
var html = '<option value="">请选择分类</option>';
|
||||
res.data.forEach(function (item) {
|
||||
html += '<option value="' + item.id + '">' + item.name + '</option>';
|
||||
if (item.children && item.children.length > 0) {
|
||||
item.children.forEach(function (child) {
|
||||
html += '<option value="' + child.id + '">├─ ' + child.name + '</option>';
|
||||
});
|
||||
}
|
||||
});
|
||||
$('select[name="cate"]').html(html);
|
||||
|
||||
// 如果有资源数据,设置分类值
|
||||
if (resourceData && resourceData.cate) {
|
||||
console.log('Setting cate value:', resourceData.cate); // 调试输出
|
||||
setTimeout(function() {
|
||||
$('select[name="cate"]').val(resourceData.cate);
|
||||
form.render('select');
|
||||
}, 100);
|
||||
}
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
|
||||
// 监听分类选择变化
|
||||
form.on('select(cate)', function(data) {
|
||||
var selectedId = data.value;
|
||||
if (!selectedId) {
|
||||
$('input[name="number"]').val('');
|
||||
return;
|
||||
}
|
||||
|
||||
// 查找选中的分类信息
|
||||
var parentCategory = null;
|
||||
var childCategory = null;
|
||||
|
||||
window.categoryData.forEach(function(parent) {
|
||||
if (parent.children) {
|
||||
parent.children.forEach(function(child) {
|
||||
if (child.id == selectedId) {
|
||||
parentCategory = parent;
|
||||
childCategory = child;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (parentCategory && childCategory) {
|
||||
// 生成资源编号
|
||||
var total = childCategory.total || 0;
|
||||
// 判断是否是初始化时的分类
|
||||
var isInitialCategory = resourceData && resourceData.cate == selectedId;
|
||||
var nextNumber = isInitialCategory ? total : total + 1;
|
||||
var numberStr = nextNumber.toString().padStart(5, '0');
|
||||
var resourceNumber = parentCategory.number + childCategory.number + numberStr;
|
||||
|
||||
// 设置资源编号
|
||||
$('input[name="number"]').val(resourceNumber);
|
||||
}
|
||||
});
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(formSubmit)', function (data) {
|
||||
// 获取编辑器内容
|
||||
var content = editor.getHtml();
|
||||
var loadIndex = layer.load(2);
|
||||
data.field.content = content;
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo url("resources/edit"); ?>',
|
||||
type: 'POST',
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
layer.close(loadIndex);
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
setTimeout(function () {
|
||||
window.location.href = '<?php echo url("resources/lists"); ?>';
|
||||
}, 1000);
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// 重置按钮点击事件
|
||||
$('button[type="reset"]').on('click', function() {
|
||||
// 重新加载分类列表
|
||||
$.get('<?php echo url("resources/getcate"); ?>', function (res) {
|
||||
if (res.code == 0) {
|
||||
var html = '<option value="">请选择分类</option>';
|
||||
res.data.forEach(function (item) {
|
||||
html += '<option value="' + item.id + '">' + item.name + '</option>';
|
||||
if (item.children && item.children.length > 0) {
|
||||
item.children.forEach(function (child) {
|
||||
html += '<option value="' + child.id + '">├─ ' + child.name + '</option>';
|
||||
});
|
||||
}
|
||||
});
|
||||
$('select[name="cate"]').html(html);
|
||||
|
||||
// 如果有资源数据,设置分类值
|
||||
if (resourceData && resourceData.cate) {
|
||||
setTimeout(function() {
|
||||
$('select[name="cate"]').val(resourceData.cate);
|
||||
form.render('select');
|
||||
}, 100);
|
||||
} else {
|
||||
form.render('select');
|
||||
}
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- wangeditor编辑器脚本 -->
|
||||
<script>
|
||||
const { createEditor, createToolbar } = window.wangEditor
|
||||
|
||||
const editorConfig = {
|
||||
MENU_CONF: {},
|
||||
placeholder: '请输入内容...',
|
||||
onChange(editor) {
|
||||
const html = editor.getHtml()
|
||||
},
|
||||
}
|
||||
|
||||
// 配置图片上传
|
||||
editorConfig.MENU_CONF['uploadImage'] = {
|
||||
server: '<?php echo url("index/upload_img"); ?>',
|
||||
fieldName: 'file',
|
||||
maxFileSize: 10 * 1024 * 1024, // 10M
|
||||
maxNumberOfFiles: 10,
|
||||
allowedFileTypes: ['image/*'],
|
||||
meta: {
|
||||
token: 'xxx'
|
||||
},
|
||||
metaWithUrl: true,
|
||||
headers: {
|
||||
Accept: 'text/x-json'
|
||||
},
|
||||
timeout: 5 * 1000, // 5s
|
||||
|
||||
onBeforeUpload(file) {
|
||||
console.log('准备上传图片', file)
|
||||
return file
|
||||
},
|
||||
onProgress(progress) {
|
||||
console.log('上传进度', progress)
|
||||
},
|
||||
onSuccess(file, res) {
|
||||
console.log('上传成功', file, res)
|
||||
},
|
||||
onFailed(file, res) {
|
||||
layer.msg('上传失败:' + res.msg, { icon: 2 })
|
||||
console.log('上传失败', file, res)
|
||||
},
|
||||
onError(file, err, res) {
|
||||
layer.msg('上传出错:' + err.message, { icon: 2 })
|
||||
console.error('上传出错', file, err, res)
|
||||
},
|
||||
customInsert(res, insertFn) {
|
||||
// res 即服务端的返回结果
|
||||
if (res.code === 0 && res.data) {
|
||||
// 从res.data中获取src字段
|
||||
const url = String(res.data.src || '');
|
||||
if (url) {
|
||||
insertFn(url);
|
||||
} else {
|
||||
layer.msg('图片地址无效', { icon: 2 });
|
||||
}
|
||||
} else {
|
||||
layer.msg('图片上传失败', { icon: 2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const editor = createEditor({
|
||||
selector: '#editor-container',
|
||||
html: `<?php echo (isset($resource['content']) && ($resource['content'] !== '')?$resource['content']:''); ?>`,
|
||||
config: editorConfig,
|
||||
mode: 'default', // or 'simple'
|
||||
})
|
||||
|
||||
const toolbarConfig = {}
|
||||
|
||||
const toolbar = createToolbar({
|
||||
editor,
|
||||
selector: '#toolbar-container',
|
||||
config: toolbarConfig,
|
||||
mode: 'default', // or 'simple'
|
||||
})
|
||||
</script>
|
||||
|
||||
<script>
|
||||
//返回资源列表
|
||||
function goBack() {
|
||||
window.location.href = '<?php echo url("resources/lists"); ?>';
|
||||
}
|
||||
</script>
|
||||
514
runtime/admin/temp/638faa80cf1298b7198f7a359b25bb22.php
Normal file
@ -0,0 +1,514 @@
|
||||
<?php /*a:2:{s:51:"E:\Demo\PHP\yunzer\app\admin\view\resources\add.php";i:1747744873;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo htmlentities((string) $config['admin_name']); ?></title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/moban.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/wangeditor.css" media="all"/>
|
||||
<style type="text/css">
|
||||
.header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
|
||||
.header div{border-bottom:solid 2px #009688;margin-top: 8px;}
|
||||
.header button{float:right;margin-top:-5px;}
|
||||
.pagination {
|
||||
display: inline-block;
|
||||
padding-left: 0;
|
||||
margin: 20px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.pagination > li {
|
||||
display: inline;
|
||||
}
|
||||
.pagination > li > a,
|
||||
.pagination > li > span {
|
||||
position: relative;
|
||||
float: left;
|
||||
padding: 6px 12px;
|
||||
margin-left: -1px;
|
||||
line-height: 1.42857143;
|
||||
color: #337ab7;
|
||||
text-decoration: none;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.pagination > li:first-child > a,
|
||||
.pagination > li:first-child > span {
|
||||
margin-left: 0;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
.pagination > li:last-child > a,
|
||||
.pagination > li:last-child > span {
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
.pagination > li > a:hover,
|
||||
.pagination > li > span:hover,
|
||||
.pagination > li > a:focus,
|
||||
.pagination > li > span:focus {
|
||||
z-index: 2;
|
||||
color: #23527c;
|
||||
background-color: #eee;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.pagination > .active > a,
|
||||
.pagination > .active > span,
|
||||
.pagination > .active > a:hover,
|
||||
.pagination > .active > span:hover,
|
||||
.pagination > .active > a:focus,
|
||||
.pagination > .active > span:focus {
|
||||
z-index: 3;
|
||||
color: #fff;
|
||||
cursor: default;
|
||||
background-color: #337ab7;
|
||||
border-color: #337ab7;
|
||||
}
|
||||
.pagination > .disabled > span,
|
||||
.pagination > .disabled > span:hover,
|
||||
.pagination > .disabled > span:focus,
|
||||
.pagination > .disabled > a,
|
||||
.pagination > .disabled > a:hover,
|
||||
.pagination > .disabled > a:focus {
|
||||
color: #777;
|
||||
cursor: not-allowed;
|
||||
background-color: #fff;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.close-img { background: url(/static/images/close_img.png); background-size: 20px 20px; width:20px; height: 20px; position: absolute; right: 5px; top: 5px; z-index: 2;}
|
||||
</style>
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','form','table','laydate','element','upload'],function(){
|
||||
layer = layui.layer; // layui 弹框
|
||||
form = layui.form; // layui form表单
|
||||
table = layui.table; // layui 表格
|
||||
laydate = layui.laydate; // layui 时间框
|
||||
element = layui.element; // layui element
|
||||
upload = layui.upload; // layui 上传
|
||||
$ = layui.jquery; // layui jquery
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body style="padding:10px; box-sizing: border-box;">
|
||||
<div class="config-container">
|
||||
<div class="config-header" style="display:flex;justify-content: space-between;">
|
||||
<div>
|
||||
<span>添加资源</span>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="goBack()">
|
||||
<i class="layui-icon layui-icon-return"></i>返回
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form class="layui-form" action="" method="post">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="title" required lay-verify="required" placeholder="请输入资源名称" autocomplete="off"
|
||||
class="layui-input" lay-affix="clear">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="cate" lay-verify="required" lay-filter="cate">
|
||||
<option value="">请选择分类</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="number" required lay-verify="required" placeholder="选取分类后系统自动生成" autocomplete="off"
|
||||
class="layui-input" lay-affix="clear" disabled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="desc" placeholder="请输入资源描述" class="layui-textarea" lay-affix="clear"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">上传者</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="uploader" required lay-verify="required" placeholder="请输入上传者"
|
||||
autocomplete="off" class="layui-input" lay-affix="clear" value="<?php echo htmlentities((string) $aUser['name']); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源图标</label>
|
||||
<div class="layui-input-block">
|
||||
<button type="button" class="layui-btn" id="upload-btn">
|
||||
<i class="layui-icon layui-icon-upload"></i> 图标上传
|
||||
</button>
|
||||
<div style="width: 120px;">
|
||||
<div class="layui-upload-list">
|
||||
<img class="layui-upload-img" id="upload-img"
|
||||
style="width: 118px; height: 118px;object-fit: cover;">
|
||||
<div id="upload-text"></div>
|
||||
</div>
|
||||
<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="icon-progress">
|
||||
<div class="layui-progress-bar" lay-percent=""></div>
|
||||
</div>
|
||||
<input type="hidden" name="icon" id="icon" value="">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">建议尺寸:128px * 128px</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源文件</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="fileurl" required placeholder="本地资源地址" autocomplete="off"
|
||||
class="layui-input" value="" style="margin-bottom: 10px;" lay-affix="clear">
|
||||
<div class="layui-upload-drag" style="display: block;" id="ID-upload-demo-drag">
|
||||
<i class="layui-icon layui-icon-upload"></i>
|
||||
<div>点击上传,或将文件拖拽到此处</div>
|
||||
<div class="layui-hide" id="ID-upload-demo-preview">
|
||||
<hr>
|
||||
<div class="file-info">
|
||||
<i class="layui-icon layui-icon-file"></i>
|
||||
<span class="file-name"></span>
|
||||
<span class="file-size"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="file-progress" style="margin-top: 10px;">
|
||||
<div class="layui-progress-bar" lay-percent=""></div>
|
||||
</div>
|
||||
<input type="hidden" name="file" id="file" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">资源链接</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="url" required placeholder="百度网盘、115网盘、蓝奏云等" autocomplete="off"
|
||||
class="layui-input" lay-affix="clear">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分享码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="code" required placeholder="请输入分享码" autocomplete="off"
|
||||
class="layui-input" lay-affix="clear">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="0" class="layui-input" placeholder="数字越大越靠前" lay-affix="clear">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">内容</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="editor—wrapper" id="content" name="content" style="border: 1px solid #ccc;">
|
||||
<div id="toolbar-container" style="border-bottom: 1px solid #ccc;"><!-- 工具栏 --></div>
|
||||
<div id="editor-container" style="height: 800px;"><!-- 编辑器 --></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/wangeditor.js"></script>
|
||||
<script>
|
||||
layui.use(['form', 'layer'], function () {
|
||||
var form = layui.form;
|
||||
var layer = layui.layer;
|
||||
var $ = layui.$;
|
||||
var upload = layui.upload;
|
||||
var element = layui.element;
|
||||
|
||||
// 图标上传
|
||||
var iconUpload = upload.render({
|
||||
elem: '#upload-btn',
|
||||
url: '<?php echo url("index/upload_img"); ?>',
|
||||
before: function (obj) {
|
||||
obj.preview(function (index, file, result) {
|
||||
$('#upload-img').attr('src', result);
|
||||
});
|
||||
element.progress('icon-progress', '0%');
|
||||
layer.msg('图标上传中', { icon: 16, time: 0 });
|
||||
},
|
||||
done: function (res) {
|
||||
if (res.code > 0) {
|
||||
return layer.msg('图标上传失败');
|
||||
}
|
||||
$('#icon').val(res.data);
|
||||
$('#upload-text').html('');
|
||||
layer.msg('图标上传成功', { icon: 1 });
|
||||
},
|
||||
uploadError: function () {
|
||||
var demoText = $('#upload-text');
|
||||
demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
|
||||
demoText.find('.demo-reload').on('click', function () {
|
||||
iconUpload.upload();
|
||||
});
|
||||
},
|
||||
progress: function (n, elem, e) {
|
||||
element.progress('icon-progress', n + '%');
|
||||
if (n == 100) {
|
||||
layer.msg('图标上传完毕', { icon: 1 });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 文件上传
|
||||
var fileUpload = upload.render({
|
||||
elem: '#ID-upload-demo-drag',
|
||||
url: '<?php echo url("index/upload_file"); ?>',
|
||||
accept: 'file',
|
||||
exts: 'doc|docx|xls|xlsx|ppt|pptx|pdf|txt|zip|rar|7z',
|
||||
before: function (obj) {
|
||||
obj.preview(function (index, file, result) {
|
||||
$('#ID-upload-demo-preview').show();
|
||||
$('.file-name').text(file.name);
|
||||
$('.file-size').text(formatFileSize(file.size));
|
||||
});
|
||||
element.progress('file-progress', '0%');
|
||||
layer.msg('文件上传中', { icon: 16, time: 0 });
|
||||
},
|
||||
done: function (res) {
|
||||
if (res.code > 0) {
|
||||
return layer.msg('文件上传失败');
|
||||
}
|
||||
$('#file').val(res.data.src);
|
||||
$('input[name="fileurl"]').val(res.data.src);
|
||||
layer.msg('文件上传成功', { icon: 1 });
|
||||
},
|
||||
uploadError: function () {
|
||||
layer.msg('文件上传失败', { icon: 2 });
|
||||
},
|
||||
progress: function (n, elem, e) {
|
||||
element.progress('file-progress', n + '%');
|
||||
if (n == 100) {
|
||||
layer.msg('文件上传完毕', { icon: 1 });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 格式化文件大小
|
||||
function formatFileSize(bytes) {
|
||||
if (bytes === 0) return '0 B';
|
||||
const k = 1024;
|
||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
// 获取分类列表
|
||||
$.get('<?php echo url("resources/getcate"); ?>', function (res) {
|
||||
if (res.code == 0) {
|
||||
var html = '<option value="">请选择分类</option>';
|
||||
res.data.forEach(function (item) {
|
||||
var disabled = item.cid == 0 ? 'disabled' : '';
|
||||
html += '<option value="' + item.id + '" ' + disabled + '>' + item.name + '</option>';
|
||||
if (item.children && item.children.length > 0) {
|
||||
item.children.forEach(function (child) {
|
||||
html += '<option value="' + child.id + '">├─ ' + child.name + '</option>';
|
||||
});
|
||||
}
|
||||
});
|
||||
$('select[name="cate"]').html(html);
|
||||
form.render('select');
|
||||
|
||||
// 存储分类数据供后续使用
|
||||
window.categoryData = res.data;
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
|
||||
// 监听分类选择变化
|
||||
form.on('select(cate)', function(data) {
|
||||
var selectedId = data.value;
|
||||
if (!selectedId) {
|
||||
$('input[name="number"]').val('');
|
||||
return;
|
||||
}
|
||||
|
||||
// 查找选中的分类信息
|
||||
var parentCategory = null;
|
||||
var childCategory = null;
|
||||
|
||||
window.categoryData.forEach(function(parent) {
|
||||
if (parent.children) {
|
||||
parent.children.forEach(function(child) {
|
||||
if (child.id == selectedId) {
|
||||
parentCategory = parent;
|
||||
childCategory = child;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (parentCategory && childCategory) {
|
||||
// 生成资源编号
|
||||
var total = childCategory.total || 0;
|
||||
var nextNumber = total + 1;
|
||||
var numberStr = nextNumber.toString().padStart(5, '0');
|
||||
var resourceNumber = parentCategory.number + childCategory.number + numberStr;
|
||||
|
||||
// 设置资源编号
|
||||
$('input[name="number"]').val(resourceNumber);
|
||||
}
|
||||
});
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(formSubmit)', function (data) {
|
||||
// 获取编辑器内容
|
||||
var content = editor.getHtml();
|
||||
if (!content || content === '<p><br></p>') {
|
||||
layer.msg('请输入文章内容', { icon: 2 });
|
||||
return false;
|
||||
}
|
||||
|
||||
var loadIndex = layer.load(2);
|
||||
data.field.content = content;
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo url("resources/add"); ?>',
|
||||
type: 'POST',
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
layer.close(loadIndex);
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
setTimeout(function () {
|
||||
window.location.href = '<?php echo url("resources/lists"); ?>';
|
||||
}, 1000);
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// 重置按钮点击事件
|
||||
$('button[type="reset"]').on('click', function() {
|
||||
// 重新加载分类列表
|
||||
$.get('<?php echo url("resources/getcate"); ?>', function (res) {
|
||||
if (res.code == 0) {
|
||||
var html = '<option value="">请选择分类</option>';
|
||||
res.data.forEach(function (item) {
|
||||
var disabled = item.cid == 0 ? 'disabled' : '';
|
||||
html += '<option value="' + item.id + '" ' + disabled + '>' + item.name + '</option>';
|
||||
if (item.children && item.children.length > 0) {
|
||||
item.children.forEach(function (child) {
|
||||
html += '<option value="' + child.id + '">├─ ' + child.name + '</option>';
|
||||
});
|
||||
}
|
||||
});
|
||||
$('select[name="cate"]').html(html);
|
||||
form.render('select');
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- wangeditor编辑器脚本 -->
|
||||
<script>
|
||||
const { createEditor, createToolbar } = window.wangEditor
|
||||
|
||||
const editorConfig = {
|
||||
MENU_CONF: {},
|
||||
placeholder: '请输入内容...',
|
||||
onChange(editor) {
|
||||
const html = editor.getHtml()
|
||||
},
|
||||
}
|
||||
|
||||
// 配置图片上传
|
||||
editorConfig.MENU_CONF['uploadImage'] = {
|
||||
server: '<?php echo url("index/upload_img"); ?>',
|
||||
fieldName: 'file',
|
||||
maxFileSize: 10 * 1024 * 1024, // 10M
|
||||
maxNumberOfFiles: 10,
|
||||
allowedFileTypes: ['image/*'],
|
||||
meta: {
|
||||
token: 'xxx'
|
||||
},
|
||||
metaWithUrl: true,
|
||||
headers: {
|
||||
Accept: 'text/x-json'
|
||||
},
|
||||
timeout: 5 * 1000, // 5s
|
||||
|
||||
onBeforeUpload(file) {
|
||||
console.log('准备上传图片', file)
|
||||
return file
|
||||
},
|
||||
onProgress(progress) {
|
||||
console.log('上传进度', progress)
|
||||
},
|
||||
onSuccess(file, res) {
|
||||
console.log('上传成功', file, res)
|
||||
},
|
||||
onFailed(file, res) {
|
||||
layer.msg('上传失败:' + res.msg, { icon: 2 })
|
||||
console.log('上传失败', file, res)
|
||||
},
|
||||
onError(file, err, res) {
|
||||
layer.msg('上传出错:' + err.message, { icon: 2 })
|
||||
console.error('上传出错', file, err, res)
|
||||
},
|
||||
customInsert(res, insertFn) {
|
||||
// res 即服务端的返回结果
|
||||
if (res.code === 0 && res.data) {
|
||||
// 直接使用res.data作为图片地址
|
||||
insertFn(res.data);
|
||||
} else {
|
||||
layer.msg('图片上传失败', { icon: 2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const editor = createEditor({
|
||||
selector: '#editor-container',
|
||||
html: '<p><br></p>',
|
||||
config: editorConfig,
|
||||
mode: 'default', // or 'simple'
|
||||
})
|
||||
|
||||
const toolbarConfig = {}
|
||||
|
||||
const toolbar = createToolbar({
|
||||
editor,
|
||||
selector: '#toolbar-container',
|
||||
config: toolbarConfig,
|
||||
mode: 'default', // or 'simple'
|
||||
})
|
||||
</script>
|
||||
|
||||
<script>
|
||||
//返回资源列表
|
||||
function goBack() {
|
||||
window.location.href = '<?php echo url("resources/lists"); ?>';
|
||||
}
|
||||
</script>
|
||||
301
runtime/admin/temp/d62c6e06b0a01c1a19438c154e4996b8.php
Normal file
@ -0,0 +1,301 @@
|
||||
<?php /*a:2:{s:53:"E:\Demo\PHP\yunzer\app\admin\view\resources\lists.php";i:1747747324;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo htmlentities((string) $config['admin_name']); ?></title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/moban.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/wangeditor.css" media="all"/>
|
||||
<style type="text/css">
|
||||
.header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
|
||||
.header div{border-bottom:solid 2px #009688;margin-top: 8px;}
|
||||
.header button{float:right;margin-top:-5px;}
|
||||
.pagination {
|
||||
display: inline-block;
|
||||
padding-left: 0;
|
||||
margin: 20px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.pagination > li {
|
||||
display: inline;
|
||||
}
|
||||
.pagination > li > a,
|
||||
.pagination > li > span {
|
||||
position: relative;
|
||||
float: left;
|
||||
padding: 6px 12px;
|
||||
margin-left: -1px;
|
||||
line-height: 1.42857143;
|
||||
color: #337ab7;
|
||||
text-decoration: none;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.pagination > li:first-child > a,
|
||||
.pagination > li:first-child > span {
|
||||
margin-left: 0;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
.pagination > li:last-child > a,
|
||||
.pagination > li:last-child > span {
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
.pagination > li > a:hover,
|
||||
.pagination > li > span:hover,
|
||||
.pagination > li > a:focus,
|
||||
.pagination > li > span:focus {
|
||||
z-index: 2;
|
||||
color: #23527c;
|
||||
background-color: #eee;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.pagination > .active > a,
|
||||
.pagination > .active > span,
|
||||
.pagination > .active > a:hover,
|
||||
.pagination > .active > span:hover,
|
||||
.pagination > .active > a:focus,
|
||||
.pagination > .active > span:focus {
|
||||
z-index: 3;
|
||||
color: #fff;
|
||||
cursor: default;
|
||||
background-color: #337ab7;
|
||||
border-color: #337ab7;
|
||||
}
|
||||
.pagination > .disabled > span,
|
||||
.pagination > .disabled > span:hover,
|
||||
.pagination > .disabled > span:focus,
|
||||
.pagination > .disabled > a,
|
||||
.pagination > .disabled > a:hover,
|
||||
.pagination > .disabled > a:focus {
|
||||
color: #777;
|
||||
cursor: not-allowed;
|
||||
background-color: #fff;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.close-img { background: url(/static/images/close_img.png); background-size: 20px 20px; width:20px; height: 20px; position: absolute; right: 5px; top: 5px; z-index: 2;}
|
||||
</style>
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','form','table','laydate','element','upload'],function(){
|
||||
layer = layui.layer; // layui 弹框
|
||||
form = layui.form; // layui form表单
|
||||
table = layui.table; // layui 表格
|
||||
laydate = layui.laydate; // layui 时间框
|
||||
element = layui.element; // layui element
|
||||
upload = layui.upload; // layui 上传
|
||||
$ = layui.jquery; // layui jquery
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body style="padding:10px; box-sizing: border-box;">
|
||||
<div class="config-container">
|
||||
<!-- 页面头部样式 -->
|
||||
<div class="config-header" style="display: flex;flex-direction: column;flex-wrap: wrap;align-items: flex-start;">
|
||||
<div class="maintitle">
|
||||
<i class="layui-icon layui-icon-file"></i>
|
||||
<span>资源列表</span>
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div class="shaixuan">
|
||||
<label>筛选:</label>
|
||||
<div class="layui-form" style="display: flex; gap: 10px;">
|
||||
<div class="layui-input-inline">
|
||||
<select id="categoryFilter" lay-filter="categoryFilter" lay-verify="">
|
||||
<option value="">全部分类</option>
|
||||
<?php if(is_array($categories) || $categories instanceof \think\Collection || $categories instanceof \think\Paginator): $i = 0; $__LIST__ = $categories;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$category): $mod = ($i % 2 );++$i;?>
|
||||
<optgroup label="<?php echo htmlentities((string) $category['name']); ?>">
|
||||
<?php if(is_array($category['children']) || $category['children'] instanceof \think\Collection || $category['children'] instanceof \think\Paginator): $i = 0; $__LIST__ = $category['children'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$subCategory): $mod = ($i % 2 );++$i;?>
|
||||
<option value="<?php echo htmlentities((string) $subCategory['id']); ?>"><?php echo htmlentities((string) $subCategory['name']); ?></option>
|
||||
<?php endforeach; endif; else: echo "" ;endif; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; endif; else: echo "" ;endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="nameSearch" placeholder="搜索资源名称" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="uploaderSearch" placeholder="搜索上传者" class="layui-input">
|
||||
</div>
|
||||
<button type="button" class="layui-btn layui-btn-normal" onclick="doSearch()">
|
||||
<i class="layui-icon layui-icon-search"></i>搜索
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="doRefresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="layui-btn layui-btn-normal" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加资源
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="resourceTable" lay-filter="resourceTable"></table>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="iconTemplate">
|
||||
{{# if(d.icon){ }}
|
||||
<img src="{{ d.icon }}" style="max-width: 50px; max-height: 50px;">
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="statusTemplate">
|
||||
{{# if(d.status == '0'){ }}
|
||||
<span style="color:red;">未审核</span>
|
||||
{{# } else if(d.status == '1'){ }}
|
||||
<span style="color:green;">已审核</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="operationBar">
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">
|
||||
<i class="layui-icon layui-icon-edit"></i>编辑
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-btn-xs" lay-event="del">
|
||||
<i class="layui-icon layui-icon-delete"></i>删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer', 'form', 'table'], function () {
|
||||
var layer = layui.layer;
|
||||
var $ = layui.jquery;
|
||||
var form = layui.form;
|
||||
var table = layui.table;
|
||||
|
||||
// 初始化表格
|
||||
table.render({
|
||||
elem: '#resourceTable',
|
||||
url: '/admin/resources/lists',
|
||||
method: 'post',
|
||||
cols: [[
|
||||
{ field: 'id', title: 'ID', align: 'center', width: 80 },
|
||||
{ field: 'number', title: '资源编号', width: 100 },
|
||||
{ field: 'title', title: '资源名称' },
|
||||
{ field: 'cate', title: '分类', align: 'center', width: 120 },
|
||||
{ field: 'icon', title: '图标', templet: '#iconTemplate', align: 'center', width: 100 },
|
||||
{ field: 'uploader', title: '上传者', align: 'center', width: 100 },
|
||||
{ field: 'desc', title: '描述', width: 200 },
|
||||
{ field: 'status', title: '状态', templet: '#statusTemplate', align: 'center', width: 80 },
|
||||
{ title: '操作', toolbar: '#operationBar', align: 'center', width: 150, fixed: 'right' }
|
||||
]],
|
||||
page: true,
|
||||
limit: 10,
|
||||
limits: [10, 50, 100],
|
||||
//height: 'full-220'
|
||||
});
|
||||
|
||||
// 监听工具条事件
|
||||
table.on('tool(resourceTable)', function (obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'edit') {
|
||||
edit(data.id);
|
||||
} else if (obj.event === 'del') {
|
||||
del(data.id);
|
||||
}
|
||||
});
|
||||
|
||||
// 监听分类筛选变化
|
||||
form.on('select(categoryFilter)', function (data) {
|
||||
filterByCategory(data.value);
|
||||
});
|
||||
});
|
||||
|
||||
function filterByCategory(categoryId) {
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function doSearch() {
|
||||
var nameKeyword = $('#nameSearch').val().trim();
|
||||
var uploaderKeyword = $('#uploaderSearch').val().trim();
|
||||
|
||||
if (!nameKeyword && !uploaderKeyword && !$('#categoryFilter').val()) {
|
||||
layer.msg('请输入搜索条件', { icon: 0 });
|
||||
return;
|
||||
}
|
||||
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function doRefresh() {
|
||||
// 清空搜索条件
|
||||
$('#nameSearch').val('');
|
||||
$('#uploaderSearch').val('');
|
||||
$('#categoryFilter').val('');
|
||||
layui.form.render('select'); // 重新渲染select
|
||||
|
||||
// 重新加载表格,不带任何筛选条件
|
||||
layui.table.reload('resourceTable', {
|
||||
where: {},
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
|
||||
layer.msg('已重置', { icon: 1 });
|
||||
}
|
||||
|
||||
function reloadTable() {
|
||||
var categoryId = $('#categoryFilter').val();
|
||||
var categoryName = '';
|
||||
if (categoryId) {
|
||||
var selectedOption = $('#categoryFilter option[value="' + categoryId + '"]');
|
||||
if (selectedOption.length > 0) {
|
||||
categoryName = selectedOption.text().trim();
|
||||
}
|
||||
}
|
||||
var nameKeyword = $('#nameSearch').val().trim();
|
||||
var uploaderKeyword = $('#uploaderSearch').val().trim();
|
||||
|
||||
layui.table.reload('resourceTable', {
|
||||
where: {
|
||||
category: categoryName,
|
||||
name: nameKeyword,
|
||||
uploader: uploaderKeyword
|
||||
},
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function add() {
|
||||
window.location.href = '/admin/resources/add';
|
||||
}
|
||||
|
||||
function edit(id) {
|
||||
window.location.href = '/admin/resources/edit?id=' + id;
|
||||
}
|
||||
|
||||
function del(id) {
|
||||
layer.confirm('确定要删除该资源吗?', {
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
$.post('/admin/resources/delete', { id: id }, function (res) {
|
||||
if (res.code == 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
setTimeout(function () {
|
||||
layui.table.reload('resourceTable');
|
||||
}, 1000);
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
layui.table.reload('resourceTable');
|
||||
}
|
||||
</script>
|
||||
627
runtime/admin/temp/eacb1914bea2e2591c82e247de8e4b1a.php
Normal file
@ -0,0 +1,627 @@
|
||||
<?php /*a:2:{s:52:"E:\Demo\PHP\yunzer\app\admin\view\resources\cate.php";i:1747738397;s:51:"E:\Demo\PHP\yunzer\app\admin\view\public\header.php";i:1746890051;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo htmlentities((string) $config['admin_name']); ?></title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/moban.css" media="all"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/wangeditor.css" media="all"/>
|
||||
<style type="text/css">
|
||||
.header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
|
||||
.header div{border-bottom:solid 2px #009688;margin-top: 8px;}
|
||||
.header button{float:right;margin-top:-5px;}
|
||||
.pagination {
|
||||
display: inline-block;
|
||||
padding-left: 0;
|
||||
margin: 20px 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.pagination > li {
|
||||
display: inline;
|
||||
}
|
||||
.pagination > li > a,
|
||||
.pagination > li > span {
|
||||
position: relative;
|
||||
float: left;
|
||||
padding: 6px 12px;
|
||||
margin-left: -1px;
|
||||
line-height: 1.42857143;
|
||||
color: #337ab7;
|
||||
text-decoration: none;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.pagination > li:first-child > a,
|
||||
.pagination > li:first-child > span {
|
||||
margin-left: 0;
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
.pagination > li:last-child > a,
|
||||
.pagination > li:last-child > span {
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
.pagination > li > a:hover,
|
||||
.pagination > li > span:hover,
|
||||
.pagination > li > a:focus,
|
||||
.pagination > li > span:focus {
|
||||
z-index: 2;
|
||||
color: #23527c;
|
||||
background-color: #eee;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.pagination > .active > a,
|
||||
.pagination > .active > span,
|
||||
.pagination > .active > a:hover,
|
||||
.pagination > .active > span:hover,
|
||||
.pagination > .active > a:focus,
|
||||
.pagination > .active > span:focus {
|
||||
z-index: 3;
|
||||
color: #fff;
|
||||
cursor: default;
|
||||
background-color: #337ab7;
|
||||
border-color: #337ab7;
|
||||
}
|
||||
.pagination > .disabled > span,
|
||||
.pagination > .disabled > span:hover,
|
||||
.pagination > .disabled > span:focus,
|
||||
.pagination > .disabled > a,
|
||||
.pagination > .disabled > a:hover,
|
||||
.pagination > .disabled > a:focus {
|
||||
color: #777;
|
||||
cursor: not-allowed;
|
||||
background-color: #fff;
|
||||
border-color: #ddd;
|
||||
}
|
||||
.close-img { background: url(/static/images/close_img.png); background-size: 20px 20px; width:20px; height: 20px; position: absolute; right: 5px; top: 5px; z-index: 2;}
|
||||
</style>
|
||||
<script type="text/javascript" src="/static/layui/layui.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer','form','table','laydate','element','upload'],function(){
|
||||
layer = layui.layer; // layui 弹框
|
||||
form = layui.form; // layui form表单
|
||||
table = layui.table; // layui 表格
|
||||
laydate = layui.laydate; // layui 时间框
|
||||
element = layui.element; // layui element
|
||||
upload = layui.upload; // layui 上传
|
||||
$ = layui.jquery; // layui jquery
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body style="padding:10px; box-sizing: border-box;">
|
||||
<div class="config-container">
|
||||
<!-- 页面头部样式 -->
|
||||
<div class="config-header" style="display: flex;flex-direction: column;flex-wrap: wrap;align-items: flex-start;">
|
||||
<div class="maintitle">
|
||||
<i class="layui-icon layui-icon-app"></i>
|
||||
<span>资源分类管理</span>
|
||||
</div>
|
||||
<div style="display: flex;align-items: flex-start;flex-direction: column;gap: 15px;margin-bottom: 10px;">
|
||||
<div>
|
||||
<button type="button" class="layui-btn layui-btn-normal" onclick="add()">
|
||||
<i class="layui-icon layui-icon-add-1"></i>添加分类
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="refresh()">
|
||||
<i class="layui-icon layui-icon-refresh"></i>刷新
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主要内容区 -->
|
||||
<div class="main-content">
|
||||
<div class="layui-row layui-col-space20">
|
||||
<!-- 左侧分类列表 -->
|
||||
<div class="layui-col-md7">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span>分类列表</span>
|
||||
<small class="text-muted">支持两级分类结构</small>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div id="categoryList" class="category-tree"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧分类信息 -->
|
||||
<div class="layui-col-md5">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span>分类信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<!-- 默认提示 -->
|
||||
<div id="defaultTip" class="empty-tip">
|
||||
<i class="layui-icon layui-icon-face-surprised"></i>
|
||||
<p>请选择左侧分类或点击新增按钮</p>
|
||||
</div>
|
||||
|
||||
<!-- 分类表单 -->
|
||||
<form class="layui-form category-form" lay-filter="categoryForm" style="display: none;">
|
||||
<input type="hidden" name="id" id="categoryId">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="number" required lay-verify="required" placeholder="请输入分类编号"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" required lay-verify="required" placeholder="请输入分类名称"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">父级分类</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="cid" lay-verify="required">
|
||||
<option value="0">顶级分类</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">分类图标</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-upload-drag" id="uploadImage">
|
||||
<i class="layui-icon layui-icon-upload"></i>
|
||||
<p>点击上传或拖拽图片至此处</p>
|
||||
<div class="layui-hide" id="uploadPreview">
|
||||
<hr>
|
||||
<img src="" alt="分类图标" style="max-width: 100%">
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="icon" id="imageInput">
|
||||
<div class="layui-form-mid layui-word-aux">建议尺寸:128px * 128px</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="0" class="layui-input"
|
||||
placeholder="数字越大越靠前">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="status" value="1" title="正常" checked>
|
||||
<input type="radio" name="status" value="0" title="禁用">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item form-actions">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="saveCategory">保存</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
<button type="button" class="layui-btn layui-btn-danger" id="deleteBtn"
|
||||
style="display: none;">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* 页面整体样式 */
|
||||
.config-container {
|
||||
padding: 15px;
|
||||
/* background: #f2f2f2; */
|
||||
}
|
||||
|
||||
.layui-col-md7 .layui-btn-primary {
|
||||
border-color: #d2d2d2;
|
||||
background: 0 0;
|
||||
color: #5f5f5f
|
||||
}
|
||||
|
||||
.layui-col-md7 .layui-btn-primary:hover {
|
||||
background-color: #1e9fff;
|
||||
color: #efefef
|
||||
}
|
||||
|
||||
/* 页面头部样式 */
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
padding: 10px 15px;
|
||||
background: #fff;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.header-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.header-title .layui-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.header-actions .layui-btn {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
/* 主要内容区样式 */
|
||||
.main-content {
|
||||
min-height: calc(100vh - 170px);
|
||||
}
|
||||
|
||||
.layui-card {
|
||||
margin-bottom: 0;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.layui-card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: auto;
|
||||
padding: 12px 15px;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
margin-left: 10px;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 分类树样式 */
|
||||
.category-tree {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.category-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 15px;
|
||||
background-color: #f8f8f8;
|
||||
border-radius: 2px;
|
||||
transition: all 0.3s;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.category-header:hover {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.category-header.active {
|
||||
background-color: #e6f7ff;
|
||||
border-right: 3px solid #1890ff;
|
||||
}
|
||||
|
||||
.category-name {
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.category-actions {
|
||||
/* opacity: 0; */
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.category-header:hover .category-actions {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.category-children {
|
||||
margin-left: 20px;
|
||||
padding-left: 15px;
|
||||
border-left: 1px dashed #e6e6e6;
|
||||
}
|
||||
|
||||
.add-child {
|
||||
padding: 3px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.add-child .layui-icon {
|
||||
font-size: 12px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
/* 空状态提示 */
|
||||
.empty-tip {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px 0;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-tip .layui-icon {
|
||||
font-size: 32px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* 表单样式优化 */
|
||||
.category-form {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.layui-form-label {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.layui-input-block {
|
||||
margin-left: 130px;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.layui-upload-drag {
|
||||
padding: 20px;
|
||||
border: 1px dashed #e2e2e2;
|
||||
background-color: #fff;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layui-upload-drag:hover {
|
||||
border-color: #009688;
|
||||
}
|
||||
|
||||
.layui-upload-drag img {
|
||||
max-width: 100%;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.layui-btn-xs {
|
||||
height: 30px;
|
||||
line-height: 25px;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// 定义全局变量和函数
|
||||
var categoryManager = {
|
||||
init: function () {
|
||||
this.initLayui();
|
||||
},
|
||||
|
||||
initLayui: function () {
|
||||
var that = this;
|
||||
layui.use(['layer', 'form', 'upload'], function () {
|
||||
var layer = layui.layer;
|
||||
var form = layui.form;
|
||||
var upload = layui.upload;
|
||||
var $ = layui.jquery;
|
||||
|
||||
// 初始化分类列表
|
||||
that.initCategoryList = function () {
|
||||
$.ajax({
|
||||
url: '/admin/resources/cate',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
var html = '';
|
||||
res.data.forEach(function (item) {
|
||||
html += that.renderCategory(item);
|
||||
});
|
||||
$('#categoryList').html(html);
|
||||
that.bindEvents();
|
||||
} else {
|
||||
layer.msg('获取分类数据失败', { icon: 2 });
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 渲染分类项
|
||||
that.renderCategory = function (category, level = 0) {
|
||||
var html = '<div class="category-item" data-id="' + category.id + '">';
|
||||
html += '<div class="category-header">';
|
||||
html += '<div class="category-name">' + category.title + '</div>';
|
||||
if (level === 0) {
|
||||
html += '<div class="category-actions">';
|
||||
html += '<button type="button" class="layui-btn layui-btn-primary layui-btn-xs add-child">';
|
||||
html += '<i class="layui-icon layui-icon-add-1"></i>添加子分类</button>';
|
||||
html += '</div>';
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
if (category.children && category.children.length > 0) {
|
||||
html += '<div class="category-children">';
|
||||
category.children.forEach(function (child) {
|
||||
html += that.renderCategory(child, level + 1);
|
||||
});
|
||||
html += '</div>';
|
||||
}
|
||||
html += '</div>';
|
||||
return html;
|
||||
};
|
||||
|
||||
// 绑定事件
|
||||
that.bindEvents = function () {
|
||||
// 点击分类项加载编辑信息
|
||||
$('.category-header').off('click').on('click', function (e) {
|
||||
if (!$(e.target).closest('.add-child').length) {
|
||||
var id = $(this).closest('.category-item').data('id');
|
||||
that.loadCategoryInfo(id);
|
||||
|
||||
// 添加选中效果
|
||||
$('.category-header').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
}
|
||||
});
|
||||
|
||||
// 添加子分类
|
||||
$('.add-child').off('click').on('click', function (e) {
|
||||
e.stopPropagation();
|
||||
var parentId = $(this).closest('.category-item').data('id');
|
||||
that.showCategoryForm(parentId);
|
||||
});
|
||||
};
|
||||
|
||||
// 加载分类信息
|
||||
that.loadCategoryInfo = function (id) {
|
||||
$.get('/admin/resources/cateedit?id=' + id, function (res) {
|
||||
if (res.code === 0) {
|
||||
that.showCategoryForm(0, res.data);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 显示分类表单
|
||||
that.showCategoryForm = function (parentId = 0, data = null) {
|
||||
$('#defaultTip').hide();
|
||||
$('.category-form').show();
|
||||
|
||||
// 重置表单
|
||||
form.val('categoryForm', {
|
||||
id: data ? data.info.id : '',
|
||||
name: data ? data.info.name : '',
|
||||
number: data ? data.info.number : '',
|
||||
cid: data ? data.info.cid : parentId,
|
||||
sort: data ? data.info.sort : 0,
|
||||
status: data ? data.info.status : 1
|
||||
});
|
||||
|
||||
// 更新父级分类选项
|
||||
var $select = $('select[name="cid"]');
|
||||
$select.empty().append('<option value="0">顶级分类</option>');
|
||||
// 获取所有分类作为父级选项
|
||||
$.ajax({
|
||||
url: '/admin/resources/cate',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
// 当前编辑的分类ID
|
||||
var currentId = data ? data.info.id : 0;
|
||||
// 递归构建分类选项
|
||||
function buildOptions(categories, level) {
|
||||
categories.forEach(function (category) {
|
||||
// 不能选择自己或自己的子分类作为父级
|
||||
if (category.id != currentId) {
|
||||
var prefix = new Array(level + 1).join('├─ ');
|
||||
$select.append('<option value="' + category.id + '">' + prefix + category.title + '</option>'); if (category.children && category.children.length > 0) { buildOptions(category.children, level + 1); }
|
||||
}
|
||||
});
|
||||
} buildOptions(res.data, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
// 设置选中的父级分类
|
||||
if (data && data.info.cid) {
|
||||
$select.val(data.info.cid);
|
||||
}
|
||||
|
||||
// 更新图标预览
|
||||
if (data && data.info.icon) {
|
||||
$('#uploadPreview').removeClass('layui-hide').find('img').attr('src', data.info.icon);
|
||||
$('#imageInput').val(data.info.icon);
|
||||
} else {
|
||||
$('#uploadPreview').addClass('layui-hide').find('img').attr('src', '');
|
||||
$('#imageInput').val('');
|
||||
}
|
||||
|
||||
// 显示/隐藏删除按钮
|
||||
$('#deleteBtn')[data ? 'show' : 'hide']();
|
||||
|
||||
form.render();
|
||||
};
|
||||
|
||||
// 初始化上传组件
|
||||
upload.render({
|
||||
elem: '#uploadImage',
|
||||
url: '/admin/upload/image',
|
||||
accept: 'images',
|
||||
acceptMime: 'image/*',
|
||||
done: function (res) {
|
||||
if (res.code === 0) {
|
||||
$('#uploadPreview').removeClass('layui-hide').find('img').attr('src', res.data.url);
|
||||
$('#imageInput').val(res.data.url);
|
||||
layer.msg('上传成功');
|
||||
} else {
|
||||
layer.msg('上传失败');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 监听表单提交
|
||||
form.on('submit(saveCategory)', function (data) {
|
||||
var url = data.field.id ? '/admin/resources/cateedit' : '/admin/resources/cateadd';
|
||||
$.post(url, data.field, function (res) {
|
||||
if (res.code === 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
that.initCategoryList();
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// 监听删除按钮
|
||||
$('#deleteBtn').on('click', function () {
|
||||
var id = $('#categoryId').val();
|
||||
if (!id) return;
|
||||
|
||||
layer.confirm('确定要删除该分类吗?', function (index) {
|
||||
$.post('/admin/resources/catedel', { id: id }, function (res) {
|
||||
if (res.code === 0) {
|
||||
layer.msg(res.msg, { icon: 1 });
|
||||
that.initCategoryList();
|
||||
$('#defaultTip').show();
|
||||
$('.category-form').hide();
|
||||
} else {
|
||||
layer.msg(res.msg, { icon: 2 });
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化页面
|
||||
that.initCategoryList();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化
|
||||
categoryManager.init();
|
||||
|
||||
// 新增分类
|
||||
function add() {
|
||||
categoryManager.showCategoryForm();
|
||||
}
|
||||
|
||||
// 刷新列表
|
||||
function refresh() {
|
||||
categoryManager.initCategoryList();
|
||||
}
|
||||
</script>
|
||||
@ -1,4 +1,4 @@
|
||||
<?php /*a:5:{s:52:"E:\Demo\PHP\yunzer\app\index\view\program\detail.php";i:1747417109;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\head.php";i:1746890051;s:61:"E:\Demo\PHP\yunzer\app\index\view\component\header-simple.php";i:1747415782;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747402501;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\foot.php";i:1746808046;}*/ ?>
|
||||
<?php /*a:5:{s:52:"E:\Demo\PHP\yunzer\app\index\view\program\detail.php";i:1747417109;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\head.php";i:1747649140;s:61:"E:\Demo\PHP\yunzer\app\index\view\component\header-simple.php";i:1747415782;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\foot.php";i:1746808046;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
|
||||
<script src="/static/layui/layui.js" charset="utf-8"></script>
|
||||
<script src="/static/js/bootstrap.bundle.js"></script>
|
||||
<script charset="UTF-8" id="LA_COLLECT" src="//www.yunzer.cn/plugins/js-sdk-pro.min.js"></script>
|
||||
<script>LA.init({ id: "KoyzaWWEcLvPzkQn", ck: "KoyzaWWEcLvPzkQn", autoTrack: true, prefix: 'event' })</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -569,6 +571,10 @@
|
||||
<p class="copyright__text">Copyright <span class="dynamic-year">2025</span> | All Rights By <a
|
||||
href="http://www.yunzer.cn">Yunzer</a></p>
|
||||
</div>
|
||||
<div class="tongji">
|
||||
<script id="LA-DATA-WIDGET" crossorigin="anonymous" charset="UTF-8"
|
||||
src="https://v6-widget.51.la/v6/KoyzaWWEcLvPzkQn/quote.js?theme=#1690FF,#FFFFFF,#999999,#FFFFFF,#FFFFFF,#1690FF,12&f=12"></script>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php /*a:4:{s:49:"E:\Demo\PHP\yunzer\app\index\view\index\index.php";i:1746890051;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\header.php";i:1747416219;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\main.php";i:1747649140;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;}*/ ?>
|
||||
<?php /*a:4:{s:49:"E:\Demo\PHP\yunzer\app\index\view\index\index.php";i:1746890051;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\header.php";i:1747416219;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\main.php";i:1747748380;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@ -536,6 +536,27 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 游戏下载模块 -->
|
||||
<div class="core-block core-module" id="gameDownload" style="order: 3;">
|
||||
<div class="module-header">
|
||||
<div>
|
||||
<div class="ModuleTitle_titleWrapper">
|
||||
<h3 class="ModuleTitle_title">游戏下载</h3>
|
||||
<div class="tab-container">
|
||||
<div class="tab-header">
|
||||
<div class="tab-item active" data-tab="all">全部</div>
|
||||
<!-- 分类标签将通过JavaScript动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-btn">更多</div>
|
||||
</div>
|
||||
<div class="product-list" id="gameDownloadList">
|
||||
<!-- 游戏将通过JavaScript动态加载 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@ -656,6 +677,32 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 加载游戏下载
|
||||
function loadGames() {
|
||||
fetch('/index/index/gameList')
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 0) {
|
||||
// 渲染分类标签
|
||||
if (result.data.categories) {
|
||||
renderCategoryTabs(result.data.categories, 'gameDownload');
|
||||
}
|
||||
// 渲染游戏列表
|
||||
if (result.data.games && result.data.games.length > 0) {
|
||||
renderGames(result.data.games, 'gameDownloadList');
|
||||
} else {
|
||||
showNoData('gameDownloadList');
|
||||
}
|
||||
} else {
|
||||
showNoData('gameDownloadList');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
showError('gameDownloadList');
|
||||
});
|
||||
}
|
||||
|
||||
// 显示无数据提示
|
||||
function showNoData(containerId) {
|
||||
document.getElementById(containerId).innerHTML = '<div class="no-data">暂无数据</div>';
|
||||
@ -718,6 +765,9 @@
|
||||
case 'programDownload':
|
||||
loadCategoryPrograms(selectedCategoryId, 'programDownloadList');
|
||||
break;
|
||||
case 'gameDownload':
|
||||
loadCategoryGames(selectedCategoryId, 'gameDownloadList');
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -958,12 +1008,71 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 渲染游戏列表
|
||||
function renderGames(games, containerId) {
|
||||
const container = document.getElementById(containerId);
|
||||
if (!container) return;
|
||||
|
||||
let html = '';
|
||||
if (Array.isArray(games)) {
|
||||
games.forEach(game => {
|
||||
html += createGameHtml(game);
|
||||
});
|
||||
}
|
||||
|
||||
container.innerHTML = html || '<div class="no-data">暂无数据</div>';
|
||||
}
|
||||
|
||||
// 创建游戏HTML
|
||||
function createGameHtml(game) {
|
||||
if (!game) return '';
|
||||
|
||||
return `
|
||||
<div class="opencourse product-item" onclick="window.open('/index/game/detail?id=${game.id || ''}', '_blank')">
|
||||
<div class="video">
|
||||
<img src="${game.icon || '/static/images/default-game.png'}" alt="" class="cover">
|
||||
</div>
|
||||
<div class="introduction">
|
||||
<div class="title">${game.title || '无标题'}</div>
|
||||
<div class="publishdate">${game.create_time || ''}</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="views"><i class="fa-solid fa-eye"></i><span style="margin-left: 5px;">${game.views || 0}</span></div>
|
||||
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;">${game.uploader || '未知作者'}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// 加载分类游戏
|
||||
function loadCategoryGames(categoryId, containerId) {
|
||||
fetch('/index/index/gameList')
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 0) {
|
||||
if (categoryId === 'all') {
|
||||
renderGames(result.data.games, containerId);
|
||||
} else {
|
||||
const filteredGames = result.data.games.filter(game => game.cate == categoryId);
|
||||
renderGames(filteredGames, containerId);
|
||||
}
|
||||
} else {
|
||||
showNoData(containerId);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('请求失败:', error);
|
||||
showError(containerId);
|
||||
});
|
||||
}
|
||||
|
||||
// 页面加载完成后执行
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadWebArticles();
|
||||
loadTechArticles();
|
||||
loadResources();
|
||||
loadPrograms();
|
||||
loadGames();
|
||||
});
|
||||
</script>
|
||||
<footer class="footer" style="background-image: url(/static/images/footer-bg-1.png)">
|
||||
|
||||
916
runtime/index/temp/c234ae0ebecc67e11e7f6a9e48226fe6.php
Normal file
@ -0,0 +1,916 @@
|
||||
<?php /*a:5:{s:49:"E:\Demo\PHP\yunzer\app\index\view\game\detail.php";i:1747754891;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\head.php";i:1747649140;s:61:"E:\Demo\PHP\yunzer\app\index\view\component\header-simple.php";i:1747415782;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\foot.php";i:1746808046;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo htmlentities((string) $config['admin_name']); ?></title>
|
||||
<link rel="stylesheet" href="/static/layui/css/layui.css">
|
||||
<link rel="stylesheet" href="/static/css/style.css">
|
||||
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/static/css/fontawesome.css">
|
||||
|
||||
<script src="/static/layui/layui.js" charset="utf-8"></script>
|
||||
<script src="/static/js/bootstrap.bundle.js"></script>
|
||||
<script charset="UTF-8" id="LA_COLLECT" src="//www.yunzer.cn/plugins/js-sdk-pro.min.js"></script>
|
||||
<script>LA.init({ id: "KoyzaWWEcLvPzkQn", ck: "KoyzaWWEcLvPzkQn", autoTrack: true, prefix: 'event' })</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="display: flex;flex-direction: column;">
|
||||
<div class="topbar-one">
|
||||
<div class="container">
|
||||
<div style="width: 70%;">
|
||||
<ul class="list-unstyled topbar-one__info">
|
||||
<li class="topbar-one__info__item">
|
||||
<span class="topbar-one__info__icon fas fa-phone-alt" style="margin-right: 10px;"></span>
|
||||
<a href="<?php echo htmlentities((string) $config['admin_phone']); ?>"><?php echo htmlentities((string) $config['admin_phone']); ?></a>
|
||||
</li>
|
||||
<li class="topbar-one__info__item">
|
||||
<span class="topbar-one__info__icon fas fa-envelope" style="margin-right: 10px;"></span>
|
||||
<a href="mailto:<?php echo htmlentities((string) $config['admin_email']); ?>"><?php echo htmlentities((string) $config['admin_email']); ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="topbar-one__social" style="width: 30%;">
|
||||
<a href="/index/user/login" class="mr-10"><i class="layui-icon layui-icon-username"></i> 登录</a>
|
||||
<a href="/index/user/register" class="mr-10"><i class="layui-icon layui-icon-user"></i> 注册</a>
|
||||
<a href="javascript:;" class="qrcode-trigger"><i class="layui-icon layui-icon-qrcode"></i> 公众号</a>
|
||||
<div class="qrcode-popup"
|
||||
style="display:none;position:absolute;right:54px;top:32px;background:#fff;padding:10px;box-shadow:0 0 10px rgba(0,0,0,0.1); z-index: 1000;">
|
||||
<img src="<?php echo htmlentities((string) $config['admin_wechat']); ?>" alt="公众号二维码" style="width:180px;height:180px;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 导航栏 -->
|
||||
<div class="main-menu">
|
||||
<div class="container">
|
||||
<div class="main-menu__logo">
|
||||
<a href="index.html"><img src="/static/images/logo.png" width="186" alt="Logo"></a>
|
||||
</div>
|
||||
<div class="main-menu__nav">
|
||||
<ul class="main-menu__list">
|
||||
<li><a href="/index.html">首页</a></li>
|
||||
<li><a href="/about.html">关于我们</a></li>
|
||||
<li><a href="/products.html">产品服务</a></li>
|
||||
<li><a href="/contact.html">联系我们</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="main-menu__right">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-inline" style="position: relative;">
|
||||
<img src="/static/images/avatar.webp" class="layui-circle"
|
||||
style="width: 40px; height: 40px; cursor: pointer;" id="userAvatarMain">
|
||||
<div class="user-dropdown" id="userDropdownMain">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/index/user/profile"><i
|
||||
class="layui-icon layui-icon-user"></i><span>个人中心</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/index/user/settings"><i
|
||||
class="layui-icon layui-icon-set"></i><span>账号管理</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:;" class="logout-btn"><i
|
||||
class="layui-icon layui-icon-logout"></i><span>退出登录</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 固定导航 -->
|
||||
<div class="sticky-nav" style="display: none;">
|
||||
<div class="container">
|
||||
<div class="sticky-nav__logo">
|
||||
<a href="index.html"><img src="/static/images/logo.png" width="150" alt="Logo"></a>
|
||||
</div>
|
||||
<div class="sticky-nav__menu">
|
||||
<ul>
|
||||
<li><a href="/index.html">首页</a></li>
|
||||
<li><a href="/about.html">关于我们</a></li>
|
||||
<li><a href="/products.html">产品服务</a></li>
|
||||
<li><a href="/contact.html">联系我们</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="sticky-nav__right">
|
||||
<div class="main-menu__right">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-inline" style="position: relative;">
|
||||
<img src="/static/images/avatar.webp" class="layui-circle"
|
||||
style="width: 40px; height: 40px; cursor: pointer;" id="userAvatarSticky">
|
||||
<div class="user-dropdown" id="userDropdownSticky">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/index/user/profile"><i
|
||||
class="layui-icon layui-icon-user"></i><span>个人中心</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/index/user/settings"><i
|
||||
class="layui-icon layui-icon-set"></i><span>账号管理</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:;" class="logout-btn"><i
|
||||
class="layui-icon layui-icon-logout"></i><span>退出登录</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* 用户头像样式 */
|
||||
#userAvatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
#userAvatar:hover {
|
||||
transform: scale(1.05);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* 下拉菜单容器 */
|
||||
.user-dropdown {
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
right: 0;
|
||||
width: 160px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(-10px);
|
||||
transition: all 0.3s ease;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.user-dropdown.show {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
/* 下拉菜单列表 */
|
||||
.user-dropdown ul {
|
||||
margin: 0;
|
||||
padding: 5px 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/* 下拉菜单项 */
|
||||
.user-dropdown li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 下拉菜单链接 */
|
||||
.user-dropdown li a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px 15px;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
/* 下拉菜单图标 */
|
||||
.user-dropdown li a i {
|
||||
margin-right: 10px;
|
||||
font-size: 16px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/* 下拉菜单文字 */
|
||||
.user-dropdown li a span {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* 下拉菜单悬停效果 */
|
||||
.user-dropdown li a:hover {
|
||||
background: #f5f5f5;
|
||||
color: #1E9FFF;
|
||||
}
|
||||
|
||||
.user-dropdown li a:hover i {
|
||||
color: #1E9FFF;
|
||||
}
|
||||
|
||||
/* 分隔线 */
|
||||
.user-dropdown li:not(:last-child) {
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
#userDropdownSticky a {
|
||||
color: #0d6efd !important;
|
||||
}
|
||||
|
||||
/* Banner样式 */
|
||||
.banner-content {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.banner-image {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-image img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center;
|
||||
}
|
||||
|
||||
.banner-text {
|
||||
position: absolute;
|
||||
top: 40%;
|
||||
left: 10%;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.banner-text a {
|
||||
text-decoration: none;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.banner-title {
|
||||
font-size: 4em;
|
||||
font-weight: 600;
|
||||
margin-bottom: 10px;
|
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.banner-desc {
|
||||
font-size: 2em;
|
||||
font-weight: 400;
|
||||
max-width: 800px;
|
||||
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.banner-btn {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.banner-btn:hover {
|
||||
background: #000;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.banner-slider {
|
||||
width: 100%;
|
||||
height: 86vh;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.banner-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-slide {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.banner-slide img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
/* 关键:等比缩放并铺满 */
|
||||
display: block;
|
||||
}
|
||||
|
||||
.layui-carousel {
|
||||
background: #f8f8f8;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 确保轮播容器和项目的高度正确 */
|
||||
#test10,
|
||||
#test10 [carousel-item],
|
||||
#test10 [carousel-item]>* {
|
||||
height: 86vh !important;
|
||||
}
|
||||
|
||||
#test10 [carousel-item]>* {
|
||||
background: none !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
layui.use(['carousel', 'form', 'layer'], function () {
|
||||
var carousel = layui.carousel, form = layui.form, layer = layui.layer, $ = layui.$;
|
||||
|
||||
// 加载banner数据
|
||||
$.ajax({
|
||||
url: '/index/index/bannerlist',
|
||||
type: 'GET',
|
||||
success: function (res) {
|
||||
if (res.code === 1) {
|
||||
var bannerHtml = '';
|
||||
res.banner.forEach(function (banner) {
|
||||
bannerHtml += '<div>' +
|
||||
'<div class="banner-content">' +
|
||||
'<div class="banner-image">' +
|
||||
'<img src="' + banner.image + '" alt="' + (banner.title || '') + '">' +
|
||||
'</div>' +
|
||||
'<div class="banner-text">' +
|
||||
'<span class="banner-title">' + (banner.title || '') + '</span>' +
|
||||
'<span class="banner-desc">' + (banner.desc || '') + '</span>' +
|
||||
'<a href="' + (banner.url || 'javascript:;') + '" class="banner-slide">' +
|
||||
'<span class="banner-btn">查看详情</span>' +
|
||||
'</a>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
});
|
||||
$('#test10 div[carousel-item]').html(bannerHtml);
|
||||
|
||||
// 图片轮播
|
||||
carousel.render({
|
||||
elem: '#test10',
|
||||
width: '100%',
|
||||
height: '100vh',
|
||||
interval: 4000,
|
||||
anim: 'fade',
|
||||
autoplay: true,
|
||||
full: false,
|
||||
arrow: 'hover'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
// 主导航头像
|
||||
$("#userAvatarMain").click(function (e) {
|
||||
e.stopPropagation();
|
||||
$("#userDropdownMain").toggleClass("show");
|
||||
$("#userDropdownSticky").removeClass("show"); // 保证只显示一个
|
||||
});
|
||||
// 固定导航头像
|
||||
$("#userAvatarSticky").click(function (e) {
|
||||
e.stopPropagation();
|
||||
$("#userDropdownSticky").toggleClass("show");
|
||||
$("#userDropdownMain").removeClass("show"); // 保证只显示一个
|
||||
});
|
||||
|
||||
// 点击页面其他地方隐藏所有菜单
|
||||
$(document).click(function (e) {
|
||||
if (!$(e.target).closest('.user-dropdown, #userAvatarMain, #userAvatarSticky').length) {
|
||||
$("#userDropdownMain, #userDropdownSticky").removeClass("show");
|
||||
}
|
||||
});
|
||||
|
||||
// 点击菜单项时隐藏菜单
|
||||
$("#userDropdownMain li a, #userDropdownSticky li a").click(function () {
|
||||
$("#userDropdownMain, #userDropdownSticky").removeClass("show");
|
||||
});
|
||||
});
|
||||
|
||||
// 退出登录
|
||||
$('.logout-btn').on('click', function () {
|
||||
layer.confirm('确定要退出登录吗?', {
|
||||
btn: ['确定', '取消']
|
||||
}, function () {
|
||||
window.location.href = '/index/user/logout';
|
||||
});
|
||||
});
|
||||
|
||||
// 监听滚动事件
|
||||
$(window).scroll(function () {
|
||||
var scrollTop = $(window).scrollTop();
|
||||
if (scrollTop > 150) { // 当滚动超过150px时显示固定导航
|
||||
$('.sticky-nav').fadeIn();
|
||||
} else {
|
||||
$('.sticky-nav').fadeOut();
|
||||
}
|
||||
});
|
||||
|
||||
// 公众号二维码
|
||||
const trigger = document.querySelector('.qrcode-trigger');
|
||||
const popup = document.querySelector('.qrcode-popup');
|
||||
|
||||
// 鼠标移入显示二维码
|
||||
trigger.addEventListener('mouseenter', function () {
|
||||
popup.style.display = 'block';
|
||||
});
|
||||
|
||||
// 鼠标移出隐藏二维码
|
||||
trigger.addEventListener('mouseleave', function () {
|
||||
popup.style.display = 'none';
|
||||
});
|
||||
|
||||
// 鼠标移入二维码区域时保持显示
|
||||
popup.addEventListener('mouseenter', function () {
|
||||
popup.style.display = 'block';
|
||||
});
|
||||
|
||||
// 鼠标移出二维码区域时隐藏
|
||||
popup.addEventListener('mouseleave', function () {
|
||||
popup.style.display = 'none';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<div class="main">
|
||||
<div class="location">
|
||||
<div class="container">
|
||||
<div class="location-item">
|
||||
<a href="/">首页</a>
|
||||
<span>></span>
|
||||
<a href="/index/game/list" id="cateLink"><?php echo $cateName; ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="game-detail">
|
||||
<div class="game-info">
|
||||
<div class="game-header">
|
||||
<h1 class="game-title"><?php echo $game['title']; ?></h1>
|
||||
<div class="game-meta">
|
||||
<span class="game-category"><?php echo $cateName; ?></span>
|
||||
<span class="game-views"><i class="fa-solid fa-eye"></i> <?php echo $game['views']; ?> 次浏览</span>
|
||||
<span class="game-downloads"><i class="fa-solid fa-download"></i> <span
|
||||
id="gameDownloads"><?php echo $game['downloads']; ?></span> 次下载</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="game-content">
|
||||
<div class="game-cover">
|
||||
<img src="<?php echo $game['icon'] ?: '/static/images/default-game.png'; ?>"
|
||||
alt="<?php echo $game['title']; ?>">
|
||||
</div>
|
||||
<div class="game-desc">
|
||||
<?php echo $game['content']; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="game-actions">
|
||||
<div style="display: flex;gap: 30px;}">
|
||||
<button id="downloadBtn" class="btn btn-primary">
|
||||
<i class="fa-solid fa-download"></i> 立即下载
|
||||
</button>
|
||||
<button id="codeBtn" class="codebtn">
|
||||
<i class="fa-solid fa-download"></i> 分享码:<?php echo $game['code']; ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 相关游戏 -->
|
||||
<?php if (!empty($relatedGames)): ?>
|
||||
<div class="related-games">
|
||||
<h3>相关游戏</h3>
|
||||
<div class="game-list">
|
||||
<?php foreach ($relatedGames as $related): ?>
|
||||
<div class="game-item"
|
||||
onclick="window.location.href='/index/game/detail?id=<?php echo $related['id']; ?>'">
|
||||
<div class="game-cover">
|
||||
<img src="<?php echo $related['icon'] ?: '/static/images/default-game.png'; ?>"
|
||||
alt="<?php echo $related['title']; ?>">
|
||||
</div>
|
||||
<div class="game-info">
|
||||
<h4 class="game-title"><?php echo $related['title']; ?></h4>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 返回顶部按钮 -->
|
||||
<div class="go-to-top" id="goToTop">
|
||||
<i class="layui-icon layui-icon-top"></i>
|
||||
</div>
|
||||
|
||||
<footer class="footer" style="background-image: url(/static/images/footer-bg-1.png)">
|
||||
<div class="container">
|
||||
<div class="row" style="width: 100%;">
|
||||
<div class="row-main">
|
||||
<div class="mr-20">
|
||||
<img src="<?php echo htmlentities((string) $config['logo']); ?>" alt="" height="70">
|
||||
<p class="text-white-50 my-4 f18" style="width: 400px;">美天智能科技,这里是介绍!</p>
|
||||
</div>
|
||||
<div style="display: flex; justify-content: space-between;width: 100%;margin-right: 200px;">
|
||||
<div>
|
||||
<h4 class="text-white f-20 font-weight-normal mb-3">关于我们</h4>
|
||||
<ul class="list-unstyled footer-sub-menu">
|
||||
<li><a href="#" class="footer-link">概况</a></li>
|
||||
<li><a href="#" class="footer-link">资讯</a></li>
|
||||
<li><a href="#" class="footer-link">加入我们</a></li>
|
||||
<li><a href="#" class="footer-link">联系我们</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h4 class="text-white f-20 font-weight-normal mb-3">商务合作</h4>
|
||||
<ul class="list-unstyled footer-sub-menu">
|
||||
<li><a href="#" class="footer-link">商务合作</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h4 class="text-white f-20 font-weight-normal mb-3">服务支持</h4>
|
||||
<ul class="list-unstyled footer-sub-menu">
|
||||
<li><a href="#" class="footer-link">常见问答</a></li>
|
||||
<li><a href="#" class="footer-link">软件下载</a></li>
|
||||
<li><a href="#" class="footer-link">服务政策</a></li>
|
||||
<li><a href="#" class="footer-link">投诉建议</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="text-center">
|
||||
<img src="<?php echo htmlentities((string) $config['admin_wechat']); ?>" alt="微信二维码" class="img-fluid" style="max-width: 150px;">
|
||||
<p class="text-white-50 mt-2">微信公众号</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<section class="copyright text-center">
|
||||
<div class="container wow fadeInUp animated" data-wow-delay="400ms"
|
||||
style="visibility: visible; animation-delay: 400ms; animation-name: fadeInUp;">
|
||||
<p class="copyright__text">Copyright <span class="dynamic-year">2025</span> | All Rights By <a
|
||||
href="http://www.yunzer.cn">Yunzer</a></p>
|
||||
</div>
|
||||
<div class="tongji">
|
||||
<script id="LA-DATA-WIDGET" crossorigin="anonymous" charset="UTF-8"
|
||||
src="https://v6-widget.51.la/v6/KoyzaWWEcLvPzkQn/quote.js?theme=#1690FF,#FFFFFF,#999999,#FFFFFF,#FFFFFF,#1690FF,12&f=12"></script>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
// 页面加载完成后执行
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// 获取游戏ID
|
||||
const gameId = new URLSearchParams(window.location.search).get('id');
|
||||
if (!gameId) {
|
||||
alert('游戏ID不存在');
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新访问次数
|
||||
updateGameViews(gameId);
|
||||
|
||||
// 下载功能
|
||||
const downloadBtn = document.getElementById('downloadBtn');
|
||||
if (downloadBtn) {
|
||||
downloadBtn.addEventListener('click', function () {
|
||||
fetch('/index/game/downloadurl?id=' + gameId, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 1) {
|
||||
const downloadsElement = document.getElementById('gameDownloads');
|
||||
let downloads = parseInt(downloadsElement.textContent);
|
||||
downloadsElement.textContent = downloads + 1;
|
||||
|
||||
// 直接使用返回的URL
|
||||
if (data.data && data.data.url) {
|
||||
window.location.href = data.data.url;
|
||||
} else {
|
||||
alert('下载地址不存在');
|
||||
}
|
||||
} else {
|
||||
alert('下载失败:' + data.msg);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('下载请求失败:', error);
|
||||
alert('下载请求失败,请稍后重试');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//复制分享码
|
||||
const codeBtn = document.getElementById('codeBtn');
|
||||
if (codeBtn) {
|
||||
codeBtn.addEventListener('click', function() {
|
||||
const code = '<?php echo htmlentities((string) $game['code']); ?>';
|
||||
if (code) {
|
||||
// 创建一个临时输入框
|
||||
const tempInput = document.createElement('input');
|
||||
tempInput.value = code;
|
||||
document.body.appendChild(tempInput);
|
||||
tempInput.select();
|
||||
|
||||
try {
|
||||
// 尝试使用传统的复制方法
|
||||
document.execCommand('copy');
|
||||
layer.msg('分享码已复制到剪贴板');
|
||||
} catch (err) {
|
||||
console.error('复制失败:', err);
|
||||
layer.msg('复制失败,请手动复制');
|
||||
} finally {
|
||||
// 移除临时输入框
|
||||
document.body.removeChild(tempInput);
|
||||
}
|
||||
} else {
|
||||
layer.msg('分享码不存在');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 返回顶部功能
|
||||
const goToTop = document.getElementById('goToTop');
|
||||
|
||||
// 监听滚动事件
|
||||
window.addEventListener('scroll', function () {
|
||||
if (window.pageYOffset > 300) {
|
||||
goToTop.classList.add('show');
|
||||
} else {
|
||||
goToTop.classList.remove('show');
|
||||
}
|
||||
});
|
||||
|
||||
// 点击返回顶部
|
||||
goToTop.addEventListener('click', function () {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// 更新游戏访问次数
|
||||
function updateGameViews(gameId) {
|
||||
fetch('/index/game/updateViews', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
},
|
||||
body: 'id=' + gameId
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.code === 1) {
|
||||
const viewsElement = document.querySelector('.game-views');
|
||||
if (viewsElement) {
|
||||
viewsElement.innerHTML = `<i class="fa-solid fa-eye"></i> ${result.data.views} 次浏览`;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('更新访问次数失败:', error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.location {
|
||||
max-width: 1000px;
|
||||
margin: 30px auto;
|
||||
}
|
||||
|
||||
.game-detail {
|
||||
max-width: 1000px;
|
||||
margin: 30px auto;
|
||||
padding: 50px;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.game-header {
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.game-title {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
margin-bottom: 15px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.game-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.game-meta span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.game-meta i {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.game-content {
|
||||
line-height: 1.8;
|
||||
color: #333;
|
||||
font-size: 16px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.game-cover {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.game-cover img {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
object-fit: cover;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.game-desc {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.game-actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 40px;
|
||||
margin: 30px 0;
|
||||
padding: 20px 0;
|
||||
border-top: 1px solid #eee;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.btn {
|
||||
/* background: #f57005; */
|
||||
color: #fff;
|
||||
padding: 15px 30px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
/* background: #e66600; */
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.codebtn{
|
||||
color:#0d6efd;
|
||||
padding: 15px 30px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #0d6efd;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.codebtn:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.related-games {
|
||||
margin: 40px 0;
|
||||
}
|
||||
|
||||
.related-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.game-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.game-item {
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
.game-item:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.game-item a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.game-cover img {
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.game-info {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.game-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 5px;
|
||||
color: #333;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.go-to-top {
|
||||
position: fixed;
|
||||
right: 30px;
|
||||
bottom: 30px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #f57005;
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.go-to-top.show {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.go-to-top:hover {
|
||||
background: #e66600;
|
||||
transform: translateY(-3px);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.game-title {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.game-list {
|
||||
grid-template-columns: repeat(1, 1fr);
|
||||
}
|
||||
|
||||
.game-meta {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.go-to-top {
|
||||
right: 20px;
|
||||
bottom: 20px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
}
|
||||
|
||||
.location-item a {
|
||||
color: #000 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||