fix(k8s): Deployment 存储挂载六种卷类型 YAML 双向映射

- 抽取 deployment-volume-utils,修正 PVC/NFS/CM/Secret/HostPath/EmptyDir 读写
- 保存时保留系统卷与 serviceAccount 挂载,合并用户卷与挂载点
- 挂载支持 subPath;ConfigMap/Secret items 支持 key:path 简写
This commit is contained in:
Logan.Li committed 2026-06-26 14:57:09 +08:00
1 parent 5fad2db0c6
commit a8305de0f5
98 files changed
+453 -250

No files matched your search

@@ -0,0 +1 @@
import{r as s,j as e}from"./vendor-codemirror-C7mXSpXt.js";import{C as M,a as W}from"./card-BVNSlZ0C.js";import{g as ce,i as oe,L as q,B as de}from"./index-EF2TDvxx.js";import{S,a as C,b as T,c as _,d as x}from"./select-DbRZUnPK.js";import{T as xe,a as le,b as L,c as v,d as me,e as i}from"./table-CUnn2-lp.js";import{k as $}from"./index-CYw3SC6I.js";import{f as G,t as pe,R as J,X as O,l as ie}from"./vendor-icons-Aso0-eeY.js";import"./index-CYARH0Cq.js";function F({title:b,items:m,selected:p,onSelect:N,emptyText:l}){const f=Math.max(...m.map(d=>d.count),1);return e.jsx(M,{"code-path":"src/components/kubernetes/EventsPage.tsx:28:5",className:"bg-[var(--dg-bg-secondary)] border-[var(--dg-border)]",children:e.jsxs(W,{"code-path":"src/components/kubernetes/EventsPage.tsx:29:7",className:"p-4",children:[e.jsx("h3",{"code-path":"src/components/kubernetes/EventsPage.tsx:30:9",className:"text-sm font-medium text-[var(--dg-text-primary)] mb-3",children:b}),m.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/EventsPage.tsx:32:11",className:"text-xs text-[var(--dg-text-muted)] py-6 text-center",children:l||"暂无数据"}):e.jsx("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:34:11",className:"space-y-1.5 max-h-[220px] overflow-y-auto pr-1",children:m.map(d=>{const k=p===d.name;return e.jsxs("button",{"code-path":"src/components/kubernetes/EventsPage.tsx:38:17",type:"button",className:`w-full flex items-center gap-2 rounded px-2 py-1.5 text-left transition-colors ${k?"bg-[var(--dg-bg-tertiary)]":"hover:bg-[var(--dg-bg-tertiary)]/60"}`,onClick:()=>N?.(k?"":d.name),children:[e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:46:19",className:"w-[88px] shrink-0 truncate text-xs text-[var(--dg-text-secondary)]",title:d.name,children:d.name}),e.jsx("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:49:19",className:"flex-1 h-1.5 rounded-full bg-[var(--dg-bg-tertiary)] overflow-hidden",children:e.jsx("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:50:21",className:`h-full rounded-full ${k?"bg-[var(--dg-accent)]":"bg-[var(--dg-text-muted)]/50"}`,style:{width:`${d.count/f*100}%`}})}),e.jsx("span",{"code-path":"src/components/kubernetes/EventsPage.tsx:55:19",className:"w-8 text-right text-xs tabular-nums text-[var(--dg-text-muted)]",children:d.count})]},d.name)})})]})})}function R({label:b,value:m,hint:p}){return e.jsxs("div",{"code-path":"src/components/kubernetes/EventsPage.tsx:68:5",className:"px-4 py-3 border-r border-[var(--dg-border)] last:border-r-0",children:[e.jsx("p",{"code-path":"src/components/kubernetes/EventsPage.tsx:69:7",className:"text-xs text-[var(--dg-text-muted)]",children:b}),e.jsx("p",{"code-path":"src/components/kubernetes/EventsPage.tsx:70:7",className:"text-xl font-semibold tabular-nums text-[var(--dg-text-primary)] mt-0.5",children:m}),p&&e.jsx("p",{"code-path":"src/components/kubernetes/EventsPage.tsx:71:16",className:"text-[10px] text-[var(--dg-text-muted)] mt-0.5",children:p})]})}function Pe(){const{clusterCode:b}=ce(),m=oe(),[p,N]=s.useState(!1),[l,f]=s.useState([]),[d,k]=s.useState([]),[Q,Y]=s.useState([]),[u,Z]=s.useState("all"),[y,ee]=s.useState("all"),[E,te]=s.useState("0"),[r,H]=s.useState(b||""),[o,U]=s.useState(null),[g,A]=s.useState(""),[h,D]=s.useState(""),[se,ne]=s.useState(null);s.useEffect(()=>{$.getClusters().then(t=>{const a=t?.list||[];if(k(a),!r&&a.length>0){const n=a[0].code||String(a[0].id);H(n),m(`/kubernetes/${n}/events`,{replace:!0})}}).catch(()=>{})},[]),s.useEffect(()=>{r&&$.getNamespaces(r).then(t=>{Y(Array.isArray(t)?t:t?.list||t?.data||[])}).catch(()=>{})},[r]);const V=s.useCallback(async()=>{if(r){N(!0);try{const t=u==="all"?void 0:u,a=y==="all"?void 0:y,n=await $.getEvents(r,t,a);f(Array.isArray(n)?n:n?.list||[])}catch{f([])}finally{N(!1)}}},[r,u,y]),B=s.useCallback(async()=>{if(r)try{const t=u==="all"?void 0:u,a=parseInt(E)||void 0,n=await $.getEventsSummary(r,t,a);U(n||null)}catch{U(null)}},[r,u,E]);s.useEffect(()=>{V()},[V]),s.useEffect(()=>{B()},[B]);const j=s.useMemo(()=>{let t=l;const a=parseInt(E,10);if(a>0){const n=Date.now()-a*3600*1e3;t=t.filter(c=>{const P=c.last_time||c.lastTime||c.last_timestamp;return!P||new Date(P).getTime()>=n})}return g&&(t=t.filter(n=>n.reason===g)),h&&(t=t.filter(n=>(n.object||"").startsWith(`${h}/`))),t},[l,g,h,E]),ae=s.useMemo(()=>l.filter(t=>t.type==="Warning").length,[l]),re=s.useMemo(()=>l.filter(t=>t.type==="Normal").length,[l]),I=s.useMemo(()=>(o?.by_reason||[]).map(t=>({name:t.reason||"Unknown",count:t.count})),[o]),z=s.useMemo(()=>(o?.by_namespace||[]).map(t=>({name:t.namespace||"<cluster>",count:t.count})),[o]),X=s.useMemo(()=>(o?.by_kind||[]).map(t=>({name:t.kind||"Unknown",count:t.count})),[o]),K=t=>t?t.replace("T"," ").substring(0,19):"-",w=t=>{if(!t)return"";const a=Date.now()-new Date(t).getTime();if(a<0)return"";const n=Math.floor(a/6e4);if(n<1)return"刚刚";if(n<60)return`${n}分钟前`;const c=Math.floor(n/60);return c<24?`${c}小时前`:`${Math.floor(c/Line truncated