feat: 微信分享钩子全页面接入 + 订阅信息结构化映射 + JWT 错误处理加强

- client: 全部页面接入 onShareAppMessage/onShareTimeline 分享钩子
- client: login 页增强、profile 订阅展示优化
- client/stores: 订阅字段扁平结构映射为 subInfo(plan/expiresAt/startDate)
- server: auth 路由 JWT 无效/过期统一返回 401 未授权响应
- server: models/tests 同步更新
This commit is contained in:
Yuzhiran Dev
2026-09-04 11:47:29 +08:00
parent de8ca9c420
commit 66de1dc396
37 changed files with 2138 additions and 1830 deletions
+17
View File
@@ -5,11 +5,28 @@
// 增加测试超时时间
jest.setTimeout(30000)
// 测试环境必须使用独立的测试数据库,绝不能操作生产库(wdkj)
const TEST_DB_NAME = 'wdkj_test'
const DANGER_DB_NAMES = ['wdkj']
function assertTestDatabase() {
const mongoose = require('mongoose')
const name = mongoose.connection.name
if (!name) return
if (DANGER_DB_NAMES.includes(name)) {
throw new Error(
`[安全] 测试不允许连接生产数据库 "${name}"。请通过 MONGODB_URI 指定独立的测试数据库(如 ${TEST_DB_NAME})。`
)
}
}
// 全局清理
afterAll(async () => {
// 关闭所有数据库连接
const mongoose = require('mongoose')
if (mongoose.connection.readyState !== 0) {
// 防呆:确认当前不是生产库后才清理/关闭
assertTestDatabase()
await mongoose.connection.close()
}
})