feat: 双端口(首页80/后台16888) + WebSocket轮播 + 展示时间限制
This commit is contained in:
@@ -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: '未授权' });
|
||||
|
||||
Reference in New Issue
Block a user