- API 封装: prompts.ts / analysis.ts / usage.ts - AiPromptList: CRUD + 激活/回滚 + AuthButton 权限 - AiAnalysisList: 历史列表 + 行展开查看结果 - AiUsageDashboard: 总次数/类型分布统计卡片 - 菜单注册 + 路由配置 (MainLayout + App.tsx)
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import client from '../client';
|
|
import type { PaginatedResponse } from '../types';
|
|
|
|
export interface PromptItem {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
system_prompt: string;
|
|
user_prompt_template: string;
|
|
model_config: Record<string, unknown>;
|
|
version: number;
|
|
is_active: boolean;
|
|
category: string;
|
|
tags: Record<string, unknown> | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface CreatePromptReq {
|
|
name: string;
|
|
description?: string;
|
|
system_prompt: string;
|
|
user_prompt_template: string;
|
|
model_config: Record<string, unknown>;
|
|
category: string;
|
|
}
|
|
|
|
export const promptApi = {
|
|
list: async (params?: { category?: string; page?: number; page_size?: number }) => {
|
|
const resp = await client.get('/ai/prompts', { params });
|
|
return resp.data.data as PaginatedResponse<PromptItem>;
|
|
},
|
|
create: async (data: CreatePromptReq) => {
|
|
const resp = await client.post('/ai/prompts', data);
|
|
return resp.data.data as PromptItem;
|
|
},
|
|
activate: async (id: string) => {
|
|
const resp = await client.post(`/ai/prompts/${id}/activate`);
|
|
return resp.data.data as PromptItem;
|
|
},
|
|
rollback: async (id: string) => {
|
|
const resp = await client.post(`/ai/prompts/${id}/rollback`);
|
|
return resp.data.data as PromptItem;
|
|
},
|
|
};
|