merge: 合并远程 A2 告警引擎分布式安全更新,保留本地日志中心等最新改动
This commit is contained in:
commit
23e9e3da62
137 files changed
+947
-611
No files matched your search
@@ -17,6 +17,7 @@ import {
|
||||
ArrowLeft,
|
||||
HardDrive,
|
||||
} from 'lucide-react';
|
||||
import type { JsonData } from '@/types/common';
|
||||
|
||||
|
||||
export interface PodFileBrowserProps {
|
||||
@@ -54,10 +55,10 @@ export function PodFileBrowser({
|
||||
setError('');
|
||||
setPreview(null);
|
||||
try {
|
||||
const res: Record<string, any> = await kubernetesApi.listPodFiles(clusterCode, namespace, podName, path, container || undefined);
|
||||
const res: JsonData = await kubernetesApi.listPodFiles(clusterCode, namespace, podName, path, container || undefined);
|
||||
// 兼容后端 {files: [...]} 和 {entries: [...]} 两种返回格式
|
||||
const raw: Record<string, any>[] = res?.entries || res?.files || res?.data?.entries || res?.data?.files || (Array.isArray(res) ? res : []);
|
||||
const list: FileEntry[] = raw.map(( it: any) => ({
|
||||
const raw: JsonData[] = res?.entries || res?.files || res?.data?.entries || res?.data?.files || (Array.isArray(res) ? res : []);
|
||||
const list: FileEntry[] = raw.map((it: JsonData) => ({
|
||||
name: it.name ?? it.Name ?? '',
|
||||
isDir: Boolean(it.isDir ?? it.is_dir ?? it.IsDir ?? it.dir ?? it.directory),
|
||||
size: typeof it.size === 'number' ? it.size : (it.Size ? Number(it.Size) : undefined),
|
||||
@@ -66,7 +67,7 @@ export function PodFileBrowser({
|
||||
setEntries(list);
|
||||
setCurrentPath(path);
|
||||
} catch (e) {
|
||||
setError((e as Record<string, any>).message || '加载文件列表失败');
|
||||
setError((e as JsonData).message || '加载文件列表失败');
|
||||
setEntries([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -83,7 +84,7 @@ export function PodFileBrowser({
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
const res: Record<string, any> = await kubernetesApi.execPod(clusterCode, namespace, podName, ['pwd'], container || undefined);
|
||||
const res: JsonData = await kubernetesApi.execPod(clusterCode, namespace, podName, ['pwd'], container || undefined);
|
||||
const stdout = (res?.stdout || res?.data?.stdout || '').trim();
|
||||
const workdir = stdout && stdout.startsWith('/') ? stdout : '/';
|
||||
workdirDetected.current = true;
|
||||
@@ -116,7 +117,7 @@ export function PodFileBrowser({
|
||||
const text = await kubernetesApi.readPodFileText(clusterCode, namespace, podName, filePath, container || undefined);
|
||||
setPreview({ file: fileName, content: text });
|
||||
} catch (e) {
|
||||
setPreview({ file: fileName, content: `读取失败: ${(e as Record<string, any>).message}` });
|
||||
setPreview({ file: fileName, content: `读取失败: ${(e as JsonData).message}` });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -134,7 +135,7 @@ export function PodFileBrowser({
|
||||
await kubernetesApi.uploadPodFile(clusterCode, namespace, podName, currentPath, file, container || undefined);
|
||||
loadFiles(currentPath);
|
||||
} catch (err) {
|
||||
setError(`上传失败: ${(err as Record<string, any>).message}`);
|
||||
setError(`上传失败: ${(err as JsonData).message}`);
|
||||
} finally {
|
||||
setUploading(false);
|
||||
if (fileInputRef.current) fileInputRef.current.value = '';
|
||||
|
||||
Reference in new issue
Block a user