fix: 清理死代码 + 修复群组模式预算支出计算

- 清理 store 中未使用的 loading 状态(stats/budget/category/user)
- 清理 stats store 冗余类型重导出和 catch 重置逻辑
- 清理 transaction store 未使用的 currentPage
- 清理 api/group 未使用的 GroupDetail/GroupMember/getGroupDetail
- 删除无引用的 api/index.ts barrel 导出文件
- 删除后端未调用的 GET /groups/:id 群组详情路由
- 合并 stats 页面重复的 loadTabData 函数
- 修复预算页群组模式下只算个人支出(不传 group_id)
This commit is contained in:
wangxiaogang
2026-06-04 21:04:59 +08:00
parent e764ae996e
commit 114263e4b2
10 changed files with 56 additions and 182 deletions

View File

@@ -86,45 +86,6 @@ router.get('/', async (req: AuthRequest, res: Response) => {
}
})
/** 获取群组详情 + 成员列表 */
router.get('/:id', async (req: AuthRequest, res: Response) => {
try {
// 验证用户是否是群组成员
const [memberCheck] = await pool.query(
'SELECT role FROM group_members WHERE group_id = ? AND user_id = ?',
[req.params.id, req.userId]
)
if ((memberCheck as any[]).length === 0) {
return res.status(403).json({ code: 40300, message: '无权访问此群组' })
}
const [groupRows] = await pool.query(
'SELECT id, name, invite_code, created_by, created_at FROM `groups` WHERE id = ?',
[req.params.id]
)
const group = (groupRows as any[])[0]
if (!group) {
return res.status(404).json({ code: 40400, message: '群组不存在' })
}
// 获取成员列表
const [members] = await pool.query(
`SELECT gm.user_id, gm.role, gm.nickname, gm.created_at as joined_at,
u.nickname as user_nickname, u.avatar_url
FROM group_members gm
LEFT JOIN users u ON gm.user_id = u.id
WHERE gm.group_id = ?
ORDER BY gm.role DESC, gm.created_at ASC`,
[req.params.id]
)
res.json({ code: 0, data: { ...group, members } })
} catch (err) {
console.error('[Group] GET by ID error:', err)
res.status(500).json({ code: 50000, message: '服务器错误' })
}
})
/** 通过邀请码加入群组 */
router.post('/join', async (req: AuthRequest, res: Response) => {
try {