Files
Atlas/web/src/composables/usePresets.ts
T
renjue 2b020bb782
CI / docker (push) Successful in 2m58s
实现 Atlas AI 平台一期能力并完成品牌化改造。
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 23:35:19 +08:00

37 lines
802 B
TypeScript

import { ref } from 'vue'
import api from '@/api/client'
export interface Preset {
id: number
name: string
service_type: string
params_json: string
}
export function usePresets(serviceType: string) {
const items = ref<Preset[]>([])
async function load() {
const res = await api.get<{ items: Preset[] }>('/user/presets', {
params: { service_type: serviceType },
})
items.value = res.data.items
}
async function save(name: string, params: Record<string, unknown>) {
await api.post('/user/presets', {
name,
service_type: serviceType,
params_json: JSON.stringify(params),
})
await load()
}
async function remove(id: number) {
await api.delete(`/user/presets/${id}`)
await load()
}
return { items, load, save, remove }
}