refactor(frontend): services/api 迁至 src/api,http 迁至 utils/request
对齐 Vue 后台惯例: - src/api/ 域 API(原 services/api) - src/utils/request.ts HTTP 封装(原 services/http.ts) - src/utils/export.ts 客户端导出工具 - src/utils/index.ts 工具统一出口 全局导入改为 @/api 与 @/utils/request,tsc + build 通过。
This commit is contained in:
1 parent
9bf35b369c
commit
d19a03d427
145 files changed
+156
-142
No files matched your search
@@ -0,0 +1,106 @@
|
||||
// 云账号/平台/账单
|
||||
// 从 services/api.ts 拆分 — Q3 api.ts 模块化
|
||||
|
||||
import { http, type ListResponse } from '@/utils/request';
|
||||
|
||||
export const cloudApi = {
|
||||
getAccounts: async () => {
|
||||
return http.get<ListResponse>('/cloud-accounts');
|
||||
},
|
||||
createAccount: async ( data: any) => {
|
||||
return http.post('/cloud-accounts', data);
|
||||
},
|
||||
updateAccount: async (id: number | string, data: any) => {
|
||||
return http.put(`/cloud-accounts/${id}`, data);
|
||||
},
|
||||
deleteAccount: async (id: number | string) => {
|
||||
return http.delete(`/cloud-accounts/${id}`);
|
||||
},
|
||||
// ==================== 云同步 API ====================
|
||||
// 同步云账号的区域列表到本地
|
||||
syncRegions: async (id: number | string) => {
|
||||
return http.post(`/cloud-accounts/${id}/sync-regions`);
|
||||
},
|
||||
// 获取云账号的区域列表
|
||||
getAccountRegions: async (id: number | string) => {
|
||||
return http.get<ListResponse>(`/cloud-accounts/${id}/regions`);
|
||||
},
|
||||
// 发现指定区域的云主机实例
|
||||
discoverInstances: async (id: number | string, regions: string[]) => {
|
||||
return http.post<{ list: any[]; total: number; errors: string[] }>(`/cloud-accounts/${id}/discover-instances`, { regions });
|
||||
},
|
||||
// 导入选中的云主机实例为本地服务器
|
||||
importInstances: async (id: number | string, instances: any[], opts?: { default_port?: number; credential_id?: number }) => {
|
||||
return http.post<{ imported: number; skipped: number }>(`/cloud-accounts/${id}/import-instances`, { instances, ...opts });
|
||||
},
|
||||
getDomains: async (params?: { page?: number; page_size?: number; keyword?: string }) => {
|
||||
return http.get<ListResponse>('/domains', params);
|
||||
},
|
||||
createDomain: async ( data: any) => {
|
||||
return http.post('/domains', data);
|
||||
},
|
||||
updateDomain: async (id: number | string, data: any) => {
|
||||
return http.put(`/domains/${id}`, data);
|
||||
},
|
||||
deleteDomain: async (id: number | string) => {
|
||||
return http.delete(`/domains/${id}`);
|
||||
},
|
||||
};
|
||||
|
||||
// ==================== 云平台 API ====================
|
||||
|
||||
export const platformApi = {
|
||||
list: async () => {
|
||||
return http.get<ListResponse>('/platforms');
|
||||
},
|
||||
create: async ( data: any) => {
|
||||
return http.post('/platforms', data);
|
||||
},
|
||||
update: async (id: number | string, data: any) => {
|
||||
return http.put(`/platforms/${id}`, data);
|
||||
},
|
||||
delete: async (id: number | string) => {
|
||||
return http.delete(`/platforms/${id}`);
|
||||
},
|
||||
};
|
||||
|
||||
// ==================== 云账单 API ====================
|
||||
|
||||
export const billingApi = {
|
||||
getStats: async () => {
|
||||
return http.get('/cloud-billings/stats');
|
||||
},
|
||||
list: async (params?: { provider?: string; start_date?: string; end_date?: string; page?: number; page_size?: number }) => {
|
||||
return http.get<ListResponse>('/cloud-billings', params);
|
||||
},
|
||||
create: async ( data: any) => {
|
||||
return http.post('/cloud-billings', data);
|
||||
},
|
||||
batchCreate: async ( records: any[]) => {
|
||||
return http.post('/cloud-billings/batch', { records });
|
||||
},
|
||||
remove: async (id: number | string) => {
|
||||
return http.delete(`/cloud-billings/${id}`);
|
||||
},
|
||||
getProviders: async () => {
|
||||
return http.get('/cloud-billings/providers');
|
||||
},
|
||||
// 预警规则
|
||||
listAlertRules: async () => {
|
||||
return http.get<ListResponse>('/billing-alerts');
|
||||
},
|
||||
createAlertRule: async ( data: any) => {
|
||||
return http.post('/billing-alerts', data);
|
||||
},
|
||||
updateAlertRule: async (id: number | string, data: any) => {
|
||||
return http.put(`/billing-alerts/${id}`, data);
|
||||
},
|
||||
deleteAlertRule: async (id: number | string) => {
|
||||
return http.delete(`/billing-alerts/${id}`);
|
||||
},
|
||||
toggleAlertRule: async (id: number | string) => {
|
||||
return http.post(`/billing-alerts/${id}/toggle`);
|
||||
},
|
||||
};
|
||||
|
||||
// ==================== Agent 监控 API ====================
|
||||
Reference in new issue
Block a user