// 简单token认证中间件,支持token-3格式 module.exports = function (req, res, next) { const auth = req.headers.authorization; if (auth && auth.startsWith('Bearer token-')) { const id = parseInt(auth.replace('Bearer token-', '')); if (!isNaN(id)) { req.user = { id }; } } next(); };