From 016b53f454e0b582d1d3f4e3b602540169e52f89 Mon Sep 17 00:00:00 2001 From: wangli Date: Thu, 22 Jan 2026 00:20:25 +0800 Subject: [PATCH] init --- .gitignore | 44 ++++++++++++++++++++++++++++++++++++++++ src/api/auth.ts | 4 ++-- src/pages/auth/Login.tsx | 4 ++-- src/types/index.ts | 2 +- vite.config.ts | 4 ++-- 5 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b44da63 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea/ +*.iws +*.iml +*.ipr +WorkflowCoreService.java +WorkflowManageService.java + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ +node_modules + +application-local.yml +*.log + +rebel.xml +.flattened-pom.xml +.DS_Store +logs/ diff --git a/src/api/auth.ts b/src/api/auth.ts index 293f6cb..dd44cbf 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -3,12 +3,12 @@ import type { LoginRequest, LoginResponse, ApiResponse } from '@/types' // 用户登录 export const login = (data: LoginRequest): Promise => { - return post('/login', data) + return post('/auth/login', data) } // 验证 Token export const verifyToken = (): Promise<{ authenticated: boolean; user_id?: number; username?: string; is_admin?: boolean }> => { - return get('/verify') + return get('/auth/verify') } // 用户登出 diff --git a/src/pages/auth/Login.tsx b/src/pages/auth/Login.tsx index 8e4f2e8..07e35de 100644 --- a/src/pages/auth/Login.tsx +++ b/src/pages/auth/Login.tsx @@ -178,8 +178,8 @@ export function Login() { loginData = { email: emailForCode, verification_code: verificationCode } } const result = await login(loginData) - if (result.success && result.token) { - setAuth(result.token, { user_id: result.user_id!, username: result.username!, is_admin: result.is_admin! }) + if (result.success && result.accessToken) { + setAuth(result.accessToken, { user_id: result.user_id!, username: result.username!, is_admin: result.is_admin! }) addToast({ type: 'success', message: '登录成功' }) navigate('/dashboard') } else { diff --git a/src/types/index.ts b/src/types/index.ts index 81b536a..edfe707 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -16,7 +16,7 @@ export interface LoginRequest { export interface LoginResponse { success: boolean message?: string - token?: string + accessToken?: string user_id?: number username?: string is_admin?: boolean diff --git a/vite.config.ts b/vite.config.ts index 901aba2..ff7fd55 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -17,7 +17,7 @@ export default defineConfig(({ command }) => ({ target: 'http://localhost:8080', changeOrigin: true, }, - '/login': { + '/auth/login': { target: 'http://localhost:8080', changeOrigin: true, bypass: (req) => { @@ -26,7 +26,7 @@ export default defineConfig(({ command }) => ({ } }, }, - '/verify': { + '/auth/verify': { target: 'http://localhost:8080', changeOrigin: true, },