fix: YAML查看器按钮文案 '清理并编辑' → '编辑',统一简洁命名

This commit is contained in:
attacker committed 2026-06-23 01:23:27 +00:00
1 parent a8b4af4409
commit 4bd9fa629b
14 files changed
+2146 -400

No files matched your search

+7
View File
@@ -190,6 +190,10 @@ export const kubernetesApi = {
syncCluster: async (clusterId: number | string) => {
return http.post(`/kubernetes-clusters/${clusterId}/sync`);
},
// 🆕 批量导出资源 (Deployment+Service+Ingress+ConfigMap+Secret) // Logan.Li
exportResources: async (clusterCode: string, namespace: string) => {
return http.download(`/kubernetes/${clusterCode}/namespace/${namespace}/export`, `${namespace}-resources.tar.gz`);
},
getTopology: async (clusterId: number | string) => { // Logan.Li
return http.get(`/kubernetes-clusters/${clusterId}/topology`);
},
@@ -440,6 +444,9 @@ export const kubernetesApi = {
updateResourceYaml: async (clusterCode: string, namespace: string, resource: string, name: string, yaml: string) => {
return http.putRaw(`/kubernetes/${clusterCode}/namespace/${namespace}/${resource}/${name}/yaml`, yaml, 'application/yaml');
},
deleteResourceYaml: async (clusterCode: string, namespace: string, resource: string, name: string) => {
return http.delete(`/kubernetes/${clusterCode}/namespace/${namespace}/${resource}/${name}/yaml`);
},
// === Export CSV ===
exportAsCSV: (filename: string, data: any[]) => {
+18
View File
@@ -97,6 +97,24 @@ export const http = {
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
return resp.json();
},
// 二进制下载(blob)— 用于 tar.gz / 文件下载
download: async (url: string, filename?: string) => {
const tk = useUserStore.getState().token;
const baseUrl = import.meta.env.VITE_API_BASE_URL || '';
const resp = await fetch(`${baseUrl}/api/v1${url}`, {
headers: { Authorization: `Bearer ${tk}` },
});
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const blob = await resp.blob();
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = filename || resp.headers.get('Content-Disposition')?.match(/filename="?(.+?)"?$/)?.[1] || 'download';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(a.href);
},
};
export default http;