refactor(frontend): P1-P2 架构统一 — utils/hooks/api 模块化
P1: - utils/storage.ts、theme.ts、validate.ts + index 统一出口 - request/store/useTheme 接入 storage;清零 confirm/alert - PipelineManager、TerminalAuditTab 拆分子模块(<700行红线) P2: - api/monitor、api/deploy 子目录化 - hooks/api 扩展:servers/pipelines/alerts/audit/sessionCommands - PipelineManager、AuditOperationsTab 接入 TanStack Query
This commit is contained in:
1 parent
d19a03d427
commit
f45e203e21
196 files changed
+3228
-2018
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import{i as Le,f as st,r as x,w as nt,N as we,A as Kt,j as e,B as h,L as he,W as Xt,o as Zt,H as Qt,C as es,R as ys,p as ks,v as ts,$ as ss,E as Qe,S as gt,G as gs,M as vs,z as bt,Q as yt,V as it,m as ns,bd as js,T as Ot,au as Ns,X as os,a3 as vt,k as Ds}from"./index-HuRw9UhJ.js";import{C as F,a as Y,b as ie,c as pe}from"./card-B2Wqa0sK.js";import{I as b}from"./input-C9Xfv8um.js";import{L as P}from"./label-DvRDtaMA.js";import{B as te}from"./badge-CeS-g-Od.js";import{k as ee}from"./index-GZwpRmKU.js";import{u as Ce}from"./use-toast-B25j_Fg3.js";import{S as fe,f as Fe,e as fs,b as Ss,s as pt,Y as It,P as Es,a as ws}from"./PodFileBrowser-DmjH49sm.js";import{T as Be,a as Oe,b as ge,c as K,d as Ie,e as X}from"./table-Du1vU-OM.js";import{P as ce}from"./plus-BVwIGPvl.js";import{H as Cs}from"./history-CLAzTAyT.js";import{M as jt}from"./minus-BLAorVC4.js";import{F as Nt}from"./file-text-BqORyhNh.js";import{H as as}from"./hard-drive-laLCm9TI.js";import{E as kt}from"./external-link-JBfQbjOd.js";import{T as et}from"./textarea-Bzol9o6k.js";import{S as $e,a as _e,b as tt,c as Ge,d as ye}from"./select-KDzbUQs3.js";import{S as Dt}from"./switch--ZaqVsRJ.js";import{T as be}from"./trash-2-Cf9-88KL.js";import{Z as cs}from"./zap-CS68N0Jd.js";import{F as Ps}from"./folder-open-BKJ-_5eY.js";import{R as rs}from"./rotate-cw-Dt34Qj6N.js";import{P as ls}from"./play-BXdOitsb.js";import{S as ot}from"./save-PutEGGnz.js";import{D as As}from"./disc-DI2GsPrr.js";import{a as Vs,F as mt}from"./folder-CyecCkCR.js";import{R as at}from"./refresh-cw-CSycAyA2.js";import{C as Ws}from"./circle-x-BVvXVx7p.js";import{A as Ts}from"./arrow-left-J2A6V6Vq.js";import{P as Ht}from"./pause-R-v_3hMV.js";import"./copy-Ci4WwJkK.js";import"./sparkles-DEwze8TU.js";import"./xterm-DSqgeKvr.js";import"./box-DPoVh2_c.js";import"./minimize-2-UErWMOt6.js";import"./upload-oCjAhX91.js";import"./download-CjFatm64.js";import"./index-DwvHXNyF.js";import"./chevron-up-GXrRy2ul.js";const Rs=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Bs=Le("hash",Rs);const Os=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],Is=Le("heart",Os);const Hs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],zs=Le("image",Hs);const Ms=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],$s=Le("key-round",Ms);const _s=[["path",{d:"M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z",key:"16rjxf"}],["path",{d:"M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193",key:"178nd4"}],["circle",{cx:"10.5",cy:"6.5",r:".5",fill:"currentColor",key:"12ikhr"}]],zt=Le("tags",_s);function ds(t){const s=t.conditions||t.pod_conditions||[],o=n=>s.find(r=>(r.type||r.Type)===n),a=n=>n?.lastTransitionTime||n?.LastTransitionTime||n?.last_transition_time;return{scheduled:a(o("PodScheduled")||{}),initialized:a(o("Initialized")||{}),containersReady:a(o("ContainersReady")||{}),ready:a(o("Ready")||{}),startTime:t.start_time||t.startTime}}function Gs(t){const{clusterCode:s,namespace:o,deployment:a,pods:n,revisions:r,onRefresh:d}=t,{toast:m}=Ce(),V=st(),[i,N]=x.useState("pods"),[D,B]=x.useState(null),[g,E]=x.useState(null),[f,w]=x.useState(a?.replicas||0),[z,O]=x.useState(!1),[ne,U]=x.useState([]),[I,L]=x.useState([]),[q,M]=x.useState([]),[Q,oe]=x.useState(""),[c,u]=x.useState([]),[j,R]=x.useState([]),p=a?.ready_replicas??a?.readyReplicas??0,C=a?.replicas??0,H=p===C&&C>0;x.useEffect(()=>{i==="services"&&(oe("services"),Promise.all([ee.getNamespaceServices(s,o).catch(()=>[]),ee.getNamespaceIngresses(s,o).catch(()=>[])]).then(([y,_])=>{const G=W=>Array.isArray(W)?W:W?.list||W?.items||W?.data||[],$=G(y),ue=G(_),Z=a?.spec?.selector?.matchLabels||a?.spec?.template?.metadata?.labels||{},me=$.filter(W=>{const ae=W.spec?.selector||W.selector||{};return Object.keys(ae).length===0?!1:Object.entries(ae).every(([ve,je])=>Z[ve]===je)}).map(W=>({name:W.name||W.metadata?.name,type:W.spec?.type||W.type||"ClusterIP",clusterIP:W.spec?.clusterIP||W.cluster_ip||"<none>",ports:(W.spec?.ports||W.ports||[]).map(ae=>`${ae.port}${ae.targetPort?":"+ae.targetPort:""}/${ae.protocol||"TCP"}`),selector:W.spec?.selector||W.selector||{},age:W.age||""})),Se=new Set(me.map(W=>W.name)),re=ue.filter(W=>(W.spec?.rules||W.rules||[]).some(ve=>(ve.http?.paths||ve.paths||[]).some(je=>{const v=je.backend?.service?.nLine truncated
|
||||
`):n.exec?.command||"",initialDelaySeconds:n.initialDelaySeconds,periodSeconds:n.periodSeconds,timeoutSeconds:n.timeoutSeconds,successThreshold:n.successThreshold,failureThreshold:n.failureThreshold}},o=n=>{if(!n)return{type:"none"};let r="none";return n.exec?r="exec":n.httpGet?r="httpGet":n.tcpSocket&&(r="tcpSocket"),{type:r,execCommand:Array.isArray(n.exec?.command)?n.exec.command.join(`
|
||||
`):"",httpPath:n.httpGet?.path||"",httpPort:n.httpGet?.port??"",tcpPort:n.tcpSocket?.port??""}},a=t.securityContext;return{name:t.name||"",image:t.image||"",imagePullPolicy:t.imagePullPolicy||"",command:Array.isArray(t.command)?t.command:[],args:Array.isArray(t.args)?t.args:[],workingDir:t.workingDir||"",env:(Array.isArray(t.env)?t.env:[]).map(n=>({name:n.name||"",value:n.value??""})),ports:(Array.isArray(t.ports)?t.ports:[]).map(n=>({name:n.name||"",containerPort:n.containerPort??"",protocol:n.protocol||"TCP"})),resources:{requests:t.resources?.requests||{},limits:t.resources?.limits||{}},livenessProbe:s(t.livenessProbe),readinessProbe:s(t.readinessProbe),startupProbe:s(t.startupProbe),lifecycle:t.lifecycle?{postStart:t.lifecycle.postStart?o(t.lifecycle.postStart):void 0,preStop:t.lifecycle.preStop?o(t.lifecycle.preStop):void 0}:null,securityContext:a?{runAsUser:a.runAsUser,runAsGroup:a.runAsGroup,runAsNonRoot:a.runAsNonRoot,privileged:a.privileged,readOnlyRootFilesystem:a.readOnlyRootFilesystem,allowPrivilegeEscalation:a.allowPrivilegeEscalation,capabilitiesAdd:a.capabilities?.add||[],capabilitiesDrop:a.capabilities?.drop||[]}:null,volumeMounts:(Array.isArray(t.volumeMounts)?t.volumeMounts:[]).map(n=>({name:n.name||"",mountPath:n.mountPath||"",subPath:n.subPath||"",readOnly:n.readOnly||!1}))}}function $t(t=""){return{name:t,image:"",imagePullPolicy:"IfNotPresent",command:[],args:[],workingDir:"",env:[],ports:[],resources:{},livenessProbe:null,readinessProbe:null,startupProbe:null,lifecycle:null,securityContext:null,volumeMounts:[]}}function xt(t){if(!t||t.type==="none"||!t.type)return;const s={};if(t.type==="httpGet")s.httpGet={},t.httpPath&&(s.httpGet.path=t.httpPath),t.httpPort!==""&&t.httpPort!=null&&(s.httpGet.port=typeof t.httpPort=="number"?t.httpPort:Number(t.httpPort)),t.httpHost&&(s.httpGet.host=t.httpHost);else if(t.type==="tcpSocket")s.tcpSocket={},t.tcpPort!==""&&t.tcpPort!=null&&(s.tcpSocket.port=typeof t.tcpPort=="number"?t.tcpPort:Number(t.tcpPort));else if(t.type==="exec"){const o=(t.execCommand||"").split(`
|
||||
`).map(a=>a.trim()).filter(Boolean);o.length&&(s.exec={command:o})}return t.initialDelaySeconds!=null&&(s.initialDelaySeconds=t.initialDelaySeconds),t.periodSeconds!=null&&(s.periodSeconds=t.periodSeconds),t.timeoutSeconds!=null&&(s.timeoutSeconds=t.timeoutSeconds),t.successThreshold!=null&&(s.successThreshold=t.successThreshold),t.failureThreshold!=null&&(s.failureThreshold=t.failureThreshold),Object.keys(s).length>0?s:void 0}function _t(t){if(!(!t||t.type==="none"||!t.type)){if(t.type==="exec"){const s=(t.execCommand||"").split(`
|
||||
`).map(o=>o.trim()).filter(Boolean);return s.length?{exec:{command:s}}:void 0}if(t.type==="httpGet"){const s={httpGet:{}};return t.httpPath&&(s.httpGet.path=t.httpPath),t.httpPort!==""&&t.httpPort!=null&&(s.httpGet.port=Number(t.httpPort)),s}if(t.type==="tcpSocket"){const s={tcpSocket:{}};return t.tcpPort!==""&&t.tcpPort!=null&&(s.tcpSocket.port=Number(t.tcpPort)),s}}}function Gt(t){const s={name:t.name};t.image&&(s.image=t.image),t.imagePullPolicy&&(s.imagePullPolicy=t.imagePullPolicy),t.workingDir&&(s.workingDir=t.workingDir),t.command.length>0&&(s.command=t.command),t.args.length>0&&(s.args=t.args),t.env.length>0&&(s.env=t.env.filter(i=>i.name.trim()).map(i=>{const N={name:i.name};return i.value!=null&&(N.value=i.value),N})),t.ports.length>0&&(s.ports=t.ports.filter(i=>i.containerPort!=="").map(i=>{const N={containerPort:typeof i.containerPort=="number"?i.containerPort:Number(i.containerPort)};return i.name&&(N.name=i.name),i.protocol&&(N.protocol=i.protocol),N}));const o=t.resources.requests,a=t.resources.limits,n=o&&Object.values(o).some(i=>i&&i.trim()),r=a&&Object.values(a).some(i=>i&&i.trim());(n||r)&&(s.resources={},n&&(s.resources.requests={},o.cpu?.trim()&&(s.resources.requests.cpu=o.cpu),o.memory?.trim()&&(s.resources.requests.memory=o.memory)),r&&(s.resources.limits={},a.cpu?.trim()&&(s.resources.limits.cpu=a.cpu),a.memory?.trim()&&(s.resources.limits.memory=a.memory)));const d=xt(t.livenessProbe);d&&(s.livenessProbe=d);const m=xt(t.readinessProbe);m&&(s.readinessProbe=m);const V=xt(t.startupProbe);if(V&&(s.startupProbe=V),t.lifecycle){const i={},N=_t(t.lifecycle.postStart);N&&(i.postStart=N);const D=_t(t.lifecycle.preStop);D&&(i.preStop=D),Object.keys(i).length>0&&(s.lifecycle=i)}if(t.securityContext){const i=t.securityContext,N={};i.runAsUser!==""&&i.runAsUser!=null&&(N.runAsUser=Number(i.runAsUser)),i.runAsGroup!==""&&i.runAsGroup!=null&&(N.runAsGroup=Number(i.runAsGroup)),i.runAsNonRoot!=null&&(N.runAsNonRoot=i.runAsNonRoot),i.privileged!=null&&(N.privileged=i.privileged),i.readOnlyRootFilesystem!=null&&(N.readOnlyRootFilesystem=i.readOnlyRootFilesystem),i.allowPrivilegeEscalation!=null&&(N.allowPrivilegeEscalation=i.allowPrivilegeEscalation);const D=(i.capabilitiesAdd||[]).filter(Boolean),B=(i.capabilitiesDrop||[]).filter(Boolean);(D.length||B.length)&&(N.capabilities={},D.length&&(N.capabilities.add=D),B.length&&(N.capabilities.drop=B)),Object.keys(N).length>0&&(s.securityContext=N)}return t.volumeMounts.length>0&&(s.volumeMounts=t.volumeMounts.filter(i=>i.name.trim()&&i.mountPath.trim()).map(i=>{const N={name:i.name,mountPath:i.mountPath};return i.subPath&&(N.subPath=i.subPath),i.readOnly&&(N.readOnly=!0),N})),s}function Lt(t){return t.join(`
|
||||
`)}function Ft(t){return t.split(`
|
||||
`).map(s=>s.trim()).filter(Boolean)}function Us({container:t,onUpdate:s}){const o=t,a="flex items-center gap-1.5 text-xs font-semibold text-slate-300 mb-2";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:36:7",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:37:9",children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:38:11",className:"text-slate-400 text-xs",children:"容器名称"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:39:11",value:o.name,onChange:n=>s({name:n.target.value}),placeholder:"my-app",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:43:9",children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:44:11",className:"text-slate-400 text-xs",children:"容器镜像"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:45:11",value:o.image,onChange:n=>s({image:n.target.value}),placeholder:"nginx:1.25",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:49:9",children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:50:11",className:"text-slate-400 text-xs",children:"镜像拉取策略"}),e.jsxs($e,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:51:11",value:o.imagePullPolicy||"__none",onValueChange:n=>s({imagePullPolicy:n==="__none"?"":n}),children:[e.jsx(_e,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:52:13",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",children:e.jsx(tt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:53:15"})}),e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:55:13",className:"bg-slate-900 border-slate-700",children:[e.jsx(ye,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:56:15",value:"__none",className:"text-slate-400",children:"不设置(默认 IfNotPresent)"}),e.jsx(ye,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:57:15",value:"Always",className:"text-slate-200",children:"Always"}),e.jsx(ye,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:58:15",value:"IfNotPresent",className:"text-slate-200",children:"IfNotPresent"}),e.jsx(ye,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:59:15",value:"Never",className:"text-slate-200",children:"Never"})]})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:63:9",children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:64:11",className:"text-slate-400 text-xs",children:"工作目录 (workingDir)"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:65:11",value:o.workingDir||"",onChange:n=>s({workingDir:n.target.value}),placeholder:"/app",className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:72:7",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:73:9",children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:74:11",className:"text-slate-400 text-xs",children:"启动命令 (command) — 每行一个"}),e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:75:11",value:Lt(o.command),placeholder:`/bin/sh
|
||||
-c`,onChange:n=>s({command:Ft(n.target.value)}),className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[60px]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:79:9",children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:80:11",className:"text-slate-400 text-xs",children:"启动参数 (args) — 每行一个"}),e.jsx(et,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:81:11",value:Lt(o.args),placeholder:`--config=/etc/app.yaml
|
||||
--debug`,onChange:n=>s({args:Ft(n.target.value)}),className:"mt-1 bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs min-h-[60px]"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:88:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:89:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:90:11",className:a,children:[e.jsx(Qt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:90:39",className:"h-3.5 w-3.5 text-cyan-400"})," 环境变量"]}),e.jsxs(h,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:91:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({env:[...o.env,{name:"",value:""}]}),children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:93:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:96:9",className:"space-y-1.5",children:[o.env.map((n,r)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:98:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:99:15",value:n.name,placeholder:"KEY",onChange:d=>{const m=[...o.env];m[r]={...n,name:d.target.value},s({env:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:102:15",value:n.value||"",placeholder:"value",onChange:d=>{const m=[...o.env];m[r]={...n,value:d.target.value},s({env:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(h,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:105:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({env:o.env.filter((d,m)=>m!==r)}),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:107:17",className:"h-3.5 w-3.5"})})]},r)),o.env.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:111:34",className:"text-[11px] text-slate-600",children:"无环境变量"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:116:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:117:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:118:11",className:a,children:[e.jsx(we,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:118:39",className:"h-3.5 w-3.5 text-indigo-400"})," 端口"]}),e.jsxs(h,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:119:11",size:"sm",variant:"outline",className:"h-6 border-slate-700 text-slate-300 text-[11px]",onClick:()=>s({ports:[...o.ports,{name:"",containerPort:"",protocol:"TCP"}]}),children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:121:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:124:9",className:"space-y-1.5",children:[o.ports.map((n,r)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:126:13",className:"grid grid-cols-[1fr_1fr_100px_auto] gap-2",children:[e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:127:15",value:n.name||"",placeholder:"http",onChange:d=>{const m=[...o.ports];m[r]={...n,name:d.target.value},s({ports:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:130:15",type:"number",value:n.containerPort,placeholder:"8080",onChange:d=>{const m=[...o.ports];m[r]={...n,containerPort:d.target.value},s({ports:m})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsxs($e,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:133:15",value:n.protocol||"TCP",onValueChange:d=>{const m=[...o.ports];m[r]={...n,protocol:d},s({ports:m})},children:[e.jsx(_e,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:134:17",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",children:e.jsx(tt,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:135:19"})}),e.jsxs(Ge,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.tsx:137:17",className:"bg-slate-900 border-slate-700",children:[e.jsx(ye,{"code-path":"src/components/kubernetes/deployment-edit/ContainerEditor.ts
Line truncated
|
||||
114.114.114.114`,rows:3,className:"w-full mt-1 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 font-mono p-2 resize-y"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:74:13",children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:75:15",className:"text-slate-500 text-xs",children:"searches(搜索域,每行一个)"}),e.jsx("textarea",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:76:15",value:o,onChange:E=>a(E.target.value),placeholder:`svc.cluster.local
|
||||
cluster.local`,rows:3,className:"w-full mt-1 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 font-mono p-2 resize-y"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:85:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:86:13",className:"flex items-center justify-between mb-1",children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:87:15",className:"text-slate-400 text-xs",children:"options(DNS 选项)"}),e.jsxs(h,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:88:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:V,children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:89:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),n.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:93:15",className:"text-xs text-slate-600 italic",children:"未配置"}):n.map((E,f)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:96:17",className:"flex items-center gap-2 mb-1.5",children:[e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:97:19",value:E.name,onChange:w=>i(f,{name:w.target.value}),placeholder:"ndots",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:103:19",className:"text-slate-600",children:":"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:104:19",value:E.value,onChange:w=>i(f,{value:w.target.value}),placeholder:"5(可留空)",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(h,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:110:19",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>N(f),children:e.jsx(be,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:111:21",className:"h-3 w-3"})})]},f))]})]})]}),e.jsxs(F,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:120:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(ie,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:121:9",className:"pb-3",children:e.jsxs(pe,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:122:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(vs,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:123:13",className:"h-4 w-4 text-amber-400"}),"主机别名 (hostAliases)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:126:9",className:"pt-0 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:127:11",className:"flex items-center justify-between mb-1",children:[e.jsx(P,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:128:13",className:"text-slate-400 text-xs",children:"IP → 主机名映射(注入 Pod 的 /etc/hosts)"}),e.jsxs(h,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:129:13",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:D,children:[e.jsx(ce,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:130:15",className:"h-3 w-3 mr-1"}),"添加"]})]}),d.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:134:13",className:"text-xs text-slate-600 italic",children:"未配置"}):d.map((E,f)=>e.jsxs("div",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:137:15",className:"flex items-center gap-2",children:[e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:138:17",value:E.ip,onChange:w=>B(f,{ip:w.target.value}),placeholder:"10.10.10.72",className:"w-40 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:144:17",className:"text-slate-600",children:"→"}),e.jsx(b,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:145:17",value:E.hostnames,onChange:w=>B(f,{hostnames:w.target.value}),placeholder:"gitlab.local, registry.local",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(h,{"code-path":"src/components/kubernetes/deployment-edit-advanced/DnsHostSection.tsx:151:17",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>g(f),children:e.jsx(be,{"code-path":"src/compone
Line truncated
|
||||
`):""),Wt(Array.isArray(T.searches)?T.searches.join(`
|
||||
`):"");const xe=Array.isArray(T.options)?T.options:[];Rt(xe.map(le=>({name:le.name||"",value:le.value||""}))),N(!1)},[a]);const ps=()=>C(S=>[...S,{key:"",value:""}]),ms=S=>C(A=>A.filter((se,ke)=>ke!==S)),xs=(S,A)=>C(se=>se.map((ke,Ae)=>Ae===S?{...ke,...A}:ke)),hs=async()=>{V(!0);try{const S=JSON.parse(JSON.stringify(D));S.spec=S.spec||{},S.spec.template=S.spec.template||{},S.spec.template.spec=S.spec.template.spec||{};const A=S.spec.template.spec;if(S.spec.strategy={type:g},g==="RollingUpdate"&&(S.spec.strategy.rollingUpdate={maxSurge:f,maxUnavailable:z}),ne&&(S.spec.revisionHistoryLimit=Number(ne)),I&&(S.spec.progressDeadlineSeconds=Number(I)),q==="nodeName"&&Q.trim())A.nodeName=Q.trim(),delete A.nodeSelector,A.affinity&&delete A.affinity.nodeAffinity;else if(q==="nodeSelector"){const T={};for(const{key:xe,value:le}of p){const ze=xe.trim();ze&&(T[ze]=le)}Object.keys(T).length>0?A.nodeSelector=T:delete A.nodeSelector,A.nodeName&&delete A.nodeName,A.affinity&&delete A.affinity.nodeAffinity}else if(q==="nodeAffinity"){const T=p.filter(xe=>xe.key.trim()).map(xe=>({key:xe.key.trim(),operator:"In",values:[xe.value]}));T.length>0?(A.affinity=A.affinity||{},A.affinity.nodeAffinity={requiredDuringSchedulingIgnoredDuringExecution:{nodeSelectorTerms:[{matchExpressions:T}]}}):A.affinity&&delete A.affinity.nodeAffinity,delete A.nodeSelector,A.nodeName&&delete A.nodeName}const se=l.filter(T=>T.key||T.operator==="Exists").map(T=>{const xe={};return T.key&&(xe.key=T.key),T.operator&&(xe.operator=T.operator),T.value&&T.operator!=="Exists"&&(xe.value=T.value),T.effect&&(xe.effect=T.effect),T.tolerationSeconds&&T.effect==="NoExecute"&&(xe.tolerationSeconds=Number(T.tolerationSeconds)),xe});se.length>0?A.tolerations=se:delete A.tolerations,y&&(A.dnsPolicy=y),G&&(A.restartPolicy=G),ue&&(A.schedulerName=ue),me&&(A.terminationGracePeriodSeconds=Number(me)),re&&(A.serviceAccountName=re);const ke={};ae&&(ke.fsGroup=Number(ae)),je&&(ke.runAsUser=Number(je)),de&&(ke.runAsGroup=Number(de)),Ne&&(ke.runAsNonRoot=!0),Object.keys(ke).length>0?A.securityContext=ke:delete A.securityContext,ct?A.hostNetwork=!0:delete A.hostNetwork,rt?A.hostIPC=!0:delete A.hostIPC,Ee?A.hostPID=!0:delete A.hostPID,St?A.shareProcessNamespace=!0:delete A.shareProcessNamespace;const Ae=wt.filter(T=>T.ip.trim()).map(T=>({ip:T.ip.trim(),hostnames:T.hostnames.split(/[,\s]+/).map(xe=>xe.trim()).filter(Boolean)})).filter(T=>T.hostnames.length>0);Ae.length>0?A.hostAliases=Ae:delete A.hostAliases;const Ve={},He=Pt.split(`
|
||||
`).map(T=>T.trim()).filter(Boolean);He.length>0&&(Ve.nameservers=He);const qe=Vt.split(`
|
||||
`).map(T=>T.trim()).filter(Boolean);qe.length>0&&(Ve.searches=qe);const De=Tt.filter(T=>T.name.trim()).map(T=>{const xe={name:T.name.trim()};return T.value.trim()&&(xe.value=T.value.trim()),xe});De.length>0&&(Ve.options=De),Object.keys(Ve).length>0?A.dnsConfig=Ve:delete A.dnsConfig;const lt=JSON.stringify(S,null,2);await ee.updateResourceYaml(t,s,"deployments",o,lt),d({title:"高级设置已保存",description:`${o} 更新已提交`}),n()}catch(S){d({title:"保存失败",description:S?.message||String(S),variant:"destructive"})}finally{V(!1)}};return i?e.jsx(F,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:322:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:323:9",className:"p-12 text-center",children:[e.jsx(he,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:324:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:325:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):a?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:342:5",className:"space-y-4",children:[e.jsxs(F,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:344:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(ie,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:345:9",className:"pb-3",children:e.jsxs(pe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:346:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(at,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:347:13",className:"h-4 w-4 text-blue-400"}),"更新策略 (Strategy)"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:350:9",className:"pt-0 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:351:11",className:"flex items-center gap-4",children:[e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:352:13",className:"flex items-center gap-1.5 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:353:15",type:"radio",checked:g==="RollingUpdate",onChange:()=>E("RollingUpdate"),className:"accent-blue-500"}),"RollingUpdate(滚动更新)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:357:13",className:"flex items-center gap-1.5 text-xs text-slate-300 cursor-pointer",children:[e.jsx("input",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:358:15",type:"radio",checked:g==="Recreate",onChange:()=>E("Recreate"),className:"accent-blue-500"}),"Recreate(重建)"]})]}),g==="RollingUpdate"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:364:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:365:15",children:[e.jsx(P,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:366:17",className:"text-slate-500 text-xs",children:"maxSurge(整数或百分比,超出期望副本数)"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:367:17",value:f,onChange:S=>w(S.target.value),placeholder:"25%",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:370:15",children:[e.jsx(P,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:371:17",className:"text-slate-500 text-xs",children:"maxUnavailable(整数或百分比,不可用上限)"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:372:17",value:z,onChange:S=>O(S.target.value),placeholder:"25%",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]})]}),e.jsxs(F,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:381:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(ie,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:382:9",className:"pb-3",children:e.jsxs(pe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:383:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(es,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:384:13",className:"h-4 w-4 text-amber-400"}),"历史版本 & 进度"]})}),e.jsxs(Y,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:387:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:388:11",children:[e.jsx(P,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:389:13",className:"text-slate-500 text-xs",children:"revisionHistoryLimit(保留 RS 历史)"}),e.jsx(b,{"code-path":"src/c
Line truncated
|
||||
bg-slate-800 border border-slate-700 text-slate-300 hover:border-blue-500/50 hover:text-blue-300 transition-colors`,children:[e.jsx(cs,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:422:23",className:"h-2.5 w-2.5"}),l.label,e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:424:23",className:"text-slate-500 text-[9px]",children:[l.protocol," ",l.port,":",l.targetPort]})]},l.name))})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:431:15",className:"space-y-2",children:[e.jsxs(P,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:432:17",className:"text-slate-500 text-[11px]",children:["端口配置 ",e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:433:24",className:"text-slate-600",children:["(",U.ports.length," 个端口)"]})]}),U.ports.map((l,k)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:436:19",className:"flex items-center gap-1.5 p-2 rounded bg-slate-800/50 border border-slate-700/50",children:[e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:438:21",value:l.name,onChange:y=>Q(k,"name",y.target.value),placeholder:"http",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsxs("select",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:442:21",value:l.protocol,onChange:y=>Q(k,"protocol",y.target.value),className:"h-7 bg-slate-800 border border-slate-700 rounded text-xs text-slate-300 px-1.5 w-16",children:[e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:444:23",value:"TCP",children:"TCP"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:445:23",value:"UDP",children:"UDP"})]}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:448:21",value:l.port,onChange:y=>Q(k,"port",y.target.value),type:"number",placeholder:"port",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:451:21",className:"text-slate-600 text-[10px]",children:"→"}),e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:452:21",value:l.targetPort,onChange:y=>Q(k,"targetPort",y.target.value),type:"number",placeholder:"targetPort",className:"h-7 w-[72px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),U.type==="NodePort"&&e.jsx(b,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:457:23",value:l.nodePort,onChange:y=>Q(k,"nodePort",y.target.value),type:"number",placeholder:"30000-32767",className:"h-7 w-[80px] bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(h,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:462:21",size:"icon",variant:"ghost",className:"h-6 w-6 text-slate-500 hover:text-red-400",onClick:()=>oe(k),disabled:U.ports.length<=1,children:e.jsx(jt,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:464:23",className:"h-3 w-3"})})]},k)),e.jsxs(h,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:469:17",size:"sm",variant:"outline",className:"h-7 w-full border-dashed border-slate-700 text-slate-400 text-xs",onClick:()=>M(),children:[e.jsx(ce,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:471:19",className:"h-3 w-3 mr-1"}),"添加自定义端口"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:476:15",className:"text-[10px] text-slate-500 border-t border-slate-700/50 pt-2",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:477:17",className:"text-slate-600",children:"selector (自动检测): "}),Object.keys(E).length>0?Object.entries(E).map(([l,k])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:480:21",className:"bg-slate-800 px-1 py-0.5 rounded text-slate-400 ml-1",children:[l,"=",k]},l)):e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:483:19",className:"text-slate-600 italic",children:"未检测到"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:487:15",className:"flex justify-end gap-2 pt-1",children:[e.jsx(h,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:488:17",size:"sm",variant:"ghost",className:"h-7 text-xs text-slate-400",onClick:()=>ne(null),children:"取消"}),e.jsx(h,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:489:17",size:"sm",className:"h-7 bg-blue-600 hover:bg-blue-700 text-xs",onClick:C,children:"创建"})]})]})]})]}),e.jsxs(F,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:497:7",className:"bg-slate-900 border-slate-800",children:[e.jsxs(ie,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:498:9",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kub
Line truncated
|
||||
${N?"border-blue-500 text-blue-400":i.available?"border-transparent text-slate-400 hover:text-slate-200":"border-transparent text-slate-600 cursor-not-allowed"}`,children:[e.jsx(D,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:596:15",className:"h-3.5 w-3.5"}),i.label,i.badge&&e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:599:17",className:`text-[9px] px-1 py-0.5 rounded ${N?"bg-blue-500/20 text-blue-300":"bg-slate-800 text-slate-600"}`,children:i.badge})]},i.key)})}),d==="basic"?e.jsx(Zs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:610:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:r}):d==="containers"?e.jsx(Xs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:620:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:r}):d==="storage"?e.jsx(tn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:630:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:r}):d==="advanced"?e.jsx(an,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:640:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:r}):d==="service"?e.jsx(rn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:650:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:r}):null]})}function pn({clusterCode:t,namespace:s,deploymentName:o}){const{toast:a}=Ce(),n=vt(V=>V.token)||localStorage.getItem("token")||"",r=`${window.location.origin}/api/v1/clusters/${t}/namespaces/${s}/deployments/${o}/update-image`,d=`curl -X POST '${r}' \\
|
||||
-H 'Authorization: Bearer ${n?n.substring(0,16)+"...":"YOUR_TOKEN"}' \\
|
||||
-H 'Content-Type: application/json' \\
|
||||
-d '{"image": "harbor.example.com/app:v1.0", "container": "your-container-name"}'`,m=V=>{navigator.clipboard.writeText(V).then(()=>a({title:"已复制"})).catch(()=>{})};return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:678:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:679:7",children:[e.jsx(P,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:680:9",className:"text-slate-400 text-sm",children:"Webhook URL"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:681:9",className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:682:11",className:"flex-1 text-xs text-slate-300 bg-slate-800 rounded px-3 py-2 break-all font-mono",children:r}),e.jsx(h,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:683:11",variant:"outline",size:"sm",className:"border-slate-700 text-slate-400 shrink-0",onClick:()=>m(r),children:"复制"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:686:7",children:[e.jsx(P,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:687:9",className:"text-slate-400 text-sm",children:"curl 示例"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:688:9",className:"relative mt-1",children:[e.jsx("pre",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:689:11",className:"text-xs text-slate-300 bg-slate-800 rounded p-3 overflow-x-auto font-mono whitespace-pre-wrap",children:d}),e.jsx(h,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:690:11",variant:"outline",size:"sm",className:"absolute top-2 right-2 border-slate-700 text-slate-400",onClick:()=>m(d),children:"复制"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:693:7",className:"text-xs text-slate-500 space-y-1",children:[e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:694:9",children:"• 使用 Bearer Token 认证(JWT 登录令牌)"}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:695:9",children:["• ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:695:14",className:"text-slate-400",children:"image"})," 必填,指定新镜像地址"]}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:696:9",children:["• ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:696:14",className:"text-slate-400",children:"container"})," 可选,不填则更新第一个容器"]})]})]})}function Ze({title:t,children:s,onClose:o}){return e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:705:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:o,children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:706:7",className:"bg-slate-900 border border-slate-700 rounded-xl p-6 w-[460px] max-w-[90vw] shadow-2xl",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:707:9",className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:708:11",className:"text-base font-bold text-slate-100",children:t}),e.jsx(h,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:709:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400",onClick:o,children:e.jsx(os,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:709:100",className:"h-4 w-4"})})]}),s]})})}function mn({clusterCode:t,namespace:s,podName:o,containers:a,onClose:n}){const{toast:r}=Ce(),[d,m]=x.useState(""),[V,i]=x.useState(200),[N,D]=x.useState(a[0]||""),[B,g]=x.useState(!1),[E,f]=x.useState(!1),w=async()=>{g(!0);try{const O=await ee.getPodLogs(t,s,o,V,N||void 0);m(O?.data?.logs||O?.logs||O||"无日志")}catch{m("获取日志失败")}finally{g(!1)}};x.useEffect(()=>{w()},[N,V]);const z=async()=>{f(!0);const O=vt.getState().token||"",ne="",U=N?`&container=${encodeURIComponent(N)}`:"",I=`${ne}/api/v1/kubernetes/${t}/namespace/${s}/pods/${o}/logs?tail=${V}&stream=true${U}`;try{const q=(await fetch(I,{headers:{Authorization:`Bearer ${O}`}})).body?.getReader();if(!q)return;const M=new TextDecoder;let Q="";for(;;){const{done:oe,value:c}=await q.read();if(oe)break;Q+=M.decode(c,{stream:!0}),m(Q)}}catch{r({title:"流式日志连接中断",variant:"destructive"})}finally{f(!1)}};return e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:764:5",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:n,children:e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:765:7",className:"bg-slate-900 border border-slate-700 rounded-xl w-[90vw] max-w-4xl max-h-[80vh] flex flex-col",onClick:O=>O.stopPropagation(),children:[e.jsxs("div",{"code-path"
Line truncated
|
||||
Reference in new issue
Block a user