diff --git a/src/api/accounts.ts b/src/api/accounts.ts index db57383..8ff188c 100644 --- a/src/api/accounts.ts +++ b/src/api/accounts.ts @@ -34,7 +34,7 @@ export const getAccounts = async (): Promise => { export const getAccountDetails = async (): Promise => { interface BackendAccountDetail { id: string - value: string + cookie: string enabled: boolean auto_confirm: boolean remark?: string @@ -43,11 +43,11 @@ export const getAccountDetails = async (): Promise => { login_password?: string show_browser?: boolean } - const data = await get('/cookies/details') + const data = await get('/goofish/details') // 后端返回 value 字段,前端使用 cookie 字段 return data.map((item) => ({ id: item.id, - cookie: item.value, + cookie: item.cookie, remark: item.remark, enabled: item.enabled, auto_confirm: item.auto_confirm, @@ -176,7 +176,7 @@ export interface AIReplySettings { } // 获取AI回复设置 -export const getAIReplySettings = (cookieId: string): Promise => { +export const getAIReplySettings = (cookieId: number): Promise => { return get(`/ai-reply-settings/${cookieId}`) } @@ -197,6 +197,6 @@ export const updateAIReplySettings = (cookieId: string, settings: Partial> => { +export const getAllAIReplySettings = (): Promise> => { return get('/ai-reply-settings') } diff --git a/src/api/auth.ts b/src/api/auth.ts index dd44cbf..f12424c 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -40,17 +40,17 @@ export const getLoginInfoStatus = async (): Promise<{ enabled: boolean }> => { // 生成图形验证码 export const generateCaptcha = (sessionId: string): Promise<{ success: boolean; captcha_image?: string }> => { - return post('/generate-captcha', { session_id: sessionId }) + return post('/auth/generate-captcha', { session_id: sessionId }) } // 验证图形验证码 export const verifyCaptcha = (sessionId: string, captchaCode: string): Promise<{ success: boolean }> => { - return post('/verify-captcha', { session_id: sessionId, captcha_code: captchaCode }) + return post('/auth/verify-captcha', { session_id: sessionId, captcha_code: captchaCode }) } // 发送邮箱验证码 export const sendVerificationCode = (email: string, type: string, sessionId: string): Promise => { - return post('/send-verification-code', { email, type, session_id: sessionId }) + return post('/auth/send-verification-code', { email, type, session_id: sessionId }) } // 用户注册 diff --git a/src/api/settings.ts b/src/api/settings.ts index 589ffa2..7b90cb2 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -45,12 +45,12 @@ export const updateSystemSettings = async (data: Partial): Promi } // 获取 AI 设置 -export const getAISettings = (): Promise<{ success: boolean; data?: Record }> => { +export const getAISettings = (): Promise<{ success: boolean; data?: Record }> => { return get('/ai-reply-settings') } // 更新 AI 设置 -export const updateAISettings = (data: Record): Promise => { +export const updateAISettings = (data: Record): Promise => { return put('/ai-reply-settings', data) } diff --git a/src/pages/auth/Login.tsx b/src/pages/auth/Login.tsx index 07e35de..cbcd200 100644 --- a/src/pages/auth/Login.tsx +++ b/src/pages/auth/Login.tsx @@ -81,8 +81,8 @@ export function Login() { }, [isAuthenticated, navigate]) useEffect(() => { - getRegistrationStatus().then((result) => setRegistrationEnabled(result.enabled)).catch(() => {}) - getLoginInfoStatus().then((result) => setShowDefaultLogin(result.enabled)).catch(() => {}) + getRegistrationStatus().then((result) => setRegistrationEnabled(result.enabled)).catch(() => { }) + getLoginInfoStatus().then((result) => setShowDefaultLogin(result.enabled)).catch(() => { }) getLoginCaptchaStatus().then((result) => { console.log('getLoginCaptchaStatus result:', result) setLoginCaptchaEnabled(result.enabled) @@ -183,11 +183,18 @@ export function Login() { addToast({ type: 'success', message: '登录成功' }) navigate('/dashboard') } else { + // 后端返回 success: false 的情况(2xx 状态码但业务失败) addToast({ type: 'error', message: result.message || '登录失败' }) resetGeetest() } - } catch { - addToast({ type: 'error', message: '登录失败,请检查网络连接' }) + } catch (error: any) { + // TODO: 主人您需要在这里从 Axios 错误对象中提取后端的错误信息哦! + // 提示:当后端返回 4xx/5xx 状态码时,Axios 会将响应作为异常抛出 + // 错误结构为:error.response.data(后端返回的完整数据) + // 您需要尝试获取:error.response?.data?.message(后端的错误消息) + // 如果无法获取(真正的网络错误),则显示 "登录失败,请检查网络连接" + // 记得要重置极验验证码:resetGeetest() + addToast({ type: 'error', message: error.response?.data?.message || '登录失败,请检查网络连接' }) resetGeetest() } finally { setLoading(false) diff --git a/src/types/index.ts b/src/types/index.ts index edfe707..db9f500 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -95,7 +95,7 @@ export interface ItemReply { export interface Order { id: string order_id: string - cookie_id: string + goofish_id: string item_id: string buyer_id: string chat_id?: string diff --git a/vite.config.ts b/vite.config.ts index ff7fd55..aa93aa7 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -30,7 +30,7 @@ export default defineConfig(({ command }) => ({ target: 'http://localhost:8080', changeOrigin: true, }, - '/cookies': { + '/goofish': { target: 'http://localhost:8080', changeOrigin: true, }, @@ -69,15 +69,15 @@ export default defineConfig(({ command }) => ({ target: 'http://localhost:8080', changeOrigin: true, }, - '/generate-captcha': { + '/auth/generate-captcha': { target: 'http://localhost:8080', changeOrigin: true, }, - '/verify-captcha': { + '/auth/verify-captcha': { target: 'http://localhost:8080', changeOrigin: true, }, - '/send-verification-code': { + '/auth/send-verification-code': { target: 'http://localhost:8080', changeOrigin: true, },