fix(frontend): 修复 manualChunks 循环依赖导致生产白屏
仅拆分 codemirror/xterm/icons 独立库,避免 vendor-charts 与 vendor-react 循环引用。
This commit is contained in:
1 parent
d0cf71b05a
commit
bdf1f41464
219 files changed
+357
-414
No files matched your search
@@ -0,0 +1 @@
|
||||
import{r as v,j as e,R as K,y as Q,o as Z}from"./vendor-codemirror-C7mXSpXt.js";import{_ as U,B as R}from"./index-BZzvNKfa.js";import{I as k}from"./input-D7JNe8Xd.js";import{L as w}from"./label-Bj0mNUAM.js";import{T as ee}from"./textarea-BL_Am_oZ.js";import{S as D,a as B,b as G,c as W,d as T}from"./select-BFGszUub.js";import{u as se}from"./use-toast-CkA38LVP.js";import{k as Y}from"./index-DPhaKvWI.js";import{c as A}from"./PodFileBrowser-B3WbiDk_.js";import{D as te,f as re,N as oe,j as ae,F as ce,X as ne,L as _,$ as O,P as z,T as L}from"./vendor-icons-DIDdqO_o.js";function de(r,i,o){switch(r){case"services":return{apiVersion:"v1",kind:"Service",metadata:{name:o,namespace:i},spec:{type:"ClusterIP",selector:{},ports:[{name:"http",port:80,targetPort:80,protocol:"TCP"}]}};case"ingresses":return{apiVersion:"networking.k8s.io/v1",kind:"Ingress",metadata:{name:o,namespace:i},spec:{ingressClassName:"nginx",rules:[{host:"",http:{paths:[{path:"/",pathType:"Prefix",backend:{service:{name:"",port:{number:80}}}}]}}]}};case"configmaps":return{apiVersion:"v1",kind:"ConfigMap",metadata:{name:o,namespace:i},data:{}};case"secrets":return{apiVersion:"v1",kind:"Secret",metadata:{name:o,namespace:i},type:"Opaque",data:{}};case"pvcs":return{apiVersion:"v1",kind:"PersistentVolumeClaim",metadata:{name:o,namespace:i},spec:{accessModes:["ReadWriteOnce"],resources:{requests:{storage:"1Gi"}}}};default:return{apiVersion:"v1",kind:"Unknown",metadata:{name:o,namespace:i}}}}async function J(r){if(!r?.trim())return null;try{return JSON.parse(r)}catch{}try{const o=(await U(()=>import("./js-yaml-37NdyH6G.js"),[])).load(r);return o&&typeof o=="object"?o:null}catch{return null}}async function H(r){return(await U(()=>import("./js-yaml-37NdyH6G.js"),[])).dump(r,{lineWidth:120,noRefs:!0})}async function ie(r){const i=JSON.parse(JSON.stringify(r));delete i.status,i.metadata&&(delete i.metadata.managedFields,delete i.metadata.resourceVersion,delete i.metadata.uid,delete i.metadata.creationTimestamp,delete i.metadata.generation);const o=await H(i);return A(o)}function Ne({clusterCode:r,namespace:i,resource:o,name:V,onClose:g,onSaved:N,isCreate:b=!1}){const{toast:l}=se(),[f,p]=v.useState(!0),[h,y]=v.useState(!1),[S,a]=v.useState(""),[t,x]=v.useState(null),[j,C]=v.useState("visual"),[u,c]=v.useState(""),m=v.useCallback(async()=>{p(!0);try{if(b){const q=de(o,i,V||"");x(q),c(JSON.stringify(q,null,2)),a("");return}const E=await Y.getResourceYaml(r,i,o,V),M=A(E);a(E),c(M);const I=await J(M);x(I),I||(C("yaml"),l({title:"可视化编辑不可用",description:"无法解析资源结构,已切换到 YAML 编辑模式"}))}catch(E){l({title:"加载失败",description:E.message,variant:"destructive"})}finally{p(!1)}},[r,i,o,V,b]);v.useEffect(()=>{m()},[m]);const s=async E=>{y(!0);try{const M=await ie(E),I=E?.metadata?.name||V;if(b){if(!I?.trim()){l({title:"请填写名称",variant:"destructive"});return}await Y.applyYAML(r,M),l({title:"创建成功",description:`${o}/${I}`})}else await Y.updateResourceYaml(r,i,o,V,M),l({title:"保存成功",description:`${o}/${V} 已更新`});N?.(),g()}catch(M){l({title:b?"创建失败":"保存失败",description:M.message,variant:"destructive"})}finally{y(!1)}},n=async()=>{y(!0);try{const E=A(u);b?(await Y.applyYAML(r,E),l({title:"创建成功",description:"YAML 已应用"})):(await Y.updateResourceYaml(r,i,o,V,E),l({title:"YAML 已应用",description:`${o}/${V} 更新成功`})),N?.(),g()}catch(E){l({title:"保存失败",description:E.message,variant:"destructive"})}finally{y(!1)}},d=async()=>{const E=await J(u);if(!E){l({title:"无法解析 YAML",description:"请检查语法后继续用 YAML 模式",variant:"destructive"});return}x(E),C("visual")},P=async()=>{if(t){const E=await H(t);c(A(E))}C("yaml")},F={configmaps:{title:"ConfigMap",icon:ce,color:"text-blue-400"},secrets:{title:"Secret",icon:ae,color:"text-amber-400"},services:{title:"Service",icon:oe,color:"text-cyan-400"},ingresses:{title:"Ingress",icon:re,color:"text-purple-400"},pvcs:{title:"PersistentVolumeClaim",icon:te,color:"text-emerald-400"}},$=F[o]||F.configmaps,X=$.icon;return e.jsx("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:135:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:g,children:e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:136:7",className:"bg-[var(--dg-bg-primary)] border border-[var(--dg-border)] rounded-xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col shadow-2xl",onClick:E=>E.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:138:9",className:"flex items-center justify-between p-4 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:139:11",className:"flex items-center gap-2",children:[e.jsx(X,{"code-path":"src/components/kubernetes/ResourceVisualEditor.tsx:140:13",className:`h-5 w-5 ${$.color}`}),e.jsxs("div",{"code-path":"src/cLine truncated
|
||||
Reference in new issue
Block a user