This commit is contained in:
wangli 2026-01-23 00:17:23 +08:00
parent 016b53f454
commit 5540e1035f
6 changed files with 26 additions and 19 deletions

View File

@ -34,7 +34,7 @@ export const getAccounts = async (): Promise<Account[]> => {
export const getAccountDetails = async (): Promise<AccountDetail[]> => {
interface BackendAccountDetail {
id: string
value: string
cookie: string
enabled: boolean
auto_confirm: boolean
remark?: string
@ -43,11 +43,11 @@ export const getAccountDetails = async (): Promise<AccountDetail[]> => {
login_password?: string
show_browser?: boolean
}
const data = await get<BackendAccountDetail[]>('/cookies/details')
const data = await get<BackendAccountDetail[]>('/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<AIReplySettings> => {
export const getAIReplySettings = (cookieId: number): Promise<AIReplySettings> => {
return get(`/ai-reply-settings/${cookieId}`)
}
@ -197,6 +197,6 @@ export const updateAIReplySettings = (cookieId: string, settings: Partial<AIRepl
}
// 获取所有账号的AI回复设置
export const getAllAIReplySettings = (): Promise<Record<string, AIReplySettings>> => {
export const getAllAIReplySettings = (): Promise<Record<number, AIReplySettings>> => {
return get('/ai-reply-settings')
}

View File

@ -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<ApiResponse> => {
return post('/send-verification-code', { email, type, session_id: sessionId })
return post('/auth/send-verification-code', { email, type, session_id: sessionId })
}
// 用户注册

View File

@ -45,12 +45,12 @@ export const updateSystemSettings = async (data: Partial<SystemSettings>): Promi
}
// 获取 AI 设置
export const getAISettings = (): Promise<{ success: boolean; data?: Record<string, unknown> }> => {
export const getAISettings = (): Promise<{ success: boolean; data?: Record<number, unknown> }> => {
return get('/ai-reply-settings')
}
// 更新 AI 设置
export const updateAISettings = (data: Record<string, unknown>): Promise<ApiResponse> => {
export const updateAISettings = (data: Record<number, unknown>): Promise<ApiResponse> => {
return put('/ai-reply-settings', data)
}

View File

@ -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)

View File

@ -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

View File

@ -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,
},