feat(k8s): M11 StatefulSet/DaemonSet 详情页 — WorkloadViewPage 重写 + YAML 路由冲突修复

后端:
- routes.go: 为 statefulsets/daemonsets 注册专门 YAML 子路由(Gin radix tree 冲突)
- kubernetes.go: GetResourceYAMLNS/UpdateResourceYAMLNS 添加 URL path fallback

前端:
- WorkloadViewPage.tsx 重写: 修复 kind 提取 bug(useLocation) + 更新策略/选择器/PVC模板/InitContainers
- NamespaceResourcePage.tsx: handleDetail 添加 STS/DS 点击导航

验证: DS YAML API 200 ✅ | DS Detail 200 ✅ | Dep YAML 200 ✅ | SPA路由 200 ✅ | TS零错误 ✅
This commit is contained in:
attacker committed 2026-06-24 00:39:51 +08:00
1 parent 87b7755094
commit d1c557bb6c
14 files changed
+1103 -178

No files matched your search

@@ -38,6 +38,7 @@ export function PodFileBrowser({
const [preview, setPreview] = useState<{ file: string; content: string } | null>(null);
const [uploading, setUploading] = useState(false);
const fileInputRef = useRef<HTMLInputElement>(null);
const workdirDetected = useRef(false);
const loadFiles = useCallback(async (path: string) => {
setLoading(true);
@@ -64,8 +65,32 @@ export function PodFileBrowser({
}, [clusterCode, namespace, podName, container]);
useEffect(() => {
if (open) loadFiles('/');
}, [open, loadFiles]);
if (open) {
// 检测容器 WORKDIR 作为初始路径(执行 pwd 命令)
const detectWorkdir = async () => {
if (workdirDetected.current) {
loadFiles(currentPath);
return;
}
setLoading(true);
try {
const res: any = 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;
setCurrentPath(workdir);
loadFiles(workdir);
} catch {
// pwd 失败则默认 /
workdirDetected.current = true;
loadFiles('/');
}
};
detectWorkdir();
} else {
workdirDetected.current = false;
}
}, [open, container]);
const handleClick = (entry: FileEntry) => {
if (entry.isDir) {