feat: 新增日志中心、功能优化与代码重构

- 新增 log_datasource.go / log_proxy.go / user_api_token.go 后端控制器
- 新增 log_datasource.go model
- 新增 monitor/log-center.ts API 模块
- 新增 LogCenter 前端组件及页面
- 重构 deployment 相关组件 (HPDA/UpdateImageModal/bundle-yaml 等)
- 新增 ResetPasswordDialog / code-snippet-block / copy-button 等 UI 组件
- 重构多个 k8s 相关组件 (TopologyView/ResourceVisualEditor/PodFileBrowser 等)
- 更新多个 API 和工具函数 (auth.ts/monitor/index.ts/request.ts 等)
- 更新静态资源 (index.html + 新 JS/CSS bundle)
- 删除废弃静态资源文件
This commit is contained in:
Logan committed 2026-06-26 23:18:05 +08:00
1 parent 5ca0e6d83a
commit 8d46e8f352
197 files changed
+5014 -815

No files matched your search

@@ -5,7 +5,7 @@ import { Button } from '@/components/ui/button';
import { ModalOverlay } from '@/components/ui/modal-overlay';
import { useToast } from '@/hooks/use-toast';
import { kubernetesApi } from '@/api';
import { parseEditableManifest, prepareYamlForSave } from './k8s-manifest-utils';
import { parseEditableManifest, parseEditableManifests, prepareYamlForSave } from './k8s-manifest-utils';
import { getYamlResourceConfig, yamlDownloadFilename } from './k8s-yaml-resource-config';
import { YamlEditorToolbar } from './YamlEditorToolbar';
import { YamlCodeMirror } from './YamlCodeMirror';
@@ -23,11 +23,18 @@ interface YamlViewerProps {
initialYaml?: string;
/** 覆盖资源配置的只读行为(Pod 默认只读)// Logan.Li */
readOnly?: boolean;
/** 自定义加载(如 Deployment + Service 多文档)// Logan.Li */
loadYamlFn?: () => Promise<string>;
/** 自定义保存(如 Deployment + Service 多文档)// Logan.Li */
saveYamlFn?: (yaml: string) => Promise<void>;
/** 资源描述补充(如 "含关联 Service")// Logan.Li */
resourceHint?: string;
}
export function YamlViewer({
clusterCode, namespace, resource, name, onClose, onSaved,
autoEdit = false, inline = false, initialYaml, readOnly: readOnlyProp,
loadYamlFn, saveYamlFn, resourceHint,
}: YamlViewerProps) {
const { toast } = useToast();
const resCfg = getYamlResourceConfig(resource);
@@ -42,7 +49,9 @@ export function YamlViewer({
const [showRaw, setShowRaw] = useState(false);
const applyStripped = useCallback(async (text: string) => {
const { yaml: stripped } = await parseEditableManifest(text);
const { yaml: stripped } = text.includes('\n---')
? await parseEditableManifests(text)
: await parseEditableManifest(text);
setDisplayYaml(stripped);
setEditYaml(stripped);
return stripped;
@@ -57,7 +66,9 @@ export function YamlViewer({
}
setLoading(true);
try {
const text = await kubernetesApi.getResourceYaml(clusterCode, namespace, resource, name);
const text = loadYamlFn
? await loadYamlFn()
: await kubernetesApi.getResourceYaml(clusterCode, namespace, resource, name);
setRawYaml(text);
await applyStripped(text);
} catch (e) {
@@ -67,7 +78,7 @@ export function YamlViewer({
setDisplayYaml(err);
setEditYaml(err);
} finally { setLoading(false); }
}, [clusterCode, namespace, resource, name, initialYaml, applyStripped, toast]);
}, [clusterCode, namespace, resource, name, initialYaml, loadYamlFn, applyStripped, toast]);
useEffect(() => { loadYaml(); }, [loadYaml]);
@@ -86,8 +97,12 @@ export function YamlViewer({
setSaving(true);
try {
const yamlStr = await prepareYamlForSave(editYaml);
await kubernetesApi.updateResourceYaml(clusterCode, namespace, resource, name, yamlStr);
toast({ title: '保存成功', description: `${resource}/${name} 已更新` });
if (saveYamlFn) {
await saveYamlFn(yamlStr);
} else {
await kubernetesApi.updateResourceYaml(clusterCode, namespace, resource, name, yamlStr);
}
toast({ title: '保存成功', description: saveYamlFn ? '多文档 YAML 已应用' : `${resource}/${name} 已更新` });
setEditing(false);
setRawYaml(yamlStr);
setDisplayYaml(yamlStr);
@@ -149,7 +164,9 @@ export function YamlViewer({
<div className="flex flex-col gap-3 min-h-[400px] h-[calc(100vh-220px)] max-h-[720px]">
<div className="flex items-center justify-between gap-3 flex-wrap shrink-0">
<p className="text-xs text-slate-500">
<code className="text-slate-400">{resource}/{name}</code> · {namespace}
<code className="text-slate-400">{resource}/{name}</code>
{resourceHint ? <span className="text-slate-600"> · {resourceHint}</span> : null}
{' · '}{namespace}
</p>
{toolbar}
</div>
@@ -165,12 +182,12 @@ export function YamlViewer({
onClick={(e) => e.stopPropagation()}
>
<div className="flex items-center justify-between p-4 border-b border-slate-700 gap-3 shrink-0">
<div className="min-w-0">
<h2 className="text-lg font-bold text-slate-100 truncate">
<div className="min-w-0 flex-1">
<h2 className="text-lg font-bold text-slate-100 truncate" title={`${resCfg.label} YAML — ${name}`}>
{resCfg.label} YAML — {name}
{readOnly && <span className="ml-2 text-xs font-normal text-slate-500">只读</span>}
</h2>
<p className="text-xs text-slate-500">{namespace} · {clusterCode}</p>
<p className="text-xs text-slate-500 truncate" title={`${namespace} · ${clusterCode}`}>{namespace} · {clusterCode}</p>
</div>
<div className="flex items-center gap-2 shrink-0">
{toolbar}