refactor(frontend): API 子模块化、大组件拆分与 TanStack Query hooks
P1: kubernetes/system API 拆为子目录模块,导出工具下沉到 lib/export-utils,
http 统一 buildApiUrl/getWsBase;HostMonitor、DeploymentEdit* 拆至子组件。
P2: 新增 hooks/api(queryKeys、useTerminalSessions、useHostMonitor),
TerminalSessionsTab 与 HostMonitor 接入 TanStack Query。
P3: 保留 services/api 路径,未迁移至 api/ 目录。
This commit is contained in:
1 parent
7fb2236b4d
commit
0b404b4611
226 files changed
+3040
-2596
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import{i as Fe,r as m,v as ot,N as Se,A as Zt,j as e,B as u,L as xe,V as Qt,o as es,E as ts,C as ss,R as bs,p as ys,t as ns,_ as os,z as tt,S as jt,y as vt,G as ks,M as vs,P as gt,Q as xt,m as as,aU as gs,T as Mt,al as Ds,X as cs,$ as Nt,k as js}from"./index-Dmami9WE.js";import{C as L,a as G,b as ie,c as pe}from"./card-CIfC-8Rh.js";import{I as v}from"./input-NsU9nXZF.js";import{L as C}from"./label-Ap_-SPYI.js";import{B as se}from"./badge-3UzCvU7L.js";import{k as te}from"./kubernetes-D2-GnE0t.js";import{u as Pe}from"./use-toast-jvSbBx20.js";import{S as we,f as Ye,e as Ns,b as fs,s as ht,Y as zt,P as Es,a as ws}from"./PodFileBrowser-BLvOIIeH.js";import{T as Re,a as Be,b as De,c as X,d as Oe,e as Z}from"./table-CG4mjNfb.js";import{P as ae}from"./plus-O65gX7Qz.js";import{H as Cs}from"./history-CbX6uocL.js";import{M as ft}from"./minus-DRP_TSA-.js";import{F as Et}from"./file-text-CebshSV-.js";import{H as rs}from"./hard-drive-DmC04Y5r.js";import{E as Dt}from"./external-link-2hCYo_Ng.js";import{T as st}from"./textarea-DHUZ6N85.js";import{S as Le,a as Ge,b as nt,c as He,d as ve}from"./select-DUbxjT0z.js";import{S as wt}from"./switch-TqjD2x0W.js";import{T as ue}from"./trash-2-DWVnIU6o.js";import{P as ls}from"./play-0EwQQJX_.js";import{S as at}from"./save-YtnrpTd8.js";import{R as ds}from"./rotate-cw-CKCO6IKE.js";import{Z as is}from"./zap-CocSkPPl.js";import{F as Ss}from"./folder-open-CjMh_m_2.js";import{D as Ps}from"./disc-BPxL4arn.js";import{F as As,a as ut}from"./folder-B5RGB3GG.js";import{R as ct}from"./refresh-cw-CTBERyFc.js";import{C as Vs}from"./circle-x-BBQeW1R3.js";import{A as Ws}from"./arrow-left-BIbk9wFC.js";import{P as _t}from"./pause-DOhduDQ5.js";import"./copy-CE_T92Lk.js";import"./sparkles-rPZivnlW.js";import"./xterm-DSqgeKvr.js";import"./box-88Ol5qY-.js";import"./minimize-2-BHcbNmdK.js";import"./upload-CRLg7Pbj.js";import"./download-Vuij9wGr.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const Ts=[["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"}]],Rs=Fe("hash",Ts);const Bs=[["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"}]],Os=Fe("heart",Bs);const Is=[["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"}]],Ms=Fe("image",Is);const zs=[["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=Fe("key-round",zs);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"}]],$t=Fe("tags",$s);function ps(t){const s=t.conditions||t.pod_conditions||[],o=n=>s.find(d=>(d.type||d.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 Ls(t){const{clusterCode:s,namespace:o,deployment:a,pods:n,revisions:d,onRefresh:i}=t,{toast:p}=Pe(),[D,h]=m.useState("pods"),[N,I]=m.useState(null),[q,V]=m.useState(null),[R,M]=m.useState(a?.replicas||0),[z,F]=m.useState(!1),[B,U]=m.useState([]),[Y,S]=m.useState([]),[Q,O]=m.useState([]),[H,ne]=m.useState(""),[oe,r]=m.useState([]),[b,f]=m.useState([]),P=a?.ready_replicas??a?.readyReplicas??0,l=a?.replicas??0,w=P===l&&l>0;m.useEffect(()=>{D==="services"&&(ne("services"),Promise.all([te.getNamespaceServices(s,o).catch(()=>[]),te.getNamespaceIngresses(s,o).catch(()=>[])]).then(([y,J])=>{const _=A=>Array.isArray(A)?A:A?.list||A?.items||A?.data||[],$=_(y),be=_(J),K=a?.spec?.selector?.matchLabels||a?.spec?.template?.metadata?.labels||{},he=$.filter(A=>{const ce=A.spec?.selector||A.selector||{};return Object.keys(ce).length===0?!1:Object.entries(ce).every(([ge,fe])=>K[ge]===fe)}).map(A=>({name:A.name||A.metadata?.name,type:A.spec?.type||A.type||"ClusterIP",clusterIP:A.spec?.clusterIP||A.cluster_ip||"<none>",ports:(A.spec?.ports||A.ports||[]).map(ce=>`${ce.port}${ce.targetPort?":"+ce.targetPort:""}/${ce.protocol||"TCP"}`),selector:A.spec?.selector||A.selector||{},age:A.age||""})),Ne=new Set(he.map(A=>A.name)),de=be.filter(A=>(A.spec?.rules||A.rules||[]).some(ge=>(ge.http?.paths||ge.paths||[]).some(fe=>{const g=fe.backend?.service?.name||fe.bacLine 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 d="none";return n.exec?d="exec":n.httpGet?d="httpGet":n.tcpSocket&&(d="tcpSocket"),{type:d,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 Gt(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 bt(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 Ht(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 Ft(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(h=>h.name.trim()).map(h=>{const N={name:h.name};return h.value!=null&&(N.value=h.value),N})),t.ports.length>0&&(s.ports=t.ports.filter(h=>h.containerPort!=="").map(h=>{const N={containerPort:typeof h.containerPort=="number"?h.containerPort:Number(h.containerPort)};return h.name&&(N.name=h.name),h.protocol&&(N.protocol=h.protocol),N}));const o=t.resources.requests,a=t.resources.limits,n=o&&Object.values(o).some(h=>h&&h.trim()),d=a&&Object.values(a).some(h=>h&&h.trim());(n||d)&&(s.resources={},n&&(s.resources.requests={},o.cpu?.trim()&&(s.resources.requests.cpu=o.cpu),o.memory?.trim()&&(s.resources.requests.memory=o.memory)),d&&(s.resources.limits={},a.cpu?.trim()&&(s.resources.limits.cpu=a.cpu),a.memory?.trim()&&(s.resources.limits.memory=a.memory)));const i=bt(t.livenessProbe);i&&(s.livenessProbe=i);const p=bt(t.readinessProbe);p&&(s.readinessProbe=p);const D=bt(t.startupProbe);if(D&&(s.startupProbe=D),t.lifecycle){const h={},N=Ht(t.lifecycle.postStart);N&&(h.postStart=N);const I=Ht(t.lifecycle.preStop);I&&(h.preStop=I),Object.keys(h).length>0&&(s.lifecycle=h)}if(t.securityContext){const h=t.securityContext,N={};h.runAsUser!==""&&h.runAsUser!=null&&(N.runAsUser=Number(h.runAsUser)),h.runAsGroup!==""&&h.runAsGroup!=null&&(N.runAsGroup=Number(h.runAsGroup)),h.runAsNonRoot!=null&&(N.runAsNonRoot=h.runAsNonRoot),h.privileged!=null&&(N.privileged=h.privileged),h.readOnlyRootFilesystem!=null&&(N.readOnlyRootFilesystem=h.readOnlyRootFilesystem),h.allowPrivilegeEscalation!=null&&(N.allowPrivilegeEscalation=h.allowPrivilegeEscalation);const I=(h.capabilitiesAdd||[]).filter(Boolean),q=(h.capabilitiesDrop||[]).filter(Boolean);(I.length||q.length)&&(N.capabilities={},I.length&&(N.capabilities.add=I),q.length&&(N.capabilities.drop=q)),Object.keys(N).length>0&&(s.securityContext=N)}return t.volumeMounts.length>0&&(s.volumeMounts=t.volumeMounts.filter(h=>h.name.trim()&&h.mountPath.trim()).map(h=>{const N={name:h.name,mountPath:h.mountPath};return h.subPath&&(N.subPath=h.subPath),h.readOnly&&(N.readOnly=!0),N})),s}function Yt(t){return t.join(`
|
||||
`)}function Jt(t){return t.split(`
|
||||
`).map(s=>s.trim()).filter(Boolean)}function qs({clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}){const{toast:i}=Pe(),[p,D]=m.useState(!1),[h,N]=m.useState(!a),[I,q]=m.useState(a||{}),[V,R]=m.useState([]),[M,z]=m.useState([]),[F,B]=m.useState([]);m.useEffect(()=>{if(!a){N(!1);return}q(a);const r=a?.spec?.template?.spec||{};R((Array.isArray(r.containers)?r.containers:[]).map(Lt)),z((Array.isArray(r.initContainers)?r.initContainers:[]).map(Lt)),B((Array.isArray(r.imagePullSecrets)?r.imagePullSecrets:[]).map(b=>b.name||"")),N(!1)},[a]);const U=(r,b)=>{R(f=>f.map((P,l)=>l===r?{...P,...b}:P))},Y=()=>{R(r=>[...r,Gt(`container-${r.length+1}`)])},S=r=>{R(b=>b.filter((f,P)=>P!==r))},Q=r=>{R(b=>{const f=JSON.parse(JSON.stringify(b[r]));f.name=`${f.name}-copy`;const P=[...b];return P.splice(r+1,0,f),P})},O=(r,b)=>{z(f=>f.map((P,l)=>l===r?{...P,...b}:P))},H=()=>{z(r=>[...r,Gt(`init-${r.length+1}`)])},ne=r=>{z(b=>b.filter((f,P)=>P!==r))},oe=async()=>{for(const r of[...M,...V]){if(!r.name.trim()){i({title:"保存失败",description:"容器名称不能为空",variant:"destructive"});return}if(!r.image.trim()){i({title:"保存失败",description:`容器 ${r.name} 的镜像不能为空`,variant:"destructive"});return}}D(!0);try{const r=JSON.parse(JSON.stringify(I));r.spec=r.spec||{},r.spec.template=r.spec.template||{},r.spec.template.spec=r.spec.template.spec||{},r.spec.template.spec.containers=V.map(Ft),r.spec.template.spec.initContainers=M.length>0?M.map(Ft):void 0,r.spec.template.spec.imagePullSecrets=F.filter(f=>f.trim()).length>0?F.filter(f=>f.trim()).map(f=>({name:f})):void 0;const b=JSON.stringify(r,null,2);await te.updateResourceYaml(t,s,"deployments",o,b),i({title:"容器配置已保存",description:`${o} 更新已提交`}),n()}catch(r){i({title:"保存失败",description:r?.message||String(r),variant:"destructive"})}finally{D(!1)}};return h?e.jsx(L,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:400:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:401:9",className:"p-12 text-center",children:[e.jsx(xe,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:402:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:403:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):a?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:419:5",className:"space-y-4",children:[e.jsxs(L,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:421:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(ie,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:422:9",className:"pb-3",children:e.jsxs(pe,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:423:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(_s,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:424:13",className:"h-4 w-4 text-amber-400"}),"镜像拉取凭证 (imagePullSecrets)",e.jsx(se,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:426:13",variant:"outline",className:"border-slate-700 text-slate-500 text-[10px]",children:"Pod 级别"})]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:429:9",className:"pt-0 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:430:11",className:"flex items-center gap-2 flex-wrap",children:[F.map((r,b)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:432:15",className:"flex items-center gap-1 bg-slate-800 rounded px-2 py-1",children:[e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:433:17",className:"text-xs text-slate-300 font-mono",children:r}),e.jsx("button",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:434:17",onClick:()=>B(f=>f.filter((P,l)=>l!==b)),className:"text-red-400 hover:text-red-300 ml-1",children:e.jsx(ue,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:435:68",className:"h-3 w-3"})})]},b)),F.length===0&&e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:438:47",className:"text-[11px] text-slate-600",children:"无"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:440:11",className:"flex gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:441:13",placeholder:"输入 Secret 名称后回车",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",onKeyDown:r=>{if(r.key==="Enter"){const b=r.target.value.trim();b&&(B(f=>[...f,b]),r.target.value="")}}}),e.jsxs(u,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:448:13",size:"sm",variant:"outline",className:"h-8 border-slate-700 text-slate-300 text-xs",on
Line truncated
|
||||
-c`,onChange:n=>s({command:Jt(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/DeploymentEditContainers.tsx:639:9",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:640:11",className:"text-slate-400 text-xs",children:"启动参数 (args) — 每行一个"}),e.jsx(st,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:641:11",value:Yt(o.args),placeholder:`--config=/etc/app.yaml
|
||||
--debug`,onChange:n=>s({args:Jt(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/DeploymentEditContainers.tsx:648:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:649:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:650:11",className:a,children:[e.jsx(ts,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:650:39",className:"h-3.5 w-3.5 text-cyan-400"})," 环境变量"]}),e.jsxs(u,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:651: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(ae,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:653:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:656:9",className:"space-y-1.5",children:[o.env.map((n,d)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:658:13",className:"grid grid-cols-[1fr_1.4fr_auto] gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:659:15",value:n.name,placeholder:"KEY",onChange:i=>{const p=[...o.env];p[d]={...n,name:i.target.value},s({env:p})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:662:15",value:n.value||"",placeholder:"value",onChange:i=>{const p=[...o.env];p[d]={...n,value:i.target.value},s({env:p})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:665:15",variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400",onClick:()=>s({env:o.env.filter((i,p)=>p!==d)}),children:e.jsx(ue,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:667:17",className:"h-3.5 w-3.5"})})]},d)),o.env.length===0&&e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:671:34",className:"text-[11px] text-slate-600",children:"无环境变量"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:676:7",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:677:9",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:678:11",className:a,children:[e.jsx(Se,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:678:39",className:"h-3.5 w-3.5 text-indigo-400"})," 端口"]}),e.jsxs(u,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:679: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(ae,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:681:13",className:"h-3 w-3 mr-1"}),"新增"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:684:9",className:"space-y-1.5",children:[o.ports.map((n,d)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:686:13",className:"grid grid-cols-[1fr_1fr_100px_auto] gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:687:15",value:n.name||"",placeholder:"http",onChange:i=>{const p=[...o.ports];p[d]={...n,name:i.target.value},s({ports:p})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:690:15",type:"number",value:n.containerPort,placeholder:"8080",onChange:i=>{const p=[...o.ports];p[d]={...n,containerPort:i.target.value},s({ports:p})},className:"bg-slate-800 border-slate-700 text-slate-200 font-mono text-xs h-8"}),e.jsxs(Le,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:693:15",value:n.protocol||"TCP",onValueChange:i=>{const p=[...o.ports];p[d]={...n,protocol:i},s({ports:p})},children:[e.jsx(Ge,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:694:17",className:"bg-slate-800 border-slate-700 text-slate-200 text-xs h-8",children:e.jsx(nt,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:695:19"})}),e.jsxs(He,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:697:17",className:"bg-slate-900 border-slate-700",children:[e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:698:19",value:"TCP",className:"text-slate-200",children:"TCP"}),e.jsx(ve,{"code-path":"src/components/kubernetes/DeploymentEditContainers.tsx:699:19",value:"UDP",className:"text-slate-2
Line truncated
|
||||
`):""),Rt(Array.isArray(W.searches)?W.searches.join(`
|
||||
`):"");const me=Array.isArray(W.options)?W.options:[];Me(me.map(le=>({name:le.name||"",value:le.value||""}))),N(!1)},[a]);const Bt=()=>w(x=>[...x,{key:"",value:""}]),Ot=x=>w(j=>j.filter((E,ee)=>ee!==x)),Ue=(x,j)=>w(E=>E.map((ee,re)=>re===x?{...ee,...j}:ee)),xs=async()=>{D(!0);try{const x=JSON.parse(JSON.stringify(I));x.spec=x.spec||{},x.spec.template=x.spec.template||{},x.spec.template.spec=x.spec.template.spec||{};const j=x.spec.template.spec;if(x.spec.strategy={type:V},V==="RollingUpdate"&&(x.spec.strategy.rollingUpdate={maxSurge:M,maxUnavailable:F}),U&&(x.spec.revisionHistoryLimit=Number(U)),S&&(x.spec.progressDeadlineSeconds=Number(S)),O==="nodeName"&&ne.trim())j.nodeName=ne.trim(),delete j.nodeSelector,j.affinity&&delete j.affinity.nodeAffinity;else if(O==="nodeSelector"){const W={};for(const{key:me,value:le}of l){const _e=me.trim();_e&&(W[_e]=le)}Object.keys(W).length>0?j.nodeSelector=W:delete j.nodeSelector,j.nodeName&&delete j.nodeName,j.affinity&&delete j.affinity.nodeAffinity}else if(O==="nodeAffinity"){const W=l.filter(me=>me.key.trim()).map(me=>({key:me.key.trim(),operator:"In",values:[me.value]}));W.length>0?(j.affinity=j.affinity||{},j.affinity.nodeAffinity={requiredDuringSchedulingIgnoredDuringExecution:{nodeSelectorTerms:[{matchExpressions:W}]}}):j.affinity&&delete j.affinity.nodeAffinity,delete j.nodeSelector,j.nodeName&&delete j.nodeName}const E=k.filter(W=>W.key||W.operator==="Exists").map(W=>{const me={};return W.key&&(me.key=W.key),W.operator&&(me.operator=W.operator),W.value&&W.operator!=="Exists"&&(me.value=W.value),W.effect&&(me.effect=W.effect),W.tolerationSeconds&&W.effect==="NoExecute"&&(me.tolerationSeconds=Number(W.tolerationSeconds)),me});E.length>0?j.tolerations=E:delete j.tolerations,J&&(j.dnsPolicy=J),$&&(j.restartPolicy=$),K&&(j.schedulerName=K),Ne&&(j.terminationGracePeriodSeconds=Number(Ne)),A&&(j.serviceAccountName=A);const ee={};ge&&(ee.fsGroup=Number(ge)),g&&(ee.runAsUser=Number(g)),je&&(ee.runAsGroup=Number(je)),We&&(ee.runAsNonRoot=!0),Object.keys(ee).length>0?j.securityContext=ee:delete j.securityContext,Je?j.hostNetwork=!0:delete j.hostNetwork,qe?j.hostIPC=!0:delete j.hostIPC,Ct?j.hostPID=!0:delete j.hostPID,Pt?j.shareProcessNamespace=!0:delete j.shareProcessNamespace;const re=dt.filter(W=>W.ip.trim()).map(W=>({ip:W.ip.trim(),hostnames:W.hostnames.split(/[,\s]+/).map(me=>me.trim()).filter(Boolean)})).filter(W=>W.hostnames.length>0);re.length>0?j.hostAliases=re:delete j.hostAliases;const ke={},ze=Vt.split(`
|
||||
`).map(W=>W.trim()).filter(Boolean);ze.length>0&&(ke.nameservers=ze);const Ke=Tt.split(`
|
||||
`).map(W=>W.trim()).filter(Boolean);Ke.length>0&&(ke.searches=Ke);const Ee=it.filter(W=>W.name.trim()).map(W=>{const me={name:W.name.trim()};return W.value.trim()&&(me.value=W.value.trim()),me});Ee.length>0&&(ke.options=Ee),Object.keys(ke).length>0?j.dnsConfig=ke:delete j.dnsConfig;const pt=JSON.stringify(x,null,2);await te.updateResourceYaml(t,s,"deployments",o,pt),i({title:"高级设置已保存",description:`${o} 更新已提交`}),n()}catch(x){i({title:"保存失败",description:x?.message||String(x),variant:"destructive"})}finally{D(!1)}};return h?e.jsx(L,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:328:7",className:"bg-slate-900 border-slate-800",children:e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:329:9",className:"p-12 text-center",children:[e.jsx(xe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:330:11",className:"h-6 w-6 animate-spin mx-auto text-slate-500"}),e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:331:11",className:"text-slate-500 mt-3 text-sm",children:"加载中..."})]})}):a?e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:348:5",className:"space-y-4",children:[e.jsxs(L,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:350:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(ie,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:351:9",className:"pb-3",children:e.jsxs(pe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:352:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(ct,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:353:13",className:"h-4 w-4 text-blue-400"}),"更新策略 (Strategy)"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:356:9",className:"pt-0 space-y-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:357:11",className:"flex items-center gap-4",children:[e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:358: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:359:15",type:"radio",checked:V==="RollingUpdate",onChange:()=>R("RollingUpdate"),className:"accent-blue-500"}),"RollingUpdate(滚动更新)"]}),e.jsxs("label",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:363: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:364:15",type:"radio",checked:V==="Recreate",onChange:()=>R("Recreate"),className:"accent-blue-500"}),"Recreate(重建)"]})]}),V==="RollingUpdate"&&e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:370:13",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:371:15",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:372:17",className:"text-slate-500 text-xs",children:"maxSurge(整数或百分比,超出期望副本数)"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:373:17",value:M,onChange:x=>z(x.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:376:15",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:377:17",className:"text-slate-500 text-xs",children:"maxUnavailable(整数或百分比,不可用上限)"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:378:17",value:F,onChange:x=>B(x.target.value),placeholder:"25%",className:"h-8 mt-1 bg-slate-800 border-slate-700 text-slate-200 text-sm font-mono"})]})]})]})]}),e.jsxs(L,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:387:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(ie,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:388:9",className:"pb-3",children:e.jsxs(pe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:389:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(ss,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:390:13",className:"h-4 w-4 text-amber-400"}),"历史版本 & 进度"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:393:9",className:"pt-0 grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:394:11",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:395:13",className:"text-slate-500 text-xs",children:"revisionHistoryLimit(保留 RS 历史)"}),e.jsx(v,{"code-path":"src/c
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/DeploymentEditAdvanced.tsx:667:13",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:668:15",className:"text-slate-500 text-xs",children:"searches(搜索域,每行一个)"}),e.jsx("textarea",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:669:15",value:Tt,onChange:x=>Rt(x.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/DeploymentEditAdvanced.tsx:675:11",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:676:13",className:"flex items-center justify-between mb-1",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:677:15",className:"text-slate-400 text-xs",children:"options(DNS 选项)"}),e.jsxs(u,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:678:15",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:()=>Me(x=>[...x,{name:"",value:""}]),children:[e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:680:17",className:"h-3 w-3 mr-1"}),"添加"]})]}),it.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:684:15",className:"text-xs text-slate-600 italic",children:"未配置"}):it.map((x,j)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:686:15",className:"flex items-center gap-2 mb-1.5",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:687:17",value:x.name,onChange:E=>Me(ee=>ee.map((re,ke)=>ke===j?{...re,name:E.target.value}:re)),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/DeploymentEditAdvanced.tsx:689:17",className:"text-slate-600",children:":"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:690:17",value:x.value,onChange:E=>Me(ee=>ee.map((re,ke)=>ke===j?{...re,value:E.target.value}:re)),placeholder:"5(可留空)",className:"flex-1 h-7 bg-slate-800 border-slate-700 text-slate-300 text-xs font-mono"}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:692:17",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>Me(E=>E.filter((ee,re)=>re!==j)),children:e.jsx(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:694:19",className:"h-3 w-3"})})]},j))]})]})]}),e.jsxs(L,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:703:7",className:"bg-slate-900 border-slate-800",children:[e.jsx(ie,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:704:9",className:"pb-3",children:e.jsxs(pe,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:705:11",className:"text-sm text-slate-200 flex items-center gap-2",children:[e.jsx(vs,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:706:13",className:"h-4 w-4 text-amber-400"}),"主机别名 (hostAliases)"]})}),e.jsxs(G,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:709:9",className:"pt-0 space-y-2",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:710:11",className:"flex items-center justify-between mb-1",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:711:13",className:"text-slate-400 text-xs",children:"IP → 主机名映射(注入 Pod 的 /etc/hosts)"}),e.jsxs(u,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:712:13",size:"sm",variant:"ghost",className:"h-6 text-xs text-slate-400",onClick:()=>Ie(x=>[...x,{ip:"",hostnames:""}]),children:[e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:714:15",className:"h-3 w-3 mr-1"}),"添加"]})]}),dt.length===0?e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:718:13",className:"text-xs text-slate-600 italic",children:"未配置"}):dt.map((x,j)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:720:13",className:"flex items-center gap-2",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:721:15",value:x.ip,onChange:E=>Ie(ee=>ee.map((re,ke)=>ke===j?{...re,ip:E.target.value}:re)),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/DeploymentEditAdvanced.tsx:723:15",className:"text-slate-600",children:"→"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:724:15",value:x.hostnames,onChange:E=>Ie(ee=>ee.map((re,ke)=>ke===j?{...re,hostnames:E.target.value}:re)),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(u,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:726:15",size:"icon",variant:"ghost",className:"h-6 w-6 text-red-400",onClick:()=>Ie(E=>E.filter((ee,re)=>re!==j)),children:e.jsx(ue,{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:728:17",className:"h-3 w-3"})})]},j))]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditAdvanced.tsx:736:7",cl
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(is,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:414:23",className:"h-2.5 w-2.5"}),c.label,e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:416:23",className:"text-slate-500 text-[9px]",children:[c.protocol," ",c.port,":",c.targetPort]})]},c.name))})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:423:15",className:"space-y-2",children:[e.jsxs(C,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:424:17",className:"text-slate-500 text-[11px]",children:["端口配置 ",e.jsxs("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:425:24",className:"text-slate-600",children:["(",U.ports.length," 个端口)"]})]}),U.ports.map((c,k)=>e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:428:19",className:"flex items-center gap-1.5 p-2 rounded bg-slate-800/50 border border-slate-700/50",children:[e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:430:21",value:c.name,onChange:y=>H(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:434:21",value:c.protocol,onChange:y=>H(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:436:23",value:"TCP",children:"TCP"}),e.jsx("option",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:437:23",value:"UDP",children:"UDP"})]}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:440:21",value:c.port,onChange:y=>H(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:443:21",className:"text-slate-600 text-[10px]",children:"→"}),e.jsx(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:444:21",value:c.targetPort,onChange:y=>H(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(v,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:449:23",value:c.nodePort,onChange:y=>H(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(u,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:454:21",size:"icon",variant:"ghost",className:"h-6 w-6 text-slate-500 hover:text-red-400",onClick:()=>ne(k),disabled:U.ports.length<=1,children:e.jsx(ft,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:456:23",className:"h-3 w-3"})})]},k)),e.jsxs(u,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:461:17",size:"sm",variant:"outline",className:"h-7 w-full border-dashed border-slate-700 text-slate-400 text-xs",onClick:()=>O(),children:[e.jsx(ae,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:463:19",className:"h-3 w-3 mr-1"}),"添加自定义端口"]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:468: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:469:17",className:"text-slate-600",children:"selector (自动检测): "}),Object.keys(V).length>0?Object.entries(V).map(([c,k])=>e.jsxs("code",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:472:21",className:"bg-slate-800 px-1 py-0.5 rounded text-slate-400 ml-1",children:[c,"=",k]},c)):e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:475:19",className:"text-slate-600 italic",children:"未检测到"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:479:15",className:"flex justify-end gap-2 pt-1",children:[e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:480:17",size:"sm",variant:"ghost",className:"h-7 text-xs text-slate-400",onClick:()=>B(null),children:"取消"}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:481:17",size:"sm",className:"h-7 bg-blue-600 hover:bg-blue-700 text-xs",onClick:l,children:"创建"})]})]})]})]}),e.jsxs(L,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:489:7",className:"bg-slate-900 border-slate-800",children:[e.jsxs(ie,{"code-path":"src/components/kubernetes/DeploymentEditService.tsx:490:9",className:"pb-3",children:[e.jsxs("div",{"code-path":"src/components/kube
Line truncated
|
||||
${N?"border-blue-500 text-blue-400":h.available?"border-transparent text-slate-400 hover:text-slate-200":"border-transparent text-slate-600 cursor-not-allowed"}`,children:[e.jsx(I,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:584:15",className:"h-3.5 w-3.5"}),h.label,h.badge&&e.jsx("span",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:587: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:h.badge})]},h.key)})}),i==="basic"?e.jsx(Xs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:598:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}):i==="containers"?e.jsx(qs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:608:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}):i==="storage"?e.jsx(en,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:618:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}):i==="advanced"?e.jsx(tn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:628:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}):i==="service"?e.jsx(nn,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:638:9",clusterCode:t,namespace:s,deploymentName:o,manifest:a,onSaved:n,onCancel:d}):null]})}function cn({clusterCode:t,namespace:s,deploymentName:o}){const{toast:a}=Pe(),n=Nt(D=>D.token)||localStorage.getItem("token")||"",d=`${window.location.origin}/api/v1/clusters/${t}/namespaces/${s}/deployments/${o}/update-image`,i=`curl -X POST '${d}' \\
|
||||
-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"}'`,p=D=>{navigator.clipboard.writeText(D).then(()=>a({title:"已复制"})).catch(()=>{})};return e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:666:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:667:7",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:668:9",className:"text-slate-400 text-sm",children:"Webhook URL"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:669:9",className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:670:11",className:"flex-1 text-xs text-slate-300 bg-slate-800 rounded px-3 py-2 break-all font-mono",children:d}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:671:11",variant:"outline",size:"sm",className:"border-slate-700 text-slate-400 shrink-0",onClick:()=>p(d),children:"复制"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:674:7",children:[e.jsx(C,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:675:9",className:"text-slate-400 text-sm",children:"curl 示例"}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:676:9",className:"relative mt-1",children:[e.jsx("pre",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:677:11",className:"text-xs text-slate-300 bg-slate-800 rounded p-3 overflow-x-auto font-mono whitespace-pre-wrap",children:i}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:678:11",variant:"outline",size:"sm",className:"absolute top-2 right-2 border-slate-700 text-slate-400",onClick:()=>p(i),children:"复制"})]})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:681:7",className:"text-xs text-slate-500 space-y-1",children:[e.jsx("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:682:9",children:"• 使用 Bearer Token 认证(JWT 登录令牌)"}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:683:9",children:["• ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:683:14",className:"text-slate-400",children:"image"})," 必填,指定新镜像地址"]}),e.jsxs("p",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:684:9",children:["• ",e.jsx("code",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:684:14",className:"text-slate-400",children:"container"})," 可选,不填则更新第一个容器"]})]})]})}function et({title:t,children:s,onClose:o}){return e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:693: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:694: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:695:9",className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:696:11",className:"text-base font-bold text-slate-100",children:t}),e.jsx(u,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:697:11",variant:"ghost",size:"icon",className:"h-7 w-7 text-slate-400",onClick:o,children:e.jsx(cs,{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:697:100",className:"h-4 w-4"})})]}),s]})})}function rn({clusterCode:t,namespace:s,podName:o,containers:a,onClose:n}){const{toast:d}=Pe(),[i,p]=m.useState(""),[D,h]=m.useState(200),[N,I]=m.useState(a[0]||""),[q,V]=m.useState(!1),[R,M]=m.useState(!1),z=async()=>{V(!0);try{const B=await te.getPodLogs(t,s,o,D,N||void 0);p(B?.data?.logs||B?.logs||B||"无日志")}catch{p("获取日志失败")}finally{V(!1)}};m.useEffect(()=>{z()},[N,D]);const F=async()=>{M(!0);const B=Nt.getState().token||"",U="",Y=N?`&container=${encodeURIComponent(N)}`:"",S=`${U}/api/v1/kubernetes/${t}/namespace/${s}/pods/${o}/logs?tail=${D}&stream=true${Y}`;try{const O=(await fetch(S,{headers:{Authorization:`Bearer ${B}`}})).body?.getReader();if(!O)return;const H=new TextDecoder;let ne="";for(;;){const{done:oe,value:r}=await O.read();if(oe)break;ne+=H.decode(r,{stream:!0}),p(ne)}}catch{d({title:"流式日志连接中断",variant:"destructive"})}finally{M(!1)}};return e.jsx("div",{"code-path":"src/components/kubernetes/DeploymentWorkload.tsx:752: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:753:7",className:"bg-slate-900 border border-slate-700 rounded-xl w-[90vw] max-w-4xl max-h-[80vh] flex flex-col",onClick:B=>B.stopPropagation(),children:[e.jsxs("div",{"code-path
Line truncated
|
||||
Reference in new issue
Block a user