From 205343674a39af4a69c9b7ca93618ff04b66c0d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E6=B3=BD=E7=BD=91?= <”357099073@qq.com“> Date: Wed, 28 May 2025 00:41:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=81=9A=E6=96=87=E7=AB=A0=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/ArticlesController.php | 183 +++++- app/index/controller/GameController.php | 169 +++++- app/index/controller/ProgramController.php | 143 ++++- app/index/controller/UserController.php | 59 ++ app/index/view/articles/index.php | 539 ++++++++++++++++++ app/index/view/articles/list.php | 76 +++ app/index/view/component/main.php | 10 +- app/index/view/game/index.php | 539 ++++++++++++++++++ app/index/view/game/list.php | 76 +++ app/index/view/program/index.php | 535 +++++++++++++++++ app/index/view/program/list.php | 261 +++++++++ app/index/view/user/component/security.php | 11 - .../temp/402d23cdf323169a38fb26d3649b6ad5.php | 414 ++++++++++---- .../temp/69170ce622adbb0032543cdbee52d3fd.php | 89 +-- 14 files changed, 2895 insertions(+), 209 deletions(-) create mode 100644 app/index/view/articles/index.php create mode 100644 app/index/view/articles/list.php create mode 100644 app/index/view/game/index.php create mode 100644 app/index/view/game/list.php create mode 100644 app/index/view/program/index.php create mode 100644 app/index/view/program/list.php diff --git a/app/index/controller/ArticlesController.php b/app/index/controller/ArticlesController.php index 91b65d5..969da2a 100644 --- a/app/index/controller/ArticlesController.php +++ b/app/index/controller/ArticlesController.php @@ -12,6 +12,120 @@ use app\index\model\Articles\ArticlesCategory; class ArticlesController extends BaseController { + //文章中心 + public function index() + { + // 获取前端传来的分类ID + $cateid = input('cateid/d', 0); // 使用input助手函数获取参数,并转换为整数 + $page = input('page/d', 1); + $limit = input('limit/d', 10); + + // 获取所有顶级分类 + $categories = ArticlesCategory::where('cid', 0) + ->where('delete_time', null) + ->where('status', 1) + ->select() + ->toArray(); + + // 获取顶级分类信息 + $category = null; + if ($cateid > 0) { + $category = ArticlesCategory::where('id', $cateid) + ->where('delete_time', null) + ->where('status', 1) + ->find(); + } + + // 获取所有子分类 + $subCategories = []; + if ($cateid > 0) { + $subCategories = ArticlesCategory::where('cid', $cateid) + ->where('delete_time', null) + ->where('status', 1) + ->select() + ->toArray(); + } + + // 获取所有子分类ID + $subCategoryIds = array_column($subCategories, 'id'); + if ($cateid > 0) { + $subCategoryIds[] = $cateid; + } + + // 构建文章查询条件 + $where = [ + ['delete_time', '=', null], + ['status', '=', 2] + ]; + + if (!empty($subCategoryIds)) { + $where[] = ['cate', 'in', $subCategoryIds]; + } + + // 查询文章 + $articles = Articles::where($where) + ->order('id DESC') + ->page($page, $limit) + ->select() + ->toArray(); + + // 按子分类分组文章 + $groupedArticles = []; + foreach ($subCategories as $subCategory) { + $groupedArticles[$subCategory['id']] = [ + 'id' => $subCategory['id'], + 'name' => $subCategory['name'], + 'desc' => $subCategory['desc'], + 'image' => $subCategory['image'], + 'list' => [] + ]; + } + + // 将文章分配到对应的子分类 + foreach ($articles as $article) { + if (isset($groupedArticles[$article['cate']])) { + // 如果文章图片为空,使用分类图片 + if (empty($article['image'])) { + $article['image'] = $groupedArticles[$article['cate']]['image']; + } + $groupedArticles[$article['cate']]['list'][] = $article; + } + } + + // 获取总数 + $total = Articles::where($where)->count(); + + // 准备返回数据 + $data = [ + 'cate' => [ + 'id' => $cateid, + 'name' => $category ? $category['name'] : '', + 'desc' => $category ? $category['desc'] : '', + 'image' => $category ? $category['image'] : '', + 'subCategories' => array_values($groupedArticles), + 'total' => $total, + 'page' => $page, + 'limit' => $limit + ] + ]; + + // 根据请求方式返回不同的输出 + if (request()->isPost()) { + return json([ + 'code' => 1, + 'msg' => '获取成功', + 'data' => $data + ]); + } else { + // 为视图准备数据 + $viewData = [ + 'categories' => $categories, + 'cate' => $data['cate'] + ]; + return view('index', $viewData); + } + } + // 文章列表页 public function list() { @@ -20,17 +134,23 @@ class ArticlesController extends BaseController // 构建查询条件 $where = [ - ['delete_time', '=', null], - ['status', '=', 1] + ['a.delete_time', '=', null], + ['a.status', '=', 2] ]; if ($cateId > 0) { - $where[] = ['cate', '=', $cateId]; + $where[] = ['a.cate', '=', $cateId]; } // 获取文章列表 - $articles = Articles::where($where) - ->order('id DESC') + $articles = Articles::alias('a') + ->join('articles_category c', 'a.cate = c.id') + ->where($where) + ->field([ + 'a.*', + 'IF(a.image IS NULL OR a.image = "", c.image, a.image) as image' + ]) + ->order('a.id DESC') ->paginate([ 'list_rows' => 10, 'query' => Request::instance()->param() @@ -51,14 +171,29 @@ class ArticlesController extends BaseController ->select() ->toArray(); - // 将变量传递给视图 - View::assign([ - 'articles' => $articles, - 'category' => $category, - 'categories' => $categories - ]); - - return view('list'); + // 根据请求方式返回不同的输出 + if (request()->isPost()) { + return json([ + 'code' => 1, + 'msg' => '获取成功', + 'data' => [ + 'articles' => $articles->items(), + 'category' => $category, + 'categories' => $categories, + 'total' => $articles->total(), + 'current_page' => $articles->currentPage(), + 'per_page' => $articles->listRows() + ] + ]); + } else { + // 将变量传递给视图 + View::assign([ + 'articles' => $articles, + 'category' => $category, + 'categories' => $categories + ]); + return view('list'); + } } // 文章详情页 @@ -66,7 +201,7 @@ class ArticlesController extends BaseController { $id = Request::param('id/d', 0); $article = Articles::where('id', $id)->find(); - + if (!$article) { return json(['code' => 0, 'msg' => '文章不存在或已被删除']); } @@ -74,20 +209,20 @@ class ArticlesController extends BaseController // 获取分类名称 $cateName = ArticlesCategory::where('id', $article['cate']) ->value('name'); - + // 获取上一篇和下一篇文章 $prevArticle = Articles::where('id', '<', $id) ->where('delete_time', null) ->where('status', '<>', 3) ->order('id DESC') ->find(); - + $nextArticle = Articles::where('id', '>', $id) ->where('delete_time', null) ->where('status', '<>', 3) ->order('id ASC') ->find(); - + // 获取相关文章(同分类的其他文章) $relatedArticles = Articles::alias('a') ->join('articles_category c', 'a.cate = c.id') @@ -120,7 +255,7 @@ class ArticlesController extends BaseController ] ]); } - + // 非 AJAX 请求返回视图 View::assign([ 'article' => $article, @@ -162,7 +297,7 @@ class ArticlesController extends BaseController // 返回更新后的点赞数 $newLikes = $article['likes'] + 1; return json([ - 'code' => 1, + 'code' => 1, 'msg' => '点赞成功', 'data' => [ 'likes' => $newLikes @@ -236,12 +371,12 @@ class ArticlesController extends BaseController public function viewStats() { $id = Request::param('id/d', 0); - - + + // 获取总访问量 $totalViews = Articles::where('id', $id) ->value('views'); - + return json([ 'code' => 1, 'data' => [ @@ -273,10 +408,10 @@ class ArticlesController extends BaseController // 更新访问次数 Articles::where('id', $id)->inc('views')->update(); - + // 获取更新后的访问次数 $newViews = Articles::where('id', $id)->value('views'); - + return json(['code' => 1, 'msg' => '更新成功', 'data' => ['views' => $newViews]]); } catch (\Exception $e) { return json(['code' => 0, 'msg' => '更新失败:' . $e->getMessage()]); diff --git a/app/index/controller/GameController.php b/app/index/controller/GameController.php index 3337622..6fdabe7 100644 --- a/app/index/controller/GameController.php +++ b/app/index/controller/GameController.php @@ -7,12 +7,120 @@ 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\Resources; use app\index\model\Resources\ResourcesCategory; use app\index\model\Attachments; class GameController extends BaseController { + //资源中心 + public function index() + { + // 获取前端传来的分类ID + $cateid = input('cateid/d', 0); + $page = input('page/d', 1); + $limit = input('limit/d', 10); + + // 获取所有顶级分类 + $categories = ResourcesCategory::where('cid', 0) + ->where('delete_time', null) + ->where('status', 1) + ->select() + ->toArray(); + + // 获取顶级分类信息 + $category = null; + if ($cateid > 0) { + $category = ResourcesCategory::where('id', $cateid) + ->where('delete_time', null) + ->where('status', 1) + ->find(); + } + + // 获取所有子分类 + $subCategories = []; + if ($cateid > 0) { + $subCategories = ResourcesCategory::where('cid', $cateid) + ->where('delete_time', null) + ->where('status', 1) + ->select() + ->toArray(); + } + + // 获取所有子分类ID + $subCategoryIds = array_column($subCategories, 'id'); + if ($cateid > 0) { + $subCategoryIds[] = $cateid; + } + + // 构建游戏查询条件 + $where = [ + ['delete_time', '=', null], + ['status', '=', 1] + ]; + + if (!empty($subCategoryIds)) { + $where[] = ['cate', 'in', $subCategoryIds]; + } + + // 查询游戏 + $games = Resources::where($where) + ->order('id DESC') + ->page($page, $limit) + ->select() + ->toArray(); + + // 按子分类分组游戏 + $groupedGames = []; + foreach ($subCategories as $subCategory) { + $groupedGames[$subCategory['id']] = [ + 'id' => $subCategory['id'], + 'name' => $subCategory['name'], + 'list' => [] + ]; + } + + // 将游戏分配到对应的子分类 + foreach ($games as $game) { + if (isset($groupedGames[$game['cate']])) { + $groupedGames[$game['cate']]['list'][] = $game; + } + } + + // 获取总数 + $total = Resources::where($where)->count(); + + // 准备返回数据 + $data = [ + 'cate' => [ + 'id' => $cateid, + 'name' => $category ? $category['name'] : '', + 'desc' => $category ? $category['desc'] : '', + 'image' => $category ? $category['image'] : '', + 'subCategories' => array_values($groupedGames), + 'total' => $total, + 'page' => $page, + 'limit' => $limit + ] + ]; + + // 根据请求方式返回不同的输出 + if (request()->isPost()) { + return json([ + 'code' => 1, + 'msg' => '获取成功', + 'data' => $data + ]); + } else { + // 为视图准备数据 + $viewData = [ + 'categories' => $categories, + 'cate' => $data['cate'] + ]; + return view('index', $viewData); + } + } + // 游戏列表页 public function list() { @@ -21,20 +129,26 @@ class GameController extends BaseController // 构建查询条件 $where = [ - ['delete_time', '=', null], - ['status', '=', 1] + ['a.delete_time', '=', null], + ['a.status', '=', 1] ]; if ($cateId > 0) { - $where[] = ['cate', '=', $cateId]; + $where[] = ['a.cate', '=', $cateId]; } // 获取游戏列表 - $games = Resources::where($where) - ->order('id DESC') + $games = Resources::alias('a') + ->join('resources_category c', 'a.cate = c.id') + ->where($where) + ->field([ + 'a.*', + 'IF(a.icon IS NULL OR a.icon = "", c.icon, a.icon) as icon' + ]) + ->order('a.id DESC') ->paginate([ 'list_rows' => 10, - 'query' => Request::param() + 'query' => Request::instance()->param() ]); // 获取分类信息 @@ -52,7 +166,22 @@ class GameController extends BaseController ->select() ->toArray(); - // 将变量传递给视图 + // 如果是POST请求,返回JSON数据 + if (Request::isPost()) { + return json([ + 'code' => 1, + 'msg' => '获取成功', + 'data' => [ + 'games' => $games->items(), + 'total' => $games->total(), + 'current_page' => $games->currentPage(), + 'per_page' => $games->listRows(), + 'category' => $category + ] + ]); + } + + // GET请求返回渲染的视图 View::assign([ 'games' => $games, 'category' => $category, @@ -67,16 +196,16 @@ class GameController extends BaseController { $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']; // 转换文件大小为合适的单位 @@ -93,20 +222,20 @@ class GameController extends BaseController // 获取分类名称 $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') @@ -140,7 +269,7 @@ class GameController extends BaseController ] ]); } - + // 非 AJAX 请求返回视图 View::assign([ 'game' => $game, @@ -179,7 +308,7 @@ class GameController extends BaseController if ($result) { return json([ - 'code' => 1, + 'code' => 1, 'msg' => '下载成功', 'data' => [ 'url' => $game['url'] @@ -194,11 +323,11 @@ class GameController extends BaseController public function viewStats() { $id = Request::param('id/d', 0); - + // 获取总访问量 $totalViews = Resources::where('id', $id) ->value('views'); - + return json([ 'code' => 1, 'data' => [ @@ -230,10 +359,10 @@ class GameController extends BaseController // 更新访问次数 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()]); diff --git a/app/index/controller/ProgramController.php b/app/index/controller/ProgramController.php index fdf31d7..e1f9697 100644 --- a/app/index/controller/ProgramController.php +++ b/app/index/controller/ProgramController.php @@ -14,6 +14,114 @@ use app\index\model\Attachments; class ProgramController extends BaseController { + //资源中心 + public function index() + { + // 获取前端传来的分类ID + $cateid = input('cateid/d', 0); + $page = input('page/d', 1); + $limit = input('limit/d', 10); + + // 获取所有顶级分类 + $categories = ResourcesCategory::where('cid', 0) + ->where('delete_time', null) + ->where('status', 1) + ->select() + ->toArray(); + + // 获取顶级分类信息 + $category = null; + if ($cateid > 0) { + $category = ResourcesCategory::where('id', $cateid) + ->where('delete_time', null) + ->where('status', 1) + ->find(); + } + + // 获取所有子分类 + $subCategories = []; + if ($cateid > 0) { + $subCategories = ResourcesCategory::where('cid', $cateid) + ->where('delete_time', null) + ->where('status', 1) + ->select() + ->toArray(); + } + + // 获取所有子分类ID + $subCategoryIds = array_column($subCategories, 'id'); + if ($cateid > 0) { + $subCategoryIds[] = $cateid; + } + + // 构建资源查询条件 + $where = [ + ['delete_time', '=', null], + ['status', '=', 1] + ]; + + if (!empty($subCategoryIds)) { + $where[] = ['cate', 'in', $subCategoryIds]; + } + + // 查询资源 + $programs = Resources::where($where) + ->order('id DESC') + ->page($page, $limit) + ->select() + ->toArray(); + + // 按子分类分组资源 + $groupedPrograms = []; + foreach ($subCategories as $subCategory) { + $groupedPrograms[$subCategory['id']] = [ + 'id' => $subCategory['id'], + 'name' => $subCategory['name'], + 'list' => [] + ]; + } + + // 将资源分配到对应的子分类 + foreach ($programs as $program) { + if (isset($groupedPrograms[$program['cate']])) { + $groupedPrograms[$program['cate']]['list'][] = $program; + } + } + + // 获取总数 + $total = Resources::where($where)->count(); + + // 准备返回数据 + $data = [ + 'cate' => [ + 'id' => $cateid, + 'name' => $category ? $category['name'] : '', + 'desc' => $category ? $category['desc'] : '', + 'image' => $category ? $category['image'] : '', + 'subCategories' => array_values($groupedPrograms), + 'total' => $total, + 'page' => $page, + 'limit' => $limit + ] + ]; + + // 根据请求方式返回不同的输出 + if (request()->isPost()) { + return json([ + 'code' => 1, + 'msg' => '获取成功', + 'data' => $data + ]); + } else { + // 为视图准备数据 + $viewData = [ + 'categories' => $categories, + 'cate' => $data['cate'] + ]; + return view('index', $viewData); + } + } + // 程序列表页 public function list() { @@ -22,20 +130,26 @@ class ProgramController extends BaseController // 构建查询条件 $where = [ - ['delete_time', '=', null], - ['status', '=', 1] + ['a.delete_time', '=', null], + ['a.status', '=', 1] ]; if ($cateId > 0) { - $where[] = ['cate', '=', $cateId]; + $where[] = ['a.cate', '=', $cateId]; } // 获取程序列表 - $programs = Resources::where($where) - ->order('id DESC') + $programs = Resources::alias('a') + ->join('resources_category c', 'a.cate = c.id') + ->where($where) + ->field([ + 'a.*', + 'IF(a.icon IS NULL OR a.icon = "", c.icon, a.icon) as icon' + ]) + ->order('a.id DESC') ->paginate([ 'list_rows' => 10, - 'query' => Request::param() + 'query' => Request::instance()->param() ]); // 获取分类信息 @@ -53,7 +167,22 @@ class ProgramController extends BaseController ->select() ->toArray(); - // 将变量传递给视图 + // 如果是POST请求,返回JSON数据 + if (Request::isPost()) { + return json([ + 'code' => 1, + 'msg' => '获取成功', + 'data' => [ + 'programs' => $programs->items(), + 'total' => $programs->total(), + 'current_page' => $programs->currentPage(), + 'per_page' => $programs->listRows(), + 'category' => $category + ] + ]); + } + + // GET请求返回渲染的视图 View::assign([ 'programs' => $programs, 'category' => $category, diff --git a/app/index/controller/UserController.php b/app/index/controller/UserController.php index 09603d3..85025d8 100644 --- a/app/index/controller/UserController.php +++ b/app/index/controller/UserController.php @@ -315,6 +315,7 @@ class UserController extends BaseController return $this->fetch(); } + //个人资料 public function saveBasic() { // 检查用户是否登录 @@ -582,6 +583,64 @@ class UserController extends BaseController } } + /** + * 获取系统通知列表 + */ + public function getMessages() + { + // 检查用户是否登录 + if (!cookie('user_account')) { + return json(['code' => 1, 'msg' => '请先登录']); + } + + $type = $this->request->get('type', 'all'); // 获取通知类型:all, unread, read + $userId = cookie('user_id'); + + try { + // 构建查询条件 + $where = [ + ['status', '=', 1] // 只获取启用的通知 + ]; + + // 查询系统通知 + $notices = UserMessage::where($where) + ->order('is_top', 'desc') // 置顶的排在前面 + ->order('create_time', 'desc') + ->select(); + + // 格式化数据 + $data = []; + foreach ($notices as $notice) { + // 检查用户是否已读该通知 + $isRead = UserMessage::where([ + ['user_id', '=', $userId], + ['notice_id', '=', $notice->id], + ['is_read', '=', 1] + ])->find(); + + // 根据type过滤 + if ($type == 'unread' && $isRead) + continue; + if ($type == 'read' && !$isRead) + continue; + + $data[] = [ + 'id' => $notice->id, + 'title' => $notice->title, + 'content' => $notice->content, + 'type' => $notice->type, + 'is_top' => $notice->is_top, + 'is_read' => $isRead ? 1 : 0, + 'create_time' => date('Y-m-d H:i:s', $notice->create_time) + ]; + } + + return json(['code' => 0, 'msg' => '获取成功', 'data' => $data]); + } catch (\Exception $e) { + return json(['code' => 1, 'msg' => '获取失败:' . $e->getMessage()]); + } + } + //修改密码 public function updatePassword() { diff --git a/app/index/view/articles/index.php b/app/index/view/articles/index.php new file mode 100644 index 0000000..9ad61c3 --- /dev/null +++ b/app/index/view/articles/index.php @@ -0,0 +1,539 @@ +{include file="component/head" /} +{include file="component/header-simple" /} + + +
+ +
+
+

文章中心

+

探索知识与洞见

+
+
+ + +
+
+ + + + +
+ +
+ {volist name="cate.subCategories" id="subCategory"} + {if $cate.id == $subCategory.id} + {if !empty($subCategory.list)} + {volist name="subCategory.list" id="article"} +
+
+ {$article.title} +
+
+
+
+ ${article.category_name || '未分类'} + +
+

${article.title}

+ +
+
+ {/volist} + {else} +
+
+ +
+

暂无文章

+

当前分类下没有找到相关文章

+
+ {/if} + {/if} + {/volist} +
+ + + +
+
+
+
+ + + +{include file="component/footer" /} + + + +{include file="component/foot" /} \ No newline at end of file diff --git a/app/index/view/articles/list.php b/app/index/view/articles/list.php new file mode 100644 index 0000000..6550fb5 --- /dev/null +++ b/app/index/view/articles/list.php @@ -0,0 +1,76 @@ +
+
+ +
+
+ +
+ {volist name="categories" id="cate"} +
{$cate.name}
+ {/volist} +
+
+
+ + +
+ {if $category} +
+

{$category.name}

+

{$category.desc|default=''}

+
+ {/if} + +
+ {volist name="articles" id="article"} +
+
+
+
+ {$article.title} +
+
+
+
+

+ {$article.title} +

+

{$article.desc|default=''}

+ +
+
+
+
+ {/volist} +
+ + +
+ {$articles|raw} +
+
+
+
+ + diff --git a/app/index/view/component/main.php b/app/index/view/component/main.php index 45cd214..88ec73e 100644 --- a/app/index/view/component/main.php +++ b/app/index/view/component/main.php @@ -14,7 +14,7 @@ -
更多
+
更多
@@ -35,7 +35,7 @@
-
更多
+
更多
@@ -56,7 +56,7 @@
-
更多
+
更多
@@ -77,7 +77,7 @@
-
更多
+
更多
@@ -98,7 +98,7 @@
-
更多
+
更多
diff --git a/app/index/view/game/index.php b/app/index/view/game/index.php new file mode 100644 index 0000000..37d0416 --- /dev/null +++ b/app/index/view/game/index.php @@ -0,0 +1,539 @@ +{include file="component/head" /} +{include file="component/header-simple" /} + + +
+ +
+
+

游戏中心

+

探索知识与洞见

+
+
+ + +
+
+ + + + +
+ +
+ {volist name="cate.subCategories" id="subCategory"} + {if $cate.id == $subCategory.id} + {if !empty($subCategory.list)} + {volist name="subCategory.list" id="game"} + +
+ {$game.title} +
+
+
+
+ {$subCategory.name} + +
+

{$game.title}

+ +
+
+ {/volist} + {else} +
+
+ +
+

暂无文章

+

当前分类下没有找到相关文章

+
+ {/if} + {/if} + {/volist} +
+ + + +
+
+
+
+ + + +{include file="component/footer" /} + + + +{include file="component/foot" /} \ No newline at end of file diff --git a/app/index/view/game/list.php b/app/index/view/game/list.php new file mode 100644 index 0000000..efc8155 --- /dev/null +++ b/app/index/view/game/list.php @@ -0,0 +1,76 @@ +
+
+ +
+
+ +
+ {volist name="categories" id="cate"} +
{$cate.name}
+ {/volist} +
+
+
+ + +
+ {if $category} +
+

{$category.name}

+

{$category.desc|default=''}

+
+ {/if} + +
+ {volist name="games" id="article"} +
+
+
+
+ {$article.title} +
+
+
+
+

+ {$article.title} +

+

{$article.desc|default=''}

+ +
+
+
+
+ {/volist} +
+ + +
+ {$games|raw} +
+
+
+
+ + diff --git a/app/index/view/program/index.php b/app/index/view/program/index.php new file mode 100644 index 0000000..5f21075 --- /dev/null +++ b/app/index/view/program/index.php @@ -0,0 +1,535 @@ +{include file="component/head" /} +{include file="component/header-simple" /} + + +
+ +
+
+

文章中心

+

探索知识与洞见

+
+
+ + +
+
+ + + + +
+ +
+ {volist name="cate.subCategories" id="subCategory"} + {if $cate.id == $subCategory.id} + {if !empty($subCategory.list)} + {volist name="subCategory.list" id="program"} + +
+ {$program.title} +
+
+
+
+ {$subCategory.name} + +
+

{$program.title}

+ +
+
+ {/volist} + {else} +
+
+ +
+

暂无文章

+

当前分类下没有找到相关文章

+
+ {/if} + {/if} + {/volist} +
+ + + +
+
+
+
+ + + +{include file="component/footer" /} + + + +{include file="component/foot" /} \ No newline at end of file diff --git a/app/index/view/program/list.php b/app/index/view/program/list.php new file mode 100644 index 0000000..4f74b7a --- /dev/null +++ b/app/index/view/program/list.php @@ -0,0 +1,261 @@ +
+
+ +
+
+ +
+ {volist name="categories" id="cate"} +
{$cate.name}
+ {/volist} +
+
+
+ + +
+ {if $category} +
+

{$category.name}

+

{$category.desc|default=''}

+
+ {/if} + +
+ {if empty($programs)} +
+ +

暂无程序

+
+ {else} + {volist name="programs" id="program"} +
+
+
+
+ {$program.title} +
+
+
+
+

+ {$program.title} +

+

{$program.desc|default=''}

+
+
+ {$program.views|default=0} + {$program.downloads|default=0} + {$program.create_time|date="Y-m-d"} +
+ 查看详情 +
+
+
+
+
+ {/volist} + {/if} +
+ + + {if !empty($programs)} +
+ {$programs->render()|raw} +
+ {/if} +
+
+
+ + + + + + // 页面加载完成后,自动触发第一个分类的点击事件 + $(document).ready(function() { + var $firstMenuItem = $('.category-item').first(); + if ($firstMenuItem.length > 0) { + $firstMenuItem.click(); + } + }); + }); + diff --git a/app/index/view/user/component/security.php b/app/index/view/user/component/security.php index a564c88..4cd4ec9 100644 --- a/app/index/view/user/component/security.php +++ b/app/index/view/user/component/security.php @@ -72,17 +72,6 @@ loadSecurityInfo(); }); - // 加载安全信息 - function loadSecurityInfo() { - fetch('/index/user/getSecurityInfo') - .then(response => response.json()) - .then(data => { - if (data.code === 0) { - document.getElementById('phoneNumber').textContent = data.data.phone || '未绑定'; - } - }); - } - // 修改密码 function changePassword() { layer.open({ diff --git a/runtime/index/temp/402d23cdf323169a38fb26d3649b6ad5.php b/runtime/index/temp/402d23cdf323169a38fb26d3649b6ad5.php index 34fed3a..e9af854 100644 --- a/runtime/index/temp/402d23cdf323169a38fb26d3649b6ad5.php +++ b/runtime/index/temp/402d23cdf323169a38fb26d3649b6ad5.php @@ -1,4 +1,4 @@ - + @@ -18,37 +18,43 @@ + false, + 'name' => '', + 'avatar' => '/static/images/avatar.png' // 默认头像 +]; + +// 检查cookie +$userAccount = cookie('user_account'); +if ($userAccount) { + $isLoggedIn = true; + $userInfo = [ + 'is_login' => true, + 'name' => cookie('user_name'), + 'avatar' => cookie('user_avatar') ? cookie('user_avatar') : '/static/images/avatar.png' + ]; +} + +// 添加一个隐藏的div来存储登录状态 +$loginStatus = [ + 'isLoggedIn' => $isLoggedIn, + 'userAccount' => $userAccount ?? '' +]; +?> + + + +
-
-
-
-
    -
  • - - -
  • -
  • - - -
  • -
-
- -
-