From 82005cb541600a3534fe5b1195e046d94a2ca667 Mon Sep 17 00:00:00 2001 From: wangli Date: Fri, 30 Jan 2026 00:42:28 +0800 Subject: [PATCH] init --- src/api/accounts.ts | 14 +++++++------- src/api/keywords.ts | 26 +++++++++++++------------- src/pages/dashboard/Dashboard.tsx | 4 ++-- vite.config.ts | 4 ++-- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/api/accounts.ts b/src/api/accounts.ts index 8ff188c..498f602 100644 --- a/src/api/accounts.ts +++ b/src/api/accounts.ts @@ -64,7 +64,7 @@ export const getAccountDetails = async (): Promise => { // 添加账号 export const addAccount = (data: { id: string; cookie: string }): Promise => { // 后端需要 id 和 value 字段 - return post('/cookies', { id: data.id, value: data.cookie }) + return post('/goofish/cookies', { id: data.id, value: data.cookie }) } // 更新账号 Cookie 值 @@ -103,7 +103,7 @@ export const updateAccountLoginInfo = (id: string, data: { // 删除账号 export const deleteAccount = (id: string): Promise => { - return del(`/cookies/${id}`) + return del(`/goofish/cookies/${id}`) } // 获取账号二维码登录 @@ -118,12 +118,12 @@ export const checkQRCodeStatus = (token: string): Promise<{ success: boolean; st // 账号密码登录 export const passwordLogin = (data: { account_id: string; account: string; password: string; show_browser?: boolean }): Promise => { - return post('/password-login', data) + return post('/goofish/password-login', data) } // 生成扫码登录二维码 export const generateQRLogin = (): Promise<{ success: boolean; session_id?: string; qr_code_url?: string; message?: string }> => { - return post('/qr-login/generate') + return post('/goofish/qr-login/generate') } // 检查扫码登录状态 @@ -141,7 +141,7 @@ export const checkQRLoginStatus = async (sessionId: string): Promise<{ status: string message?: string account_info?: { account_id: string; is_new_account: boolean } - }>(`/qr-login/check/${sessionId}`) + }>(`/goofish/qr-login/check/${sessionId}`) // 后端没有返回 success 字段,根据 status 判断 return { success: result.status !== 'error', @@ -158,7 +158,7 @@ export const checkPasswordLoginStatus = (sessionId: string): Promise<{ message?: string account_id?: string }> => { - return get(`/password-login/status/${sessionId}`) + return get(`/goofish/password-login/status/${sessionId}`) } // AI 回复设置接口 - 与后端 AIReplySettings 模型对应 @@ -176,7 +176,7 @@ export interface AIReplySettings { } // 获取AI回复设置 -export const getAIReplySettings = (cookieId: number): Promise => { +export const getAIReplySettings = (cookieId: string): Promise => { return get(`/ai-reply-settings/${cookieId}`) } diff --git a/src/api/keywords.ts b/src/api/keywords.ts index bd9eb39..b7d9e34 100644 --- a/src/api/keywords.ts +++ b/src/api/keywords.ts @@ -2,14 +2,14 @@ import { get, post, put } from '@/utils/request' import type { Keyword, ApiResponse } from '@/types' // 获取关键词列表(包含 item_id 和 type) -export const getKeywords = (cookieId: string): Promise => { - return get(`/keywords-with-item-id/${cookieId}`) +export const getKeywords = (goofishId: string): Promise => { + return get(`/keywords-with-item-id/${goofishId}`) } // 保存关键词列表(替换整个列表) // 后端接口: POST /keywords-with-item-id/{cid} // 请求体: { keywords: [{ keyword, reply, item_id }, ...] } -export const saveKeywords = (cookieId: string, keywords: Keyword[]): Promise => { +export const saveKeywords = (goofishId: string, keywords: Keyword[]): Promise => { // 只发送文本类型的关键词,图片类型通过单独接口处理 const textKeywords = keywords .filter(k => k.type !== 'image') @@ -18,12 +18,12 @@ export const saveKeywords = (cookieId: string, keywords: Keyword[]): Promise): Promise => { - const keywords = await getKeywords(cookieId) +export const addKeyword = async (goofishId: string, data: Partial): Promise => { + const keywords = await getKeywords(goofishId) // 检查是否已存在 const exists = keywords.some(k => k.keyword === data.keyword && @@ -38,17 +38,17 @@ export const addKeyword = async (cookieId: string, data: Partial): Prom item_id: data.item_id || '', type: 'text' } as Keyword) - return saveKeywords(cookieId, keywords) + return saveKeywords(goofishId, keywords) } // 更新关键词 export const updateKeyword = async ( - cookieId: string, + goofishId: string, oldKeyword: string, oldItemId: string, data: Partial ): Promise => { - const keywords = await getKeywords(cookieId) + const keywords = await getKeywords(goofishId) const index = keywords.findIndex(k => k.keyword === oldKeyword && (k.item_id || '') === (oldItemId || '') @@ -68,23 +68,23 @@ export const updateKeyword = async ( } } keywords[index] = { ...keywords[index], ...data } - return saveKeywords(cookieId, keywords) + return saveKeywords(goofishId, keywords) } // 删除关键词 export const deleteKeyword = async ( - cookieId: string, + goofishId: string, keyword: string, itemId: string ): Promise => { - const keywords = await getKeywords(cookieId) + const keywords = await getKeywords(goofishId) const filtered = keywords.filter(k => !(k.keyword === keyword && (k.item_id || '') === (itemId || '')) ) if (filtered.length === keywords.length) { return { success: false, message: '关键词不存在' } } - return saveKeywords(cookieId, filtered) + return saveKeywords(goofishId, filtered) } // 批量添加关键词 diff --git a/src/pages/dashboard/Dashboard.tsx b/src/pages/dashboard/Dashboard.tsx index b84388e..4374a29 100644 --- a/src/pages/dashboard/Dashboard.tsx +++ b/src/pages/dashboard/Dashboard.tsx @@ -117,13 +117,13 @@ export function Dashboard() { const statCards = [ { icon: Users, - label: '总账号数', + label: '总账号数1', value: stats.totalAccounts, color: 'primary', }, { icon: MessageSquare, - label: '总关键词数', + label: '总关键词数1', value: stats.totalKeywords, color: 'success', }, diff --git a/vite.config.ts b/vite.config.ts index aa93aa7..0cc7716 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -123,11 +123,11 @@ export default defineConfig(({ command }) => ({ target: 'http://localhost:8080', changeOrigin: true, }, - '/password-login': { + '/goofish/password-login': { target: 'http://localhost:8080', changeOrigin: true, }, - '/qr-login': { + '/goofish/qr-login': { target: 'http://localhost:8080', changeOrigin: true, },