From 6cc9b12b81d184bb2df9dc68f93ca45c3d47d229 Mon Sep 17 00:00:00 2001
From: 905086 <k2049@qq.com>
Date: Sun, 08 Nov 2026 17:31:58 +0800
Subject: [PATCH] feat(server): 添加游戏目录公开浏览页并更新重启脚本提示
---
server/showcase/index.html | 361 +++++++++++++++++++++++++++++++++++++++++++++++++++
server/main.go | 9 +
server/tmp_restart.ps1 | 2
3 files changed, 371 insertions(+), 1 deletions(-)
diff --git a/server/main.go b/server/main.go
index d219814..44ec722 100644
--- a/server/main.go
+++ b/server/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "net/http"
"os"
"path/filepath"
@@ -56,6 +57,14 @@
}
}
+ // ---------- 游戏目录展示页(公开,仅浏览不可下载) ----------
+ r.GET("/showcase", func(c *gin.Context) {
+ c.File("./showcase/index.html")
+ })
+ r.GET("/", func(c *gin.Context) {
+ c.Redirect(http.StatusFound, "/showcase")
+ })
+
// ---------- 管理后台 ----------
r.GET("/admin", func(c *gin.Context) {
c.File("./admin/index.html")
diff --git a/server/showcase/index.html b/server/showcase/index.html
new file mode 100644
index 0000000..052a05b
--- /dev/null
+++ b/server/showcase/index.html
@@ -0,0 +1,361 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+<meta charset="UTF-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<title>游趣电玩 · 游戏目录</title>
+<style>
+ * { margin: 0; padding: 0; box-sizing: border-box; }
+ body {
+ background: #14161f;
+ color: #fff;
+ font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
+ min-height: 100vh;
+ }
+ img { display: block; }
+
+ /* 顶部栏 */
+ header {
+ position: sticky; top: 0; z-index: 100;
+ background: rgba(20, 22, 31, .95);
+ backdrop-filter: blur(10px);
+ border-bottom: 1px solid #252a3a;
+ padding: 14px 24px;
+ display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
+ }
+ .logo {
+ width: 42px; height: 42px; border-radius: 50%;
+ background: linear-gradient(135deg, #ff5c8a, #b44dff);
+ display: flex; align-items: center; justify-content: center;
+ font-size: 18px; font-weight: bold; flex-shrink: 0;
+ box-shadow: 0 0 18px rgba(255, 92, 138, .45);
+ }
+ .brand { display: flex; flex-direction: column; margin-right: 8px; }
+ .brand b { font-size: 17px; letter-spacing: 1px; }
+ .brand span { font-size: 11px; color: #7d8598; }
+ .search-box {
+ flex: 1; min-width: 200px; max-width: 420px;
+ position: relative; margin-left: auto;
+ }
+ .search-box input {
+ width: 100%; height: 38px; padding: 0 40px 0 16px;
+ background: #1c1f2e; border: 1px solid #2c3247; border-radius: 19px;
+ color: #fff; font-size: 13px; outline: none;
+ }
+ .search-box input:focus { border-color: #ff5c8a; }
+ .search-box .icon {
+ position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
+ color: #7d8598; font-size: 14px; font-style: normal;
+ }
+ .client-tip {
+ font-size: 12px; color: #7d8598;
+ padding: 7px 14px; border: 1px solid #2c3247; border-radius: 16px;
+ white-space: nowrap;
+ }
+
+ /* 类别栏 */
+ .cats {
+ display: flex; gap: 10px; overflow-x: auto; padding: 16px 24px 4px;
+ scrollbar-width: none;
+ }
+ .cats::-webkit-scrollbar { display: none; }
+ .cat-chip {
+ padding: 8px 18px; border-radius: 16px; white-space: nowrap;
+ background: #1c1f2e; color: #aab2c5; font-size: 13px;
+ cursor: pointer; border: 1px solid transparent; user-select: none;
+ transition: all .2s;
+ }
+ .cat-chip:hover { color: #fff; }
+ .cat-chip.active {
+ background: linear-gradient(135deg, #ff5c8a, #ff7e5a);
+ color: #fff; font-weight: bold;
+ }
+
+ /* 游戏网格 */
+ main {
+ max-width: 1280px; margin: 0 auto; padding: 20px 24px 60px;
+ display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
+ gap: 22px 18px;
+ }
+ .card {
+ border-radius: 10px; overflow: hidden; cursor: pointer;
+ background: #1c1f2e; border: 1px solid #262b3d;
+ transition: transform .25s, box-shadow .25s, border-color .25s;
+ }
+ .card:hover {
+ transform: translateY(-5px);
+ box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
+ border-color: #ff5c8a;
+ }
+ .cover {
+ aspect-ratio: 3/4; background: #10121c; position: relative; overflow: hidden;
+ }
+ .cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
+ .card:hover .cover img { transform: scale(1.05); }
+ .cover .size-tag {
+ position: absolute; right: 0; bottom: 0;
+ background: rgba(0, 0, 0, .65); color: #e7eaf3;
+ font-size: 11px; padding: 3px 8px; border-radius: 6px 0 0 0;
+ }
+ .card .info { padding: 10px 12px 12px; }
+ .card .title {
+ font-size: 13px; font-weight: bold; line-height: 1.45; height: 2.9em;
+ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
+ overflow: hidden; margin-bottom: 8px;
+ }
+ .tags { display: flex; flex-wrap: wrap; gap: 5px; }
+ .tag {
+ font-size: 11px; color: #9aa3b8; background: #262b3d;
+ padding: 2px 8px; border-radius: 4px;
+ }
+ .tag.cat { color: #4a92ff; }
+
+ .empty {
+ grid-column: 1 / -1; text-align: center; color: #5c6478;
+ padding: 80px 0; font-size: 14px;
+ }
+ .loading { grid-column: 1 / -1; text-align: center; color: #5c6478; padding: 80px 0; }
+ .loading .spin {
+ display: inline-block; width: 28px; height: 28px;
+ border: 3px solid #2c3247; border-top-color: #ff5c8a;
+ border-radius: 50%; animation: spin .8s linear infinite;
+ }
+ @keyframes spin { to { transform: rotate(360deg); } }
+
+ /* 详情弹窗 */
+ .modal-mask {
+ position: fixed; inset: 0; z-index: 200;
+ background: rgba(5, 6, 10, .8); backdrop-filter: blur(4px);
+ display: none; align-items: flex-start; justify-content: center;
+ padding: 4vh 16px; overflow-y: auto;
+ }
+ .modal-mask.show { display: flex; }
+ .modal {
+ width: 860px; max-width: 100%;
+ background: #1b1e2e; border: 1px solid #2c3247; border-radius: 12px;
+ padding: 26px; position: relative;
+ animation: pop .25s ease;
+ }
+ @keyframes pop { from { opacity: 0; transform: translateY(18px); } }
+ .close-btn {
+ position: absolute; top: 14px; right: 14px;
+ width: 32px; height: 32px; border-radius: 50%;
+ background: #262b3d; color: #aab2c5; border: none; cursor: pointer;
+ font-size: 16px; line-height: 32px; text-align: center;
+ }
+ .close-btn:hover { background: #ff5c8a; color: #fff; }
+ .detail-top { display: flex; gap: 24px; }
+ .detail-cover {
+ width: 240px; flex-shrink: 0; aspect-ratio: 3/4;
+ border-radius: 10px; overflow: hidden; background: #10121c;
+ }
+ .detail-cover img { width: 100%; height: 100%; object-fit: cover; }
+ .detail-meta { flex: 1; min-width: 0; }
+ .detail-meta h2 { font-size: 20px; margin-bottom: 12px; line-height: 1.4; padding-right: 36px; }
+ .meta-rows { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
+ .meta-row { display: flex; font-size: 13px; }
+ .meta-row .k { color: #7d8598; width: 70px; flex-shrink: 0; }
+ .meta-row .v { color: #dfe3ee; word-break: break-all; }
+ .desc {
+ font-size: 13px; color: #aab2c5; line-height: 1.8;
+ max-height: 180px; overflow-y: auto; white-space: pre-wrap;
+ }
+ .shots { margin-top: 20px; }
+ .shots h3 { font-size: 14px; color: #dfe3ee; margin-bottom: 10px; }
+ .shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
+ .shot-grid img, .shot-grid video {
+ width: 100%; border-radius: 8px; background: #10121c;
+ }
+ .video-box { margin-top: 20px; }
+ .video-box video { width: 100%; border-radius: 8px; background: #000; }
+ .only-view {
+ margin-top: 22px; padding: 12px 16px; border-radius: 8px;
+ background: rgba(255, 92, 138, .08); border: 1px solid rgba(255, 92, 138, .3);
+ color: #ff8aa8; font-size: 13px; text-align: center;
+ }
+
+ footer {
+ text-align: center; color: #5c6478; font-size: 12px;
+ padding: 30px 0 40px; border-top: 1px solid #1e2231;
+ }
+
+ @media (max-width: 640px) {
+ header { padding: 12px 14px; }
+ .client-tip { display: none; }
+ .cats { padding: 12px 14px 4px; }
+ main { padding: 14px 14px 50px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 12px; }
+ .modal { padding: 18px; }
+ .detail-top { flex-direction: column; }
+ .detail-cover { width: 170px; margin: 0 auto; }
+ .detail-meta h2 { padding-right: 30px; }
+ }
+</style>
+</head>
+<body>
+
+<header>
+ <div class="logo">99</div>
+ <div class="brand"><b>游趣电玩</b><span>游戏目录 · 精选游戏一览</span></div>
+ <div class="search-box">
+ <input id="kw" type="text" placeholder="搜索游戏名称..." />
+ <i class="icon">🔍</i>
+ </div>
+ <div class="client-tip">本页面仅用于浏览,下载游戏请使用游趣电玩客户端</div>
+</header>
+
+<nav class="cats" id="cats"></nav>
+
+<main id="grid">
+ <div class="loading"><span class="spin"></span></div>
+</main>
+
+<footer>游趣电玩 · 游戏盒子 © 2026 | 本目录仅供展示,具体游戏以客户端为准</footer>
+
+<!-- 详情弹窗 -->
+<div class="modal-mask" id="mask">
+ <div class="modal">
+ <button class="close-btn" onclick="closeDetail()">✕</button>
+ <div id="detailBody"></div>
+ </div>
+</div>
+
+<script>
+const API = '';
+let allGames = [];
+let categories = [];
+let curCat = 0;
+let curKw = '';
+let debounceTimer = null;
+
+function gbLabel(s) {
+ if (!s) return '未知大小';
+ const t = String(s).trim();
+ return /[a-zA-Z]/.test(t) ? t : t + ' GB';
+}
+function esc(s) {
+ return String(s == null ? '' : s).replace(/[&<>"']/g, m =>
+ ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[m]));
+}
+
+async function loadCategories() {
+ try {
+ const res = await fetch(API + '/api/categories').then(r => r.json());
+ if (res.code === 0) categories = res.data || [];
+ } catch (e) {}
+ const el = document.getElementById('cats');
+ let html = `<div class="cat-chip active" data-id="0" onclick="pickCat(0)">全部</div>`;
+ html += categories.map(c =>
+ `<div class="cat-chip" data-id="${c.id}" onclick="pickCat(${c.id})">${esc(c.name)}</div>`).join('');
+ el.innerHTML = html;
+}
+
+async function loadGames() {
+ const grid = document.getElementById('grid');
+ grid.innerHTML = '<div class="loading"><span class="spin"></span></div>';
+ try {
+ const p = new URLSearchParams({ platform: 'all', category: '0', keyword: curKw, sort: 'updated' });
+ const res = await fetch(API + '/api/games?' + p).then(r => r.json());
+ if (res.code !== 0) throw 0;
+ allGames = res.data || [];
+ render();
+ } catch (e) {
+ grid.innerHTML = '<div class="empty">加载失败,请刷新重试</div>';
+ }
+}
+
+function render() {
+ const grid = document.getElementById('grid');
+ if (!allGames.length) {
+ grid.innerHTML = '<div class="empty">暂无游戏</div>';
+ return;
+ }
+ const list = curCat > 0 ? allGames.filter(g => g.category_id === curCat) : allGames;
+ if (!list.length) {
+ grid.innerHTML = '<div class="empty">该类别下暂无游戏</div>';
+ return;
+ }
+ grid.innerHTML = list.map(g => `
+ <div class="card" onclick="openDetail(${g.id})">
+ <div class="cover">
+ ${g.cover_url
+ ? `<img src="${esc(g.cover_url)}" loading="lazy" alt="${esc(g.title)}" onerror="this.style.display='none'">`
+ : ''}
+ <span class="size-tag">${esc(gbLabel(g.size))}</span>
+ </div>
+ <div class="info">
+ <div class="title">${esc(g.title)}</div>
+ <div class="tags">
+ ${g.category_name ? `<span class="tag cat">${esc(g.category_name)}</span>` : ''}
+ ${(g.tags || '').split(/[,,\s]+/).filter(Boolean).slice(0, 2).map(t =>
+ `<span class="tag">${esc(t)}</span>`).join('')}
+ </div>
+ </div>
+ </div>`).join('');
+}
+
+function pickCat(id) {
+ curCat = id;
+ document.querySelectorAll('.cat-chip').forEach(c =>
+ c.classList.toggle('active', +c.dataset.id === id));
+ render();
+}
+
+document.getElementById('kw').addEventListener('input', e => {
+ clearTimeout(debounceTimer);
+ debounceTimer = setTimeout(() => { curKw = e.target.value.trim(); loadGames(); }, 350);
+});
+
+async function openDetail(id) {
+ const mask = document.getElementById('mask');
+ const body = document.getElementById('detailBody');
+ body.innerHTML = '<div class="loading"><span class="spin"></span></div>';
+ mask.classList.add('show');
+ mask.onclick = e => { if (e.target === mask) closeDetail(); };
+ try {
+ const res = await fetch(API + '/api/games/' + id).then(r => r.json());
+ if (res.code !== 0) throw 0;
+ const g = res.data;
+ let shots = [];
+ try { shots = JSON.parse(g.screenshots || '[]'); } catch (e) {}
+ const tagList = (g.tags || '').split(/[,,\s]+/).filter(Boolean);
+ body.innerHTML = `
+ <div class="detail-top">
+ <div class="detail-cover">
+ ${g.cover_url ? `<img src="${esc(g.cover_url)}" alt="${esc(g.title)}">` : ''}
+ </div>
+ <div class="detail-meta">
+ <h2>${esc(g.title)}</h2>
+ <div class="meta-rows">
+ ${g.category_name ? `<div class="meta-row"><span class="k">类别</span><span class="v">${esc(g.category_name)}</span></div>` : ''}
+ ${tagList.length ? `<div class="meta-row"><span class="k">标签</span><span class="v">${tagList.map(esc).join(' / ')}</span></div>` : ''}
+ <div class="meta-row"><span class="k">游戏大小</span><span class="v">${esc(gbLabel(g.size))}</span></div>
+ ${g.install_size ? `<div class="meta-row"><span class="k">磁盘占用</span><span class="v">${esc(gbLabel(g.install_size))}</span></div>` : ''}
+ <div class="meta-row"><span class="k">平台</span><span class="v">${esc(g.platform === 'switch' ? 'Switch 资源' : 'PC 资源')}</span></div>
+ </div>
+ <div class="desc">${esc(g.description || '暂无简介')}</div>
+ </div>
+ </div>
+ ${g.video_url ? `<div class="video-box"><video src="${esc(g.video_url)}" controls preload="none" poster="${esc(g.cover_url || '')}"></video></div>` : ''}
+ ${shots.length ? `<div class="shots"><h3>游戏截图</h3><div class="shot-grid">
+ ${shots.map(s => `<img src="${esc(s)}" loading="lazy" onerror="this.style.display='none'">`).join('')}
+ </div></div>` : ''}
+ <div class="only-view">本页面仅提供游戏预览,如需下载游戏请在游趣电玩客户端中操作</div>
+ `;
+ } catch (e) {
+ body.innerHTML = '<div class="empty">详情加载失败</div>';
+ }
+}
+
+function closeDetail() {
+ document.getElementById('mask').classList.remove('show');
+ const v = document.querySelector('#detailBody video');
+ if (v) v.pause();
+}
+
+document.addEventListener('keydown', e => { if (e.key === 'Escape') closeDetail(); });
+
+loadCategories();
+loadGames();
+</script>
+</body>
+</html>
diff --git a/server/tmp_restart.ps1 b/server/tmp_restart.ps1
index 9291ba4..d754e7e 100644
--- a/server/tmp_restart.ps1
+++ b/server/tmp_restart.ps1
@@ -1,4 +1,4 @@
Get-NetTCPConnection -LocalPort 8080 -State Listen -ErrorAction SilentlyContinue | ForEach-Object {
Stop-Process -Id $_.OwningProcess -Force -ErrorAction SilentlyContinue
}
-Write-Host "stopped"
+Write-Host "old server stopped"
--
Gitblit v1.10.0