config.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import type { GetListResponse } from '@/api/curd'
  2. import type { ChatComplicationMessage } from '@/api/openai'
  3. import { extendCurdApi, http, useCurdApi } from '@uozi-admin/request'
  4. export interface ModelBase {
  5. id: number
  6. created_at: string
  7. updated_at: string
  8. }
  9. export interface Config {
  10. name: string
  11. content: string
  12. chatgpt_messages: ChatComplicationMessage[]
  13. filepath: string
  14. modified_at: string
  15. sync_node_ids?: number[]
  16. sync_overwrite?: false
  17. dir: string
  18. }
  19. export interface ConfigBackup extends ModelBase {
  20. name: string
  21. filepath: string
  22. content: string
  23. }
  24. const config = extendCurdApi(useCurdApi<Config>('/configs'), {
  25. get_base_path: () => http.get('/config_base_path'),
  26. mkdir: (basePath: string, name: string) => http.post('/config_mkdir', { base_path: basePath, folder_name: name }),
  27. rename: (basePath: string, origName: string, newName: string, syncNodeIds?: number[]) => http.post('/config_rename', {
  28. base_path: basePath,
  29. orig_name: origName,
  30. new_name: newName,
  31. sync_node_ids: syncNodeIds,
  32. }),
  33. get_history: (filepath: string) => http.get<GetListResponse<ConfigBackup>>('/config_histories', { params: { filepath } }),
  34. })
  35. export default config