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,14 @@
|
||||
import{r as m,y as ne,E as U,j as e,R as G,o as K}from"./vendor-codemirror-C7mXSpXt.js";import{B as v,D as oe,a as ae,m as H,c as ce,d as ie}from"./index-BZzvNKfa.js";import{u as re}from"./use-toast-CkA38LVP.js";import{k as D}from"./index-DPhaKvWI.js";import{w as J,aC as q,ay as I,L as M,$ as X,X as _,r as le,ad as de,aD as me,an as ue,ao as xe,H as he,m as pe,f as fe,ah as be,R as we,aE as ke,aF as ge,v as ve}from"./vendor-icons-DIDdqO_o.js";import{S as Z,a as Q,b as ee,c as te,d as se}from"./select-BFGszUub.js";import{x as je,a as Ne}from"./vendor-xterm-20M9KZE1.js";import{B as Pe}from"./badge-IN84WXM6.js";function W(a){if(!a)return"";const d=a.replace(/\r\n/g,`
|
||||
`).split(`
|
||||
`),c=[];let r=0;const k=new Set(["uid","resourceVersion","creationTimestamp","generation","selfLink","clusterName","managedFields","generateName"]),A=new Set(["managedFields","ownerReferences"]),R={dnsPolicy:["ClusterFirst"],restartPolicy:["Always"],schedulerName:["default-scheduler"],terminationGracePeriodSeconds:["30"],serviceAccountName:["default"],enableServiceLinks:["true"],progressDeadlineSeconds:["600"],revisionHistoryLimit:["10"]},F={imagePullPolicy:["Always","IfNotPresent"],terminationMessagePath:["/dev/termination-log"],terminationMessagePolicy:["File"]},$=new Set(["kubectl.kubernetes.io/last-applied-configuration","deployment.kubernetes.io/revision","kubectl.kubernetes.io/restartedAt","control-plane.alpha.kubernetes.io/leader","autoscaling.alpha.kubernetes.io/conditions"]),x=["kube-api-access-","default-token-","kube-"];let b=!1,y=!1,E=!1,Y=!1,w=!1,T=!1,j=!1,C=!1,N=0;function p(u){return u.length-u.trimStart().length}function P(u){const s=u.trimStart().match(/^([a-zA-Z_][a-zA-Z0-9_./-]*)\s*:/);return s?s[1]:null}function V(u){const s=u.trim().split(":").slice(1).join(":").trim();return s!==""&&!/^[>|]/.test(s)}function B(u){for(r++;r<d.length;){const s=d[r],i=s.trimStart();if(i===""||i.startsWith("#")){r++;continue}if(p(s)<=u)break;r++}}function f(u){const s=P(u);return s?x.some(i=>s.startsWith(i)):!1}for(;r<d.length;){const u=d[r],s=u.trimStart(),i=p(u),o=P(u);if(s===""||s.startsWith("#")){c.push(u),r++;continue}if(i===0&&o==="status"){B(0);continue}if(i===0&&o==="metadata"){b=!0,c.push(u),r++;continue}if(i===0&&o!=="metadata"&&(b=!1,y=!1),i===0&&o==="spec"){E=!0,c.push(u),r++;continue}if(i===0&&o!=="spec"&&(E=!1,Y=!1,w=!1,T=!1,C=!1),b){if(i===2&&o==="annotations"){y=!0,c.push(u),r++;continue}if(i<=2&&o!=="annotations"&&(y=!1),i>=2&&i<=4&&s.startsWith("pod-template-hash")&&s.includes(":")){r++;continue}if(i===2&&o&&k.has(o)){V(u)?r++:B(2);continue}if(i===2&&o&&A.has(o)){B(2);continue}if(y&&i>2&&o&&$.has(o)){if(V(u))r++;else{const l=s.split(":").slice(1).join(":").trim();/^[>|]/.test(l)?B(i):r++}continue}}if(E){if(i===2&&o==="template"){c.push(u),r++;continue}if(i===2&&o&&R[o]){const h=s.split(":").slice(1).join(":").trim();if(R[o].includes(h)){r++;continue}}if(i===2&&o==="nodeName"){r++;continue}if(i===2&&o==="spec"){Y=!0,N=i,c.push(u),r++;continue}}if(Y&&i>N){if(o==="containers"){w=!0,T=!1,c.push(u),r++;continue}if(o==="initContainers"){T=!0,w=!1,c.push(u),r++;continue}if(o==="volumes"){C=!0,c.push(u),r++;continue}if(o&&R[o]){const h=s.split(":").slice(1).join(":").trim();if(R[o].includes(h)){r++;continue}}if(o==="nodeName"){r++;continue}if(o==="serviceAccount"&&s.endsWith(":")){V(u)?r++:B(i);continue}}if((w||T)&&i>=6){if(o&&F[o]){const h=s.split(":").slice(1).join(":").trim();if(F[o].includes(h)){r++;continue}}if(o==="volumeMounts"&&(j=!0),j&&s.startsWith("- name:")){let h=[u],l=r+1,t=!1;for(;l<d.length;){const n=d[l].trimStart();if(n===""||n.startsWith("#")){h.push(d[l]),l++;continue}if(p(d[l])<=i)break;Se(n)&&(t=!0),h.push(d[l]),l++}if(t){r=l;continue}j=!1}}if(C&&i>=4&&s.startsWith("- name:")&&f(s)){const h=i;for(r++;r<d.length;){const l=d[r],t=l.trimStart();if(t===""||t.startsWith("#")){r++;continue}if(p(l)<=h)break;r++}continue}if(s===""&&c.length>0&&c[c.length-1].trim()===""){r++;continue}c.push(u),r++}return c.join(`
|
||||
`).replace(/\n{3,}/g,`
|
||||
|
||||
`).trimEnd()+`
|
||||
`}function Se(a){return a.includes("mountPath:")&&(a.includes("/var/run/secrets/kubernetes.io")||a.includes("/var/run/secrets/sa"))}const O={green:"#10b981",orange:"#f59e0b",red:"#ef4444",blue:"#326CE5"};function Re(a){if(!a)return"#64748b";const d=a.toLowerCase();return["running","available","ready","active","completed","succeeded"].includes(d)?O.green:["pending","updating","progressing","containercreating"].includes(d)?O.orange:["failed","error","crashloopbackoff","imagepullbackoff","errimageneverpull"].includes(d)?O.red:O.blue}function $e(a){if(!a)return"-";const d=new Date(a);if(isNaN(d.getTime()))return a;const c=r=>String(r).padStart(2,"0");return`${d.getFullYear()}-${c(d.getMonth()+1)}-${c(d.getDate())} ${c(d.getHours())}:${c(d.getMinutes())}:${c(d.getSeconds())}`}function ze(a,d){if(!a||!d)return null;const c=new Date(a).getTime(),r=new Date(d).getTime();return isNaN(c)||isNaN(r)||r<c?null:Math.max(0,Math.round((r-c)/1e3))}function De(a){if(a==null)return"-";if(a<60)return`${a}s`;if(a<3600)return`${Math.floor(a/60)}m${a%60}s`;const d=Math.floor(a/3600),c=Math.floor(a%3600/60);return`${d}h${c}m`}function Me({clusterCode:a,namespace:d,resource:c,name:r,onClose:k,onSaved:A,cleanBeforeEdit:R=!1,autoEdit:F=!1,inline:$=!1,initialYaml:x}){const{toast:b}=re(),[y,E]=m.useState(x||""),[Y,w]=m.useState(""),[T,j]=m.useState(!x),[C,N]=m.useState(!1),[p,P]=m.useState(F),[V,B]=m.useState(!1),f=R||F,z=async()=>{if(x){E(x),w(f?W(x):x),j(!1);return}j(!0);try{const n=await D.getResourceYaml(a,d,c,r);E(n),w(f?W(n):n)}catch(n){b({title:"获取YAML失败",description:n.message,variant:"destructive"});const g=`# Error: ${n.message}`;E(g),w(g)}finally{j(!1)}},u=()=>{const n=f?W(y):y;w(n),P(!0),f&&b({title:"已清理只读字段",description:"已剥离 status / managedFields / uid 等"})},[s,i]=m.useState(!1),o=async()=>{N(!0);try{await D.updateResourceYaml(a,d,c,r,Y),b({title:"YAML已应用",description:`${c}/${r} 更新成功`}),P(!1),E(Y),A?.()}catch(n){b({title:"保存失败",description:n.message,variant:"destructive"})}finally{N(!1)}},h=async()=>{const n=p?Y:y;await navigator.clipboard.writeText(n),B(!0),setTimeout(()=>B(!1),2e3)};m.useEffect(()=>{z()},[]);const l=p?Y:f&&!s?W(y):y,t=m.useMemo(()=>[ne(),U.lineWrapping,...p?[]:[U.editable.of(!1)]],[p]);return $?e.jsxs("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:113:7",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:114:9",className:"flex items-center justify-between",children:[e.jsxs("p",{"code-path":"src/components/kubernetes/YamlViewer.tsx:115:11",className:"text-xs text-slate-500",children:[e.jsxs("code",{"code-path":"src/components/kubernetes/YamlViewer.tsx:116:13",className:"text-slate-400",children:[c,"/",r]})," · ",d," · ",a]}),e.jsxs("div",{"code-path":"src/components/kubernetes/YamlViewer.tsx:118:11",className:"flex items-center gap-2",children:[e.jsxs(v,{"code-path":"src/components/kubernetes/YamlViewer.tsx:119:13",variant:"outline",size:"sm",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:h,children:[V?e.jsx(J,{"code-path":"src/components/kubernetes/YamlViewer.tsx:120:25",className:"h-3 w-3 mr-1 text-emerald-400"}):e.jsx(q,{"code-path":"src/components/kubernetes/YamlViewer.tsx:120:79",className:"h-3 w-3 mr-1"}),V?"已复制":"复制"]}),f&&!p&&e.jsxs(v,{"code-path":"src/components/kubernetes/YamlViewer.tsx:124:15",variant:"outline",size:"sm",className:`h-7 text-xs ${s?"border-slate-700 text-slate-500":"border-emerald-700/50 text-emerald-400"}`,onClick:()=>i(n=>!n),title:"切换 精简/原始 视图",children:[e.jsx(I,{"code-path":"src/components/kubernetes/YamlViewer.tsx:126:17",className:"h-3 w-3 mr-1"}),s?"原始":"精简"]}),p?e.jsxs(e.Fragment,{children:[e.jsx(v,{"code-path":"src/components/kubernetes/YamlViewer.tsx:144:17",variant:"outline",size:"sm",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>{P(!1),z()},children:"取消"}),e.jsxs(v,{"code-path":"src/components/kubernetes/YamlViewer.tsx:147:17",size:"sm",className:"h-7 bg-blue-600 hover:bg-blue-700 text-xs",onClick:o,disabled:C,children:[C?e.jsx(M,{"code-path":"src/components/kubernetes/YamlViewer.tsx:148:29",className:"h-3 w-3 animate-spin mr-1"}):e.jsx(X,{"code-path":"src/components/kubernetes/YamlViewer.tsx:148:81",className:"h-3 w-3 mr-1"}),"保存"]})]}):e.jsxs(e.Fragment,{children:[f&&e.jsxs(v,{"code-path":"src/components/kubernetes/YamlViewer.tsx:132:19",variant:"outline",size:"sm",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:u,title:"清理 status / managedFields 等只读字段后编辑",children:[e.jsx(I,{"code-path":"src/components/kubernetes/YamlViewer.tsx:133:19",className:"h-3 w-3 mr-1 text-amber-400"}),"编辑"]}),!f&&e.jsx(v,{"code-path":"src/components/kubernetes/YamlViewer.tsx:137:19",variant:"outline",size:"sm",className:"h-7 border-slate-700 text-slate-300 text-xs",onClick:()=>P(!0),children:"编辑"})]})]})]}),e.jsx("div",{"code-path":"src/components/kub
Line truncated
|
||||
\x1B[33m⚠ bash 不可用,请切换 /bin/sh 后重连。\x1B[0m`),Y.current=!0;return}s.write(t.includes("\x1B")?t:`\r
|
||||
\x1B[31m${t}\x1B[0m\r
|
||||
`)}}catch{typeof h.data=="string"&&s.write(h.data)}},o.onclose=h=>{T(l=>l==="error"?l:"closed"),Y.current||s.write(`\r
|
||||
\x1B[33m[连接已关闭]\x1B[0m\r
|
||||
`)},o.onerror=h=>{console.error("[PodExec:connect] WS error event fired, readyState=",o.readyState,"type=",h.type),T("error"),s.write(`\r
|
||||
\x1B[31m[连接发生错误]\x1B[0m\r
|
||||
`)}},[c,r,k,N,P]);m.useEffect(()=>{if(!a)return;if(!c){console.error("[PodExec:initEffect] ABORT: clusterId is falsy:",c);return}if(!k){console.error("[PodExec:initEffect] ABORT: podName is falsy:",k);return}let s=!1,i=0;const o=performance.now(),h=()=>{if(s)return;const l=$.current;if(!l){i++,i<20?requestAnimationFrame(h):console.error("[PodExec:tryInit] FAILED: containerRef still null after 20 retries (",Math.round(performance.now()-o),"ms)");return}const t=new je.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,scrollback:5e3,theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#38bdf8",selectionBackground:"#1e40af",black:"#1e293b",red:"#ef4444",green:"#10b981",yellow:"#f59e0b",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e2e8f0",brightBlack:"#475569",brightRed:"#f87171",brightGreen:"#34d399",brightYellow:"#fbbf24",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#f8fafc"}}),n=new Ne.FitAddon;t.loadAddon(n),x.current=t,y.current=n,t.onData(g=>{b.current&&b.current.readyState===WebSocket.OPEN?b.current.send(JSON.stringify({status:0,data:g})):console.warn("[PodExec:term] TX dropped — WS not open, readyState=",b.current?.readyState)}),t.open(l),requestAnimationFrame(()=>{try{n.fit()}catch{}}),E.current=!0,B()};return requestAnimationFrame(h),()=>{s=!0}},[a,c,k]),m.useEffect(()=>{if(!a){try{b.current?.close()}catch{}try{x.current?.dispose()}catch{}x.current=null,b.current=null,y.current=null,E.current=!1,T("idle")}},[a]),m.useEffect(()=>{a&&x.current&&E.current&&B()},[N,P]),m.useEffect(()=>{if(!a)return;const s=$.current;if(!s)return;let i;const o=new ResizeObserver(()=>{clearTimeout(i),i=setTimeout(()=>{if(y.current&&x.current)try{y.current.fit(),x.current.focus();const{cols:h,rows:l}=x.current;b.current?.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({status:1,cols:h,rows:l}))}catch{}},60)});return o.observe(s),()=>{clearTimeout(i),o.disconnect()}},[a,j]);const f=w==="connected"?"bg-emerald-400":w==="error"?"bg-red-400":w==="closed"?"bg-slate-500":"bg-amber-400",z=w==="connected"?"已连接":w==="connecting"?"连接中":w==="error"?"连接错误":w==="closed"?"已断开":"空闲",u=m.useCallback(()=>{try{x.current?.focus()}catch{}},[]);return e.jsx(oe,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:279:5",open:a,onOpenChange:d,children:e.jsxs(ae,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:280:7",showCloseButton:!1,className:H("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",j?"!max-w-none !w-screen !h-screen !rounded-none !translate-x-0 !translate-y-0 !left-0 !top-0":""),style:j?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"960px",width:"92vw"},children:[e.jsxs(ce,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:289:9",className:"sr-only",children:["exec — ",k]}),e.jsx(ie,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:290:9",className:"sr-only",children:"进入 Pod 容器执行命令"}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:293:9",className:"flex items-center justify-between gap-2 px-4 py-2 border-b border-[var(--dg-border)] flex-wrap",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:294:11",className:"flex items-center gap-2 text-sm min-w-0",children:[e.jsx("div",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:295:13",className:H("w-2 h-2 rounded-full shrink-0",f),title:z}),e.jsx(le,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:296:13",className:"h-4 w-4 text-blue-400 shrink-0"}),e.jsxs("span",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:297:13",className:"text-[var(--dg-text-primary)] font-medium truncate",children:["exec — ",k]}),w==="connecting"&&e.jsx(M,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:298:44",className:"h-3 w-3 animate-spin text-[var(--dg-text-muted)]"}),e.jsx("span",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:299:13",className:"text-xs text-[var(--dg-text-muted)]",children:z})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:301:11",className:"flex items-center gap-2",children:[A.length>0&&e.jsxs(Z,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:303:15",value:N,onValueChange:p,children:[e.jsxs(Q,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:304:17",className:"h-8 w-[150px] text-xs bg-[var(--dg-bg-hover)] border-[var(--dg-border)]",children:[e.jsx(de,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:305:19",className:"h-3 w-3 mr-1 text-[var(--dg-text-muted)]"}),e.jsx(ee,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:306:19",placeholder:"容器"})]}),e.jsx(te,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:308:17",children:A.map(s=>e.jsx(se,{"code-path":"src/components/kubernetes/PodExecTerminal.tsx:308:55",value:s,children:s},s))}
Line truncated
|
||||
Reference in new issue
Block a user