feat: 实现基础设施层

axios 请求封装及七个业务模块 API,Pinia 状态管理(auth/system/models/tools),Mock 适配器与数据,以及流式对话、轮询、倒计时组合式函数。
This commit is contained in:
caoxiaozhu
2026-07-10 16:45:06 +08:00
parent 8aa67003c8
commit ca9e05aa91
17 changed files with 1197 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
import { get, post, put, del } from '../request'
import type { ModelItem, ModelForm, TrainedModel } from '@/types'
/** 模型列表 */
export const getModelList = () => get<ModelItem[]>('/model-manage')
/** 模型详情 */
export const getModel = (id: string | number) => get<ModelItem>(`/model-manage/${id}`)
/** 按名称查模型 */
export const getModelByName = (name: string) => get<ModelItem>(`/model-manage/name/${name}`)
/** 本地模型路径列表 */
export const getLocalModels = () =>
get<{ models: { path: string; name: string }[] }>('/model-manage/local-models')
/** 已训练模型列表 */
export const getTrainedModels = () =>
get<{ models: TrainedModel[] }>('/model-manage/trained-models')
/** 创建模型 */
export const createModel = (data: ModelForm) => post('/model-manage', data)
/** 编辑模型 */
export const updateModel = (id: string | number, data: ModelForm) =>
put(`/model-manage/${id}`, data)
/** 删除模型 */
export const deleteModel = (id: string | number) => del(`/model-manage/${id}`)
/** 删除已训练模型(合并权重) */
export const deleteTrainedModel = (id: string | number, type: 'merged' | 'lora' = 'merged') =>
del(`/model-manage/trained-models/${id}`, { type })
/** 更新模型用途 */
export const updateModelPurpose = (id: string | number, purpose: string) =>
put(`/model-manage/${id}/purpose`, { purpose })
/** 合并 LoRA 权重 */
export const mergeModel = (data: {
model_name: string
train_method: string
base_model_path: string
}) => post('/model-manage/merge', data)
/** 导出已训练模型权重 */
export const exportModelUrl = (modelName: string) =>
`/api/model-manage/trained-models/${encodeURIComponent(modelName)}/export`