feat: Phase 1 完成 — 基础设施 + 用户认证 + 管理端 + 端到端验证

Phase 1 (基础设施与用户认证) 全部 11 个 Task 开发完成:

后端 (Go):
- Auth 模块: 注册/登录/JWT(有状态)/Profile/密码修改
- Admin 模块: 用户列表/详情/禁用/启用/角色分配/创建用户
- 中间件: JWT认证 + RBAC角色权限 + 请求日志 + CORS + Panic恢复
- Dockerfile 多阶段构建 + Docker Compose 全栈部署

前台 (uni-app):
- 登录/注册页面 + 自定义 TabBar + 个人中心
- 请求封装 + 状态管理 (Pinia)

管理端 (Vue 3 + Element Plus):
- 登录/仪表盘/用户列表/用户详情
- Axios 封装 + 路由守卫 + Pinia 状态管理

验证:
- 全流程 API 端到端测试通过
- Playwright 页面自动化验证通过
- code-reviewer 代码审查通过

Made-with: Cursor
This commit is contained in:
bujinyuan
2026-03-02 11:31:24 +08:00
parent e9bd4dd204
commit 4d03215fe4
63 changed files with 15908 additions and 102 deletions

85
admin/src/router/index.js Normal file
View File

@@ -0,0 +1,85 @@
/**
* 管理后台路由配置
*
* 路由结构:
* - /login → 管理员登录页(无需认证)
* - / → 后台主布局(需要认证 + admin 角色)
* - /dashboard → 仪表盘
* - /user/list → 用户管理列表
* - /user/detail/:id → 用户详情
*
* 路由守卫:
* - 未登录 → 重定向到 /login
* - 已登录访问 /login → 重定向到 /dashboard
*/
import { createRouter, createWebHashHistory } from 'vue-router'
const routes = [
{
path: '/login',
name: 'Login',
component: () => import('@/views/login/index.vue'),
meta: { title: '管理员登录', requiresAuth: false }
},
{
path: '/',
component: () => import('@/views/layout/index.vue'),
redirect: '/dashboard',
meta: { requiresAuth: true },
children: [
{
path: 'dashboard',
name: 'Dashboard',
component: () => import('@/views/dashboard/index.vue'),
meta: { title: '仪表盘' }
},
{
path: 'user/list',
name: 'UserList',
component: () => import('@/views/user/list.vue'),
meta: { title: '用户列表' }
},
{
path: 'user/detail/:id',
name: 'UserDetail',
component: () => import('@/views/user/detail.vue'),
meta: { title: '用户详情' }
}
]
}
]
const router = createRouter({
history: createWebHashHistory(),
routes
})
/**
* 全局前置守卫
* 检查登录状态,控制页面访问权限
*/
router.beforeEach((to, from, next) => {
const token = localStorage.getItem('admin_token')
document.title = to.meta.title
? `${to.meta.title} - EchoChat 管理后台`
: 'EchoChat 管理后台'
if (to.meta.requiresAuth === false) {
if (token && to.path === '/login') {
next('/dashboard')
} else {
next()
}
return
}
if (!token) {
next({ path: '/login', query: { redirect: to.fullPath } })
return
}
next()
})
export default router