fix(我的): 修复状态栏遮挡与退出登录被底栏遮住, 新增访问 IP 展示
Docker Build and Push / build-image (push) Successful in 3m26s

This commit is contained in:
jif2.zhang
2026-11-12 17:15:21 +08:00
parent e05ed6b491
commit 7b53a7b5e9
5 changed files with 88 additions and 7 deletions
+25
View File
@@ -0,0 +1,25 @@
// 系统信息: 当前访问者 IP 等
// 仅供「我」页展示, 需要登录后访问
import { Router } from 'express'
import { authRequired } from '../middleware.js'
const router = Router()
router.use(authRequired)
router.use((_req, res, next) => {
res.set('Cache-Control', 'no-store')
next()
})
// 去掉 IPv4-mapped IPv6 前缀 (::ffff:1.2.3.4 → 1.2.3.4), 便于展示
function normalizeIp(ip) {
const s = String(ip || '').trim()
return s.startsWith('::ffff:') ? s.slice(7) : s
}
// GET /api/system/client-ip 服务器看到的当前访问 IP
// 依赖 index.js 里的 trust proxy 设置解析 X-Forwarded-For (生产经 NPM 反代)
router.get('/client-ip', (req, res) => {
res.json({ ip: normalizeIp(req.ip || req.socket?.remoteAddress) })
})
export default router