feat: 实现前端认证系统,WebSocket 连接携带 JWT token

- 新增 AuthContext/AuthProvider:登录/注册状态管理,JWT 自动刷新
- 新增 AuthPage 组件:登录/注册表单,支持模式切换和前端校验
- 新增 api.ts:封装 auth REST API 客户端(register/login/refresh/logout)
- WebSocket 连接时拼接 ?token=<jwt>,重连自动携带
- useVisionSession 接受 accessToken 参数并透传
- App.tsx 包裹 AuthProvider,未登录时显示登录页
- storage.ts 新增 token/user 的 localStorage 存储
- i18n 新增中/英/日三语 auth 翻译
- App.css 新增 auth 页面和用户 badge 样式
This commit is contained in:
2026-06-14 18:38:45 +08:00
parent a1ae7740f1
commit 8de956719c
12 changed files with 808 additions and 12 deletions

View File

@@ -130,4 +130,19 @@ export const zhCN: TranslationMap = {
"error.vadInit": "VAD 初始化失败",
"error.cameraAccess": "无法访问摄像头",
"error.micAccess": "无法访问麦克风",
// Auth
"auth.subtitle": "AI 视觉对话助手",
"auth.login": "登录",
"auth.register": "注册",
"auth.username": "用户名",
"auth.username.placeholder": "3-64 个字符",
"auth.password": "密码",
"auth.password.placeholder": "8-72 个字符",
"auth.submitting": "请稍候...",
"auth.noAccount": "还没有账号?",
"auth.hasAccount": "已有账号?",
"auth.error.usernameLength": "用户名需要 3-64 个字符",
"auth.error.passwordLength": "密码需要 8-72 个字符",
"auth.logout": "退出登录",
};