feat: 双端口(首页80/后台16888) + WebSocket轮播 + 展示时间限制

This commit is contained in:
yinzhou.ma
2026-07-16 23:01:43 +08:00
parent 42aeb84c64
commit 9316422ef1
7 changed files with 135 additions and 98 deletions
+7 -1
View File
@@ -202,9 +202,15 @@ wss.on('connection', (ws) => {
const adminApp = express();
adminApp.use(express.json());
adminApp.use(express.urlencoded({ extended: true }));
adminApp.use(express.static(path.join(__dirname, 'public')));
adminApp.use('/uploads', express.static(path.join(__dirname, 'uploads')));
// 路由 - 后台直接在根路径,未登录跳转登录页
adminApp.get('/login', (req, res) => res.sendFile(path.join(__dirname, 'public', 'login.html')));
adminApp.get('/', (req, res) => res.sendFile(path.join(__dirname, 'public', 'admin.html')));
// 静态文件(不自动serve index.html
adminApp.use(express.static(path.join(__dirname, 'public'), { index: false }));
const authMiddleware = (req, res, next) => {
const token = req.headers.authorization?.split(' ')[1];
if (!token || token !== 'admin-token') return res.status(401).json({ error: '未授权' });