更新代码

This commit is contained in:
云泽网 2025-05-10 17:33:54 +08:00
parent 426e583fc9
commit b1356231d4
39 changed files with 33089 additions and 9795 deletions

View File

@ -19,11 +19,27 @@ class Article extends Base
->order('id DESC')
->select()
->each(function ($item) {
$item['cate'] = Db::table('yz_article_category')->where('id', $item['cate'])->value('name');
// 获取分类信息
$cateInfo = Db::table('yz_article_category')
->where('id', $item['cate'])
->field('name, image')
->find();
// 设置分类名称
$item['cate'] = $cateInfo['name'];
// 如果文章没有图片,使用分类的图片
if (empty($item['image']) && !empty($cateInfo['image'])) {
$item['image'] = $cateInfo['image'];
}
// 格式化时间
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
$item['publishdate'] = $item['publishdate'] ? date('Y-m-d H:i:s', $item['publishdate']) : '';
return $item;
});
View::assign([
'lists' => $lists
]);
@ -166,6 +182,7 @@ class Article extends Base
'lists' => $lists
]);
return View::fetch();
// return json(['code' => 0, 'msg' => '获取成功', 'data' => $lists]);
}
}
@ -211,6 +228,7 @@ class Article extends Base
$currentDateTime = time();
$data = [
'name' => input('post.name'),
'image' => input('post.image'),
'cid' => input('post.cid'),
'sort' => input('post.sort', 0),
'status' => input('post.status', 1),
@ -244,6 +262,7 @@ class Article extends Base
$data = [
'id' => input('post.id'),
'name' => input('post.name'),
'image' => input('post.image'),
'cid' => input('post.cid'),
'sort' => input('post.sort', 0),
'status' => input('post.status', 1),

View File

@ -19,6 +19,7 @@
<tr>
<th width="20">ID</th>
<th width="120">分类名称</th>
<th width="120">分类图片</th>
<th>描述</th>
<th width="80">排序</th>
<th width="80">状态</th>
@ -32,7 +33,8 @@
<tr>
<td>{$vo.id}</td>
<td>{$vo.name}</td>
<td>{$vo.desc}</td>
<td><img src="{$vo.image}" style="width: 100px;height: auto;"></td>
<td></td>{$vo.desc}</td>
<td>{$vo.sort}</td>
<td>{$vo.status==1?'开启':'<span style="color:red;">禁用</span>'}</td>
<td>{$vo.create_time}</td>
@ -54,6 +56,7 @@
<tr>
<td>{$sub.id}</td>
<td style="padding-left: 30px;">├─ {$sub.name}</td>
<td><img src="{$sub.image}" style="width: 100px;height: auto;"></td>
<td>{$sub.desc}</td>
<td>{$sub.sort}</td>
<td>{$sub.status==1?'开启':'<span style="color:red;">禁用</span>'}</td>
@ -98,7 +101,7 @@
title: '编辑分类',
shadeClose: true,
shade: 0.8,
area: ['500px', '400px'],
area: ['800px', '800px'],
content: '{:url("article/cateedit")}?id=' + id
});
}

View File

@ -2,6 +2,26 @@
<div style="padding: 50px;padding-bottom: 0px;">
<form class="layui-form" action="" method="post">
<input type="hidden" name="id" value="{$info.id}">
<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;" src="{$info.image}">
<div id="upload-text"></div>
</div>
<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="filter-demo">
<div class="layui-progress-bar" lay-percent=""></div>
</div>
<input type="hidden" name="image" id="image" value="{$info.image}">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">分类名称</label>
<div class="layui-input-block">
@ -31,7 +51,8 @@
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
<input type="number" id="sort" name="sort" value="{$info.sort}" placeholder="请输入排序值" class="layui-input">
<input type="number" id="sort" name="sort" value="{$info.sort}" placeholder="请输入排序值"
class="layui-input">
</div>
</div>
@ -44,23 +65,66 @@
</div>
<script>
layui.use(['form', 'layer'], function () {
// 首先定义PHP变量确保类型正确
var currentCid = parseInt('{$info.cid|default=0}'); // 转换为数字
var currentId = parseInt('{$info.id|default=0}'); // 转换为数字
layui.use(['form', 'layer', 'upload', 'element'], function () {
var form = layui.form;
var layer = layui.layer;
var $ = layui.jquery;
var upload = layui.upload;
var element = layui.element;
// 获取URL中的id参数
var urlParams = new URLSearchParams(window.location.search);
var id = urlParams.get('id');
var id = parseInt(urlParams.get('id')) || 0; // 转换为数字
// 图片上传
var uploadInst = upload.render({
elem: '#upload-btn',
url: '{:url("index/upload_img")}',
before: function (obj) {
obj.preview(function (index, file, result) {
$('#upload-img').attr('src', result);
});
element.progress('filter-demo', '0%');
layer.msg('上传中', { icon: 16, time: 0 });
},
done: function (res) {
if (res.code > 0) {
return layer.msg('上传失败');
}
$('#image').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 () {
uploadInst.upload();
});
},
progress: function (n, elem, e) {
element.progress('filter-demo', n + '%');
if (n == 100) {
layer.msg('上传完毕', { icon: 1 });
}
}
});
// 获取分类列表
$.get('{:url("article/getcate")}', function (res) {
if (res.code == 0) {
var html = '<option value="0">顶级分类</option>';
res.data.forEach(function (item) {
// 排除自己及其子分类作为父级选项
if(item.id != id) {
html += '<option value="' + item.id + '"' + (item.id == {$info.cid} ? ' selected' : '') + '>' + item.name + '</option>';
// 确保item.id是数字类型
var itemId = parseInt(item.id);
if (itemId !== id) { // 使用严格比较
html += '<option value="' + itemId + '"' +
(itemId === currentCid ? ' selected' : '') +
'>' + item.name + '</option>';
}
});
$('#cid').html(html);

View File

@ -5,7 +5,7 @@
<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/third/layui/css/layui.css" media="all"/>
<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all"/>
<link rel="stylesheet" type="text/css" href="__CSS__/moban.css" media="all"/>
<link rel="stylesheet" type="text/css" href="__CSS__/wangeditor.css" media="all"/>
<style type="text/css">
@ -78,7 +78,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框

View File

@ -25,17 +25,27 @@ class Index extends Base
$articleList = [];
foreach ($articles as $article) {
$cate = $article['cate'];
$cateName = Db::table('yz_article_category')
// 获取分类信息
$cateInfo = Db::table('yz_article_category')
->where('id', $cate)
->where('delete_time', null)
->where('status', 1)
->value('name');
->field('name, image')
->find();
if ($cateName) { // 只添加有效的分类
if (!isset($articleList[$cateName])) {
$articleList[$cateName] = [];
if ($cateInfo) { // 只添加有效的分类
// 如果文章没有图片,使用分类的图片
if (empty($article['image']) && !empty($cateInfo['image'])) {
$article['image'] = $cateInfo['image'];
}
$articleList[$cateName][] = $article;
// 转换发布日期格式为Y-m-d
$article['publishdate'] = date('Y-m-d', $article['publishdate']);
if (!isset($articleList[$cateInfo['name']])) {
$articleList[$cateInfo['name']] = [];
}
$articleList[$cateInfo['name']][] = $article;
}
}

View File

@ -8,7 +8,10 @@
<link rel="stylesheet" href="__LAYUI__/css/layui.css">
<link rel="stylesheet" href="__CSS__/style.css">
<link rel="stylesheet" href="__CSS__/bootstrap.min.css">
<link rel="stylesheet" href="__CSS__/fontawesome.css">
<script src="__LAYUI__/layui.js" charset="utf-8"></script>
<script src="__JS__/bootstrap.bundle.js"></script>
</head>
<body>

View File

@ -90,20 +90,22 @@
<!-- 全部文章 -->
<div class="tab-content active" data-tab="all">
{foreach $articleList as $cateName => $articles}
{foreach $articles as $article}
<div class="opencourse product-item" onclick="window.open('{:url('article/detail')}?id={$article.id}', '_blank')">
<div class="video">
<img src="{$article.image}" alt="" class="cover">
</div>
<div class="introduction">
<div class="title">{$article.title}</div>
<div class="subtitle">{$article.author}</div>
</div>
<div class="bottom">
<div class="desc">{$article.desc}</div>
</div>
{foreach $articles as $article}
<div class="opencourse product-item"
onclick="window.open('{:url('article/detail')}?id={$article.id}', '_blank')">
<div class="video">
<img src="{$article.image}" alt="" class="cover">
</div>
{/foreach}
<div class="introduction">
<div class="title">{$article.title}</div>
<div class="publishdate">{$article.publishdate}</div>
</div>
<div class="bottom">
<div class="views"><i class="fa-solid fa-eye "></i><span style="margin-left: 5px;">{$article.views}</span></div>
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;">{$article.author}</span></div>
</div>
</div>
{/foreach}
{/foreach}
</div>
@ -111,16 +113,18 @@
{foreach $articleList as $cateName => $articles}
<div class="tab-content" data-tab="{$cateName}">
{foreach $articles as $article}
<div class="opencourse product-item" onclick="window.open('{:url('article/detail')}?id={$article.id}', '_blank')">
<div class="opencourse product-item"
onclick="window.open('{:url('article/detail')}?id={$article.id}', '_blank')">
<div class="video">
<img src="{$article.image}" alt="" class="cover">
</div>
<div class="introduction">
<div class="title">{$article.title}</div>
<div class="subtitle">{$article.author}</div>
<div class="publishdate">{$article.publishdate}</div>
</div>
<div class="bottom">
<div class="desc">{$article.desc}</div>
<div class="views"><i class="fa-solid fa-eye "></i><span style="margin-left: 5px;">{$article.views}</span></div>
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;">{$article.author}</span></div>
</div>
</div>
{/foreach}

View File

@ -8,7 +8,10 @@
<link rel="stylesheet" href="__LAYUI__/css/layui.css">
<link rel="stylesheet" href="__CSS__/style.css">
<link rel="stylesheet" href="__CSS__/bootstrap.min.css">
<link rel="stylesheet" href="__CSS__/fontawesome.css">
<script src="__LAYUI__/layui.js" charset="utf-8"></script>
<script src="__JS__/bootstrap.bundle.js"></script>
</head>
<body>

File diff suppressed because it is too large Load Diff

9
public/static/css/fontawesome.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -266,7 +266,6 @@ body {
/* 轮播动画 */
@keyframes slide {
0%,
33% {
transform: translateX(0);
@ -428,6 +427,8 @@ body {
background: #eee;
border-radius: 8px;
overflow: hidden;
width: 250px;
height: 140px;
}
.video img {
@ -446,13 +447,20 @@ body {
margin: 16px 12px 0 10px;
}
.bottom .desc {
.bottom .desc,
.bottom .author,
.bottom .views,
.publishdate {
font-weight: 400;
color: #b2b2b2;
font-size: 14px;
line-height: 20px;
}
.publishdate {
margin-top: 10px;
}
.bottom .btn {
display: flex;
justify-content: center;
@ -469,14 +477,16 @@ body {
}
.introduction .title {
height:50px;
font-size: 17px;
font-weight: 500;
color: #404040;
line-height: 25px;
transition: color 0.2s ease;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
white-space: nowrap;
}
.introduction .subtitle {
@ -489,4 +499,4 @@ body {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

6315
public/static/js/bootstrap.bundle.js vendored Normal file

File diff suppressed because it is too large Load Diff

4226
public/static/js/bootstrap.bundle.min.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

View File

@ -1,4 +1,4 @@
<?php /*a:3:{s:68:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzertest\icon_list.php";i:1745482530;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1745564348;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1745482530;}*/ ?>
<?php /*a:3:{s:68:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzertest\icon_list.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,8 +6,9 @@
<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/third/layui/css/layui.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;}
@ -78,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框

View File

@ -1,4 +1,4 @@
<?php /*a:3:{s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\index\welcome.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746778404;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
<?php /*a:3:{s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\index\welcome.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,7 +6,7 @@
<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/third/layui/css/layui.css" media="all"/>
<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">
@ -79,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框

View File

@ -1,4 +1,4 @@
<?php /*a:2:{s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\add.php";i:1746782028;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746778404;}*/ ?>
<?php /*a:2:{s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\add.php";i:1746841528;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,7 +6,7 @@
<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/third/layui/css/layui.css" media="all"/>
<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">
@ -79,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框
@ -162,7 +162,7 @@
<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: 500px;"><!-- 编辑器 --></div>
<div id="editor-container" style="height: 800px;"><!-- 编辑器 --></div>
</div>
</div>
</div>
@ -268,9 +268,7 @@
if (res.code == 0) {
layer.msg(res.msg, { icon: 1 });
setTimeout(function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
parent.location.reload();
window.location.href = '<?php echo url("article/articlelist"); ?>';
}, 1000);
} else {
layer.msg(res.msg, { icon: 2 });
@ -279,12 +277,6 @@
});
return false;
});
// 返回上一页
function goBack() {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
}
});
</script>
@ -294,14 +286,63 @@
const { createEditor, createToolbar } = window.wangEditor
const editorConfig = {
MENU_CONF: {},
placeholder: '请输入内容...',
onChange(editor) {
const html = editor.getHtml()
// console.log('editor content', html)
// 也可以同步到 <textarea>
},
}
// 配置图片上传
editorConfig.MENU_CONF['uploadImage'] = {
server: '<?php echo url("index/upload_imgs"); ?>',
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: '<p><br></p>',
@ -317,4 +358,11 @@
config: toolbarConfig,
mode: 'default', // or 'simple'
})
</script>
<script>
//返回文章列表
function goBack() {
window.location.href = '<?php echo url("article/articlelist"); ?>';
}
</script>

View File

@ -1,4 +1,4 @@
<?php /*a:3:{s:65:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\configlist.php";i:1745553686;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1745564348;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1745482530;}*/ ?>
<?php /*a:3:{s:65:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\configlist.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,8 +6,9 @@
<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/third/layui/css/layui.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;}
@ -78,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框

View File

@ -1,4 +1,4 @@
<?php /*a:2:{s:67:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\articlelist.php";i:1746783178;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746778404;}*/ ?>
<?php /*a:2:{s:67:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\articlelist.php";i:1746841528;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,7 +6,7 @@
<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/third/layui/css/layui.css" media="all"/>
<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">
@ -79,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框
@ -163,14 +163,7 @@
}
function edit(id) {
layer.open({
type: 2,
title: '编辑文章',
shadeClose: true,
shade: 0.8,
area: ['800px', '600px'],
content: '<?php echo url("article/edit"); ?>?id=' + id
});
window.location.href = '<?php echo url("article/edit"); ?>?id=' + id;
}
function del(id) {

View File

@ -1,4 +1,4 @@
<?php /*a:2:{s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\cateedit.php";i:1746776155;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746709977;}*/ ?>
<?php /*a:2:{s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\cateedit.php";i:1746861076;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,8 +6,9 @@
<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/third/layui/css/layui.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;}
@ -78,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框
@ -95,6 +96,26 @@
<div style="padding: 50px;padding-bottom: 0px;">
<form class="layui-form" action="" method="post">
<input type="hidden" name="id" value="<?php echo htmlentities((string) $info['id']); ?>">
<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;" src="<?php echo htmlentities((string) $info['image']); ?>">
<div id="upload-text"></div>
</div>
<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="filter-demo">
<div class="layui-progress-bar" lay-percent=""></div>
</div>
<input type="hidden" name="image" id="image" value="<?php echo htmlentities((string) $info['image']); ?>">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">分类名称</label>
<div class="layui-input-block">
@ -124,7 +145,8 @@
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-block">
<input type="number" id="sort" name="sort" value="<?php echo htmlentities((string) $info['sort']); ?>" placeholder="请输入排序值" class="layui-input">
<input type="number" id="sort" name="sort" value="<?php echo htmlentities((string) $info['sort']); ?>" placeholder="请输入排序值"
class="layui-input">
</div>
</div>
@ -137,23 +159,66 @@
</div>
<script>
layui.use(['form', 'layer'], function () {
// 首先定义PHP变量确保类型正确
var currentCid = parseInt('<?php echo htmlentities((string) (isset($info['cid']) && ($info['cid'] !== '')?$info['cid']:0)); ?>'); // 转换为数字
var currentId = parseInt('<?php echo htmlentities((string) (isset($info['id']) && ($info['id'] !== '')?$info['id']:0)); ?>'); // 转换为数字
layui.use(['form', 'layer', 'upload', 'element'], function () {
var form = layui.form;
var layer = layui.layer;
var $ = layui.jquery;
var upload = layui.upload;
var element = layui.element;
// 获取URL中的id参数
var urlParams = new URLSearchParams(window.location.search);
var id = urlParams.get('id');
var id = parseInt(urlParams.get('id')) || 0; // 转换为数字
// 图片上传
var uploadInst = 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('filter-demo', '0%');
layer.msg('上传中', { icon: 16, time: 0 });
},
done: function (res) {
if (res.code > 0) {
return layer.msg('上传失败');
}
$('#image').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 () {
uploadInst.upload();
});
},
progress: function (n, elem, e) {
element.progress('filter-demo', n + '%');
if (n == 100) {
layer.msg('上传完毕', { icon: 1 });
}
}
});
// 获取分类列表
$.get('<?php echo url("article/getcate"); ?>', function (res) {
if (res.code == 0) {
var html = '<option value="0">顶级分类</option>';
res.data.forEach(function (item) {
// 排除自己及其子分类作为父级选项
if(item.id != id) {
html += '<option value="' + item.id + '"' + (item.id == <?php echo htmlentities((string) $info['cid']); ?> ? ' selected' : '') + '>' + item.name + '</option>';
// 确保item.id是数字类型
var itemId = parseInt(item.id);
if (itemId !== id) { // 使用严格比较
html += '<option value="' + itemId + '"' +
(itemId === currentCid ? ' selected' : '') +
'>' + item.name + '</option>';
}
});
$('#cid').html(html);

View File

@ -1,4 +1,4 @@
<?php /*a:3:{s:68:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzeradmin\userinfo.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746709977;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
<?php /*a:3:{s:68:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzeradmin\userinfo.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,8 +6,9 @@
<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/third/layui/css/layui.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;}
@ -78,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框

View File

@ -1,4 +1,4 @@
<?php /*a:3:{s:69:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzeradmin\admininfo.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746709977;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
<?php /*a:3:{s:69:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzeradmin\admininfo.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,8 +6,9 @@
<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/third/layui/css/layui.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;}
@ -78,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框

View File

@ -1,4 +1,4 @@
<?php /*a:2:{s:63:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\cateadd.php";i:1746776163;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746709977;}*/ ?>
<?php /*a:2:{s:63:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\cateadd.php";i:1746776163;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,8 +6,9 @@
<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/third/layui/css/layui.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;}
@ -78,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框

View File

@ -1,4 +1,4 @@
<?php /*a:3:{s:66:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\configvalue.php";i:1745553696;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1745564348;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1745482530;}*/ ?>
<?php /*a:3:{s:66:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\yunzer\configvalue.php";i:1746709977;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\tail.php";i:1746709977;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,8 +6,9 @@
<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/third/layui/css/layui.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;}
@ -78,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框

View File

@ -1,4 +1,4 @@
<?php /*a:2:{s:67:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\articlecate.php";i:1746775555;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746778404;}*/ ?>
<?php /*a:2:{s:67:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\articlecate.php";i:1746861621;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
<!DOCTYPE html>
<html>
<head>
@ -6,7 +6,7 @@
<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/third/layui/css/layui.css" media="all"/>
<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">
@ -79,7 +79,7 @@
}
.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/third/layui/layui.js"></script>
<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 弹框
@ -113,6 +113,7 @@
<tr>
<th width="20">ID</th>
<th width="120">分类名称</th>
<th width="120">分类图片</th>
<th>描述</th>
<th width="80">排序</th>
<th width="80">状态</th>
@ -125,7 +126,8 @@
<tr>
<td><?php echo htmlentities((string) $vo['id']); ?></td>
<td><?php echo htmlentities((string) $vo['name']); ?></td>
<td><?php echo htmlentities((string) $vo['desc']); ?></td>
<td><img src="<?php echo htmlentities((string) $vo['image']); ?>" style="width: 100px;height: auto;"></td>
<td></td><?php echo htmlentities((string) $vo['desc']); ?></td>
<td><?php echo htmlentities((string) $vo['sort']); ?></td>
<td><?php echo $vo['status']==1 ? '开启' : '<span style="color:red;">禁用</span>'; ?></td>
<td><?php echo htmlentities((string) $vo['create_time']); ?></td>
@ -146,6 +148,7 @@
<tr>
<td><?php echo htmlentities((string) $sub['id']); ?></td>
<td style="padding-left: 30px;">├─ <?php echo htmlentities((string) $sub['name']); ?></td>
<td><img src="<?php echo htmlentities((string) $sub['image']); ?>" style="width: 100px;height: auto;"></td>
<td><?php echo htmlentities((string) $sub['desc']); ?></td>
<td><?php echo htmlentities((string) $sub['sort']); ?></td>
<td><?php echo $sub['status']==1 ? '开启' : '<span style="color:red;">禁用</span>'; ?></td>
@ -190,7 +193,7 @@
title: '编辑分类',
shadeClose: true,
shade: 0.8,
area: ['500px', '400px'],
area: ['800px', '800px'],
content: '<?php echo url("article/cateedit"); ?>?id=' + id
});
}

View File

@ -0,0 +1,710 @@
<?php /*a:5:{s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\article\detail.php";i:1746841528;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\head.php";i:1746865131;s:71:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header-simple.php";i:1746841528;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1746709977;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\foot.php";i:1746865126;}*/ ?>
<!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>
</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"></span><a
href="tel:629-555-0129">(629) 555-0129</a></li>
<li class="topbar-one__info__item"><span class="topbar-one__info__icon fas fa-envelope"></span><a
href="mailto:info@example.com">info@example.com</a></li>
</ul>
</div>
<div class="topbar-one__social" style="width: 30%;">
<a href="https://facebook.com"><i class="fab fa-facebook-f"></i></a>
<a href="https://twitter.com"><i class="fab fa-twitter"></i></a>
<a href="https://instagram.com"><i class="fab fa-instagram"></i></a>
<a href="https://www.youtube.com/"><i class="fab fa-linkedin"></i></a>
</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">
<a href="#" class="main-menu__search"><i class="layui-icon layui-icon-search"></i></a>
<a href="login.html" class="main-menu__login"><i class="layui-icon layui-icon-username"></i></a>
</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">
<a href="#" class="main-menu__search"><i class="layui-icon layui-icon-search"></i></a>
<a href="login.html" class="main-menu__login"><i class="layui-icon layui-icon-username"></i></a>
</div>
</div>
</div>
<script>
layui.use(['carousel', 'form'], function () {
var carousel = layui.carousel
, form = layui.form;
//图片轮播
carousel.render({
elem: '#test10'
, width: '100%'
, height: '86vh'
, interval: 4000
});
var $ = layui.$, active = {
set: function (othis) {
var THIS = 'layui-bg-normal'
, key = othis.data('key')
, options = {};
othis.css('background-color', '#5FB878').siblings().removeAttr('style');
options[key] = othis.data('value');
ins3.reload(options);
}
};
//监听开关
form.on('switch(autoplay)', function () {
ins3.reload({
autoplay: this.checked
});
});
$('.demoSet').on('keyup', function () {
var value = this.value
, options = {};
if (!/^\d+$/.test(value)) return;
options[this.name] = value;
ins3.reload(options);
});
// 监听滚动事件
$(window).scroll(function () {
var scrollTop = $(window).scrollTop();
if (scrollTop > 150) { // 当滚动超过150px时显示固定导航
$('.sticky-nav').fadeIn();
} else {
$('.sticky-nav').fadeOut();
}
});
});
</script>
<div class="main">
<div class="location">
<div class="container">
<div class="location-item">
<a href="<?php echo url('index/index/index'); ?>">首页</a>
<span>></span>
<a href="<?php echo url('index/article/index'); ?>">技术文章</a>
</div>
</div>
</div>
<div class="article-detail-container">
<div class="article-header">
<h1 class="article-title"><?php echo htmlentities((string) $article['title']); ?></h1>
<div class="article-meta">
<span class="article-author"><i class="fa fa-user"></i> <?php echo htmlentities((string) $article['author']); ?></span>
<span class="article-date"><i class="fa fa-calendar"></i> <?php echo htmlentities((string) date('Y-m-d H:i',!is_numeric($article['create_time'])? strtotime($article['create_time']) : $article['create_time'])); ?></span>
<span class="article-category"><i class="fa fa-folder"></i> <?php echo htmlentities((string) $cateName); ?></span>
<span class="article-views"><i class="fa fa-eye"></i> <?php echo htmlentities((string) $article['views']); ?> 阅读</span>
</div>
</div>
<div class="article-content">
<?php echo $article['content']; ?>
</div>
<div class="article-tags">
<span class="tag-label">标签:</span>
<?php if(!empty($article['tags'])): foreach($article['tags'] as $tag): ?>
<span class="tag-item"><?php echo htmlentities((string) $tag); ?></span>
<?php endforeach; else: ?>
<span class="no-tags">暂无标签</span>
<?php endif; ?>
</div>
<div class="article-actions">
<div class="action-item like-btn">
<i class="fa fa-thumbs-up"></i>
<span class="action-text">点赞</span>
<span class="action-count"><?php echo htmlentities((string) (isset($article['likes']) && ($article['likes'] !== '')?$article['likes']:0)); ?></span>
</div>
<div class="action-item share-btn">
<i class="fa fa-share-alt"></i>
<span class="action-text">分享</span>
</div>
</div>
<div class="article-navigation">
<div class="prev-article">
<?php if(!empty($prevArticle)): ?>
<a href="<?php echo url('index/article/index', ['id' => $prevArticle['id']]); ?>">
<i class="fa fa-arrow-left"></i> 上一篇:<?php echo htmlentities((string) $prevArticle['title']); ?>
</a>
<?php else: ?>
<span class="disabled"><i class="fa fa-arrow-left"></i> 没有上一篇了</span>
<?php endif; ?>
</div>
<div class="next-article">
<?php if(!empty($nextArticle)): ?>
<a href="<?php echo url('index/article/index', ['id' => $nextArticle['id']]); ?>">
下一篇:<?php echo htmlentities((string) $nextArticle['title']); ?> <i class="fa fa-arrow-right"></i>
</a>
<?php else: ?>
<span class="disabled">没有下一篇了 <i class="fa fa-arrow-right"></i></span>
<?php endif; ?>
</div>
</div>
<div class="related-articles">
<h3 class="related-title">相关推荐</h3>
<div class="related-list">
<?php if(!empty($relatedArticles)): foreach($relatedArticles as $related): ?>
<div class="related-item">
<a href="<?php echo url('index/article/index', ['id' => $related['id']]); ?>">
<div class="related-image">
<img src="<?php echo htmlentities((string) $related['image']); ?>" alt="<?php echo htmlentities((string) $related['title']); ?>">
</div>
<div class="related-info">
<div class="related-item-title"><?php echo htmlentities((string) $related['title']); ?></div>
<div class="related-item-desc"><?php echo htmlentities((string) $related['desc']); ?></div>
</div>
</a>
</div>
<?php endforeach; else: ?>
<div class="no-related">暂无相关文章</div>
<?php endif; ?>
</div>
</div>
<!-- <div class="article-comments">
<h3 class="comments-title">评论区</h3>
<div class="comment-form">
<textarea placeholder="请输入您的评论..." class="comment-textarea"></textarea>
<button class="comment-submit">发表评论</button>
</div>
<div class="comment-list">
<?php if(!empty($comments)): foreach($comments as $comment): ?>
<div class="comment-item">
<div class="comment-avatar">
<img src="<?php echo htmlentities((string) (isset($comment['avatar']) && ($comment['avatar'] !== '')?$comment['avatar']:'/static/images/default-avatar.png')); ?>" alt="用户头像">
</div>
<div class="comment-content">
<div class="comment-user"><?php echo htmlentities((string) $comment['username']); ?></div>
<div class="comment-text"><?php echo htmlentities((string) $comment['content']); ?></div>
<div class="comment-footer">
<span class="comment-time"><?php echo htmlentities((string) date('Y-m-d H:i',!is_numeric($comment['create_time'])? strtotime($comment['create_time']) : $comment['create_time'])); ?></span>
<span class="comment-reply">回复</span>
</div>
</div>
</div>
<?php endforeach; else: ?>
<div class="no-comments">暂无评论,快来抢沙发吧!</div>
<?php endif; ?>
</div>
</div> -->
</div>
</div>
<!-- 返回顶部按钮 -->
<div class="go-to-top" id="goToTop">
<i class="layui-icon-up"></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="/static/images/logo-l-w.png" 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="/static/images/code.png" 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>
</section>
<style>
.location {
max-width: 1000px;
margin: 30px auto;
}
.article-detail-container {
max-width: 1000px;
margin: 30px auto;
padding: 50px;
background: #fff;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
.article-header {
margin-bottom: 30px;
border-bottom: 1px solid #eee;
padding-bottom: 20px;
}
.article-title {
font-size: 28px;
font-weight: 700;
color: #333;
margin-bottom: 15px;
line-height: 1.4;
}
.article-meta {
display: flex;
flex-wrap: wrap;
gap: 20px;
color: #666;
font-size: 14px;
}
.article-meta span {
display: flex;
align-items: center;
}
.article-meta i {
margin-right: 5px;
}
.article-content {
line-height: 1.8;
color: #333;
font-size: 16px;
margin-bottom: 30px;
}
.article-content img {
max-width: 100%;
height: auto;
margin: 15px 0;
border-radius: 4px;
}
.article-tags {
margin: 20px 0;
display: flex;
align-items: center;
flex-wrap: wrap;
}
.tag-label {
font-weight: bold;
margin-right: 10px;
}
.tag-item {
background: #f2f2f2;
padding: 4px 10px;
border-radius: 15px;
font-size: 12px;
margin-right: 8px;
color: #666;
}
.article-actions {
display: flex;
justify-content: center;
gap: 40px;
margin: 30px 0;
padding: 20px 0;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
}
.action-item {
display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
}
.action-item i {
font-size: 24px;
color: #666;
margin-bottom: 5px;
}
.action-text {
font-size: 14px;
color: #666;
}
.action-count {
font-size: 12px;
color: #999;
margin-top: 3px;
}
.article-navigation {
display: flex;
justify-content: space-between;
margin: 30px 0;
}
.prev-article,
.next-article {
max-width: 45%;
}
.prev-article a,
.next-article a {
color: #333;
text-decoration: none;
}
.prev-article a:hover,
.next-article a:hover {
color: #f57005;
}
.disabled {
color: #999;
}
.related-articles {
margin: 40px 0;
}
.related-title {
font-size: 20px;
font-weight: 600;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}
.related-list {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.related-item {
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transition: transform 0.3s;
}
.related-item:hover {
transform: translateY(-5px);
}
.related-item a {
text-decoration: none;
color: inherit;
}
.related-image img {
width: 100%;
height: 150px;
object-fit: cover;
}
.related-info {
padding: 10px;
}
.related-item-title {
font-size: 16px;
font-weight: 600;
margin-bottom: 5px;
color: #333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.related-item-desc {
font-size: 12px;
color: #666;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.article-comments {
margin-top: 40px;
}
.comments-title {
font-size: 20px;
font-weight: 600;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}
.comment-form {
margin-bottom: 30px;
}
.comment-textarea {
width: 100%;
height: 100px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
resize: none;
margin-bottom: 10px;
}
.comment-submit {
background: #f57005;
color: white;
border: none;
padding: 8px 20px;
border-radius: 4px;
cursor: pointer;
float: right;
}
.comment-item {
display: flex;
margin-bottom: 20px;
padding-bottom: 20px;
border-bottom: 1px solid #eee;
}
.comment-avatar img {
width: 50px;
height: 50px;
border-radius: 50%;
margin-right: 15px;
}
.comment-content {
flex: 1;
}
.comment-user {
font-weight: 600;
margin-bottom: 5px;
}
.comment-text {
line-height: 1.6;
margin-bottom: 10px;
}
.comment-footer {
display: flex;
justify-content: space-between;
color: #999;
font-size: 12px;
}
.comment-reply {
cursor: pointer;
color: #f57005;
}
.no-comments,
.no-related,
.no-tags {
color: #999;
text-align: center;
padding: 20px;
}
@media (max-width: 768px) {
.article-title {
font-size: 24px;
}
.related-list {
grid-template-columns: repeat(1, 1fr);
}
.article-meta {
gap: 10px;
}
}
/* 返回顶部按钮样式 */
.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);
}
.go-to-top i {
font-size: 18px;
}
@media (max-width: 768px) {
.go-to-top {
right: 20px;
bottom: 20px;
width: 36px;
height: 36px;
}
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function () {
// 点赞功能
const likeBtn = document.querySelector('.like-btn');
if (likeBtn) {
likeBtn.addEventListener('click', function () {
const articleId = '<?php echo htmlentities((string) $article['id']); ?>';
fetch('/index/article/like?id=' + articleId, {
method: 'POST'
})
.then(response => response.json())
.then(data => {
if (data.code === 1) {
const countElement = this.querySelector('.action-count');
let count = parseInt(countElement.textContent);
countElement.textContent = count + 1;
this.classList.add('liked');
this.style.color = '#f57005';
} else {
alert('点赞失败:' + data.msg);
}
})
.catch(error => {
console.error('点赞请求失败:', error);
});
});
}
// 返回顶部功能
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'
});
});
});
</script>
</body>
</html>

View File

@ -1,4 +1,4 @@
<?php /*a:4:{s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\index\index.php";i:1746709977;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header.php";i:1746709977;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\main.php";i:1746709977;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1746709977;}*/ ?>
<?php /*a:4:{s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\index\index.php";i:1746865108;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header.php";i:1746709977;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\main.php";i:1746868512;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1746709977;}*/ ?>
<!DOCTYPE html>
<html>
@ -9,7 +9,10 @@
<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>
</head>
<body>
@ -247,13 +250,13 @@ layui.use(['carousel', 'form'], function(){
<div class="module-header">
<div>
<div class="ModuleTitle_titleWrapper">
<h3 class="ModuleTitle_title">公开课</h3>
<h3 class="ModuleTitle_title">技术文章</h3>
<div class="tab-container">
<div class="tab-header">
<div class="tab-item active" data-tab="all">全部</div>
<div class="tab-item" data-tab="frontend">前端</div>
<div class="tab-item" data-tab="backend">后端</div>
<div class="tab-item" data-tab="mobile">移动端</div>
<?php foreach($articleList as $cateName => $articles): ?>
<div class="tab-item" data-tab="<?php echo htmlentities((string) $cateName); ?>"><?php echo htmlentities((string) $cateName); ?></div>
<?php endforeach; ?>
</div>
</div>
</div>
@ -261,68 +264,48 @@ layui.use(['carousel', 'form'], function(){
<div class="more-btn">更多</div>
</div>
<div class="product-list">
<!-- 全部课程 -->
<!-- 全部文章 -->
<div class="tab-content active" data-tab="all">
<!-- 原有的课程列表内容 -->
<div class="opencourse product-item">
<!-- ... 原有内容 ... -->
</div>
<!-- ... 其他课程项 ... -->
</div>
<!-- 前端课程 -->
<div class="tab-content" data-tab="frontend">
<div class="opencourse product-item">
<?php foreach($articleList as $cateName => $articles): foreach($articles as $article): ?>
<div class="opencourse product-item"
onclick="window.open('<?php echo url('article/detail'); ?>?id=<?php echo htmlentities((string) $article['id']); ?>', '_blank')">
<div class="video">
<img src="https://static001.geekbang.org/resource/image/ff/b8/ff18d73bec1040abf3d7bc7bffb532b8.jpg?x-oss-process=image/resize,w_423,h_238/format,webp"
alt="" class="cover">
<img src="<?php echo htmlentities((string) $article['image']); ?>" alt="" class="cover">
</div>
<div class="introduction">
<div class="title">Vue.js 实战教程</div>
<div class="subtitle">张老师 | 资深前端工程师</div>
<div class="title"><?php echo htmlentities((string) $article['title']); ?></div>
<div class="publishdate"><?php echo htmlentities((string) $article['publishdate']); ?></div>
</div>
<div class="bottom">
<div class="desc">2.5w人学过</div>
<div class="views"><i class="fa-solid fa-eye "></i><span style="margin-left: 5px;"><?php echo htmlentities((string) $article['views']); ?></span></div>
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;"><?php echo htmlentities((string) $article['author']); ?></span></div>
</div>
</div>
<!-- 可以添加更多前端课程 -->
<?php endforeach; ?>
<?php endforeach; ?>
</div>
<!-- 后端课程 -->
<div class="tab-content" data-tab="backend">
<div class="opencourse product-item">
<!-- 分类文章 -->
<?php foreach($articleList as $cateName => $articles): ?>
<div class="tab-content" data-tab="<?php echo htmlentities((string) $cateName); ?>">
<?php foreach($articles as $article): ?>
<div class="opencourse product-item"
onclick="window.open('<?php echo url('article/detail'); ?>?id=<?php echo htmlentities((string) $article['id']); ?>', '_blank')">
<div class="video">
<img src="https://static001.geekbang.org/resource/image/76/cd/762ee7f34a76fbff61d20aae313833cd.jpg?x-oss-process=image/resize,w_423,h_238/format,webp"
alt="" class="cover">
<img src="<?php echo htmlentities((string) $article['image']); ?>" alt="" class="cover">
</div>
<div class="introduction">
<div class="title">PHP高级开发实战</div>
<div class="subtitle">李老师 | 资深后端工程师</div>
<div class="title"><?php echo htmlentities((string) $article['title']); ?></div>
<div class="publishdate"><?php echo htmlentities((string) $article['publishdate']); ?></div>
</div>
<div class="bottom">
<div class="desc">1.8w人学过</div>
<div class="views"><i class="fa-solid fa-eye "></i><span style="margin-left: 5px;"><?php echo htmlentities((string) $article['views']); ?></span></div>
<div class="author"><i class="fa-regular fa-user"></i><span style="margin-left: 5px;"><?php echo htmlentities((string) $article['author']); ?></span></div>
</div>
</div>
<!-- 可以添加更多后端课程 -->
</div>
<!-- 移动端课程 -->
<div class="tab-content" data-tab="mobile">
<div class="opencourse product-item">
<div class="video">
<img src="https://static001.geekbang.org/resource/image/0f/69/0f95b62cf7yy6d6yy674f090d063b669.jpg?x-oss-process=image/resize,w_423,h_238/format,webp"
alt="" class="cover">
</div>
<div class="introduction">
<div class="title">Flutter跨平台开发</div>
<div class="subtitle">王老师 | 移动端架构师</div>
</div>
<div class="bottom">
<div class="desc">1.2w人学过</div>
</div>
</div>
<!-- 可以添加更多移动端课程 -->
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
</div>
@ -361,6 +344,7 @@ layui.use(['carousel', 'form'], function(){
});
});
});
</script>
</script>
<footer class="footer" style="background-image: url(/static/images/footer-bg-1.png)">
<div class="container">