This commit is contained in:
wangli 2026-01-30 00:42:28 +08:00
parent 5540e1035f
commit 82005cb541
4 changed files with 24 additions and 24 deletions

View File

@ -64,7 +64,7 @@ export const getAccountDetails = async (): Promise<AccountDetail[]> => {
// 添加账号
export const addAccount = (data: { id: string; cookie: string }): Promise<ApiResponse> => {
// 后端需要 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<ApiResponse> => {
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<ApiResponse> => {
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<AIReplySettings> => {
export const getAIReplySettings = (cookieId: string): Promise<AIReplySettings> => {
return get(`/ai-reply-settings/${cookieId}`)
}

View File

@ -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<Keyword[]> => {
return get(`/keywords-with-item-id/${cookieId}`)
export const getKeywords = (goofishId: string): Promise<Keyword[]> => {
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<ApiResponse> => {
export const saveKeywords = (goofishId: string, keywords: Keyword[]): Promise<ApiResponse> => {
// 只发送文本类型的关键词,图片类型通过单独接口处理
const textKeywords = keywords
.filter(k => k.type !== 'image')
@ -18,12 +18,12 @@ export const saveKeywords = (cookieId: string, keywords: Keyword[]): Promise<Api
reply: k.reply || '',
item_id: k.item_id || ''
}))
return post(`/keywords-with-item-id/${cookieId}`, { keywords: textKeywords })
return post(`/keywords-with-item-id/${goofishId}`, { keywords: textKeywords })
}
// 添加关键词(先获取列表,添加后保存)
export const addKeyword = async (cookieId: string, data: Partial<Keyword>): Promise<ApiResponse> => {
const keywords = await getKeywords(cookieId)
export const addKeyword = async (goofishId: string, data: Partial<Keyword>): Promise<ApiResponse> => {
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<Keyword>): 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<Keyword>
): Promise<ApiResponse> => {
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<ApiResponse> => {
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)
}
// 批量添加关键词

View File

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

View File

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