chore: 重新编译前端产物(补装CodeMirror依赖)
This commit is contained in:
1 parent
23e9e3da62
commit
4e384ca401
115 files changed
+147
-147
No files matched your search
@@ -0,0 +1,5 @@
|
||||
import{r as c,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{C as z,b as F,c as H,d as oe,a as R}from"./card-BIfzBCEy.js";import{f as je,r as q,u as v,B as l,m as Q,s as ve,D as W,a as Y,b as Z,c as ee,d as se,e as te,v as ce,o as be}from"./index-Dungj95X.js";import{I as k}from"./input-CXoUQQLm.js";import{L as C}from"./label-CMpUoC87.js";import{B as _}from"./badge-CGJlVD3L.js";import{u as ne}from"./use-toast-DNZLibQY.js";import{C as I}from"./code-snippet-block-E9P2jHS4.js";import{aj as ae,P as re,L as D,ak as Se,x as Ne,al as Pe,am as Ke,an as we,b as ke,A as Ce,ao as _e,U as De,j as Te}from"./vendor-icons-DmqcWdzX.js";function B(t){if(!t)return"—";const a=new Date(t);return Number.isNaN(a.getTime())?"—":a.toLocaleString()}function T(t=12){const a=new Date;return a.setMonth(a.getMonth()+t),a.toISOString().slice(0,10)}function Le(t){if(!t)return T();const a=new Date(t);return Number.isNaN(a.getTime())?T():a.toISOString().slice(0,10)}function $e(t,a){if(!t||!a)return{pct:0,daysLeft:null};const n=new Date(t).getTime(),s=new Date(a).getTime(),x=Date.now();if(s<=n)return{pct:0,daysLeft:0};const y=Math.max(0,Math.ceil((s-x)/864e5));return{pct:Math.min(100,Math.max(0,(x-n)/(s-n)*100)),daysLeft:y}}function Oe(t){return t?t.length<=10?t:`${t.slice(0,6)}…${t.slice(-4)}`:"—"}function Me(){const{toast:t}=ne(),a=je(),n=ve(),[s,x]=c.useState(null),[y,u]=c.useState(!0),[p,d]=c.useState(!1),[A,N]=c.useState(!1),[P,f]=c.useState(""),[K,m]=c.useState(!1),[j,r]=c.useState("create"),[L,$]=c.useState(""),[w,O]=c.useState(T()),[ie,M]=c.useState(!1),[de,pe]=c.useState(""),U=c.useCallback(async()=>{u(!0);try{const i=q();i&&f(i);const S=await v.getApiAccessKey().catch(()=>({has_token:!1}));x(S)}finally{u(!1)}},[]);c.useEffect(()=>{U()},[U]);const h=P||q(),le=s?.access_key_mask||(s?.prefix?`${s.prefix}.•••••••••••••••••••••••••••••••••`:""),{pct:xe,daysLeft:me}=c.useMemo(()=>$e(s?.created_at,s?.expires_at),[s?.created_at,s?.expires_at]),g=s?.days_left??me,b=!!s?.expired||s?.status==="expired"||g!=null&&g<=0,E=()=>{r("create"),$(""),O(T()),m(!0)},ue=()=>{r("edit"),$(s?.description||""),O(Le(s?.expires_at)),m(!0)},he=async()=>{if(j==="edit"){d(!0);try{const o=await v.updateApiAccessKey({description:L,expires_at:w});x(o),m(!1),t({title:"凭证信息已更新"})}catch(o){t({title:"更新失败",description:o?.message||String(o),variant:"destructive"})}finally{d(!1)}return}const i=!!s?.has_token;if(await a({title:i?"轮换凭证":"签发凭证",description:i?"旧凭证将立即作废,是否继续?":"凭证明文仅显示一次,请妥善保存。",confirmText:i?"轮换":"签发",variant:i?"destructive":"default"})){d(!0);try{const o=await v.regenerateApiAccessKey({description:L,expires_at:w});f(o.token),ce(o.token),pe(o.token),M(!0),m(!1),x({has_token:!0,key_id:o.key_id,prefix:o.prefix,access_key_mask:`${o.prefix}.•••••••••••••••••••••••••••••••••`,description:o.description,created_at:o.created_at,expires_at:o.expires_at,status:"active",expired:!1,days_left:Math.ceil((new Date(o.expires_at).getTime()-Date.now())/864e5)}),t({title:"凭证已签发",description:"已保存至本浏览器,请立即复制"})}catch(o){t({title:"签发失败",description:o?.message||String(o),variant:"destructive"})}finally{d(!1)}}},ge=async()=>{if(await a({title:"吊销凭证",description:"吊销后 Pipeline / curl 调用将全部失败,是否继续?",confirmText:"吊销",variant:"destructive"})){d(!0);try{await v.revokeApiAccessKey(),f(""),ce(""),x({has_token:!1}),t({title:"凭证已吊销"})}catch(S){t({title:"吊销失败",description:S?.message||String(S),variant:"destructive"})}finally{d(!1)}}},X=h?`X-AIOps-Access-Key: ${h}`:"X-AIOps-Access-Key: <你的访问凭证>",G="test-k8s",J="default",V="demo-jar",ye=`curl -X POST '${n}/kubernetes/${G}/namespace/${J}/deployments/${V}/update-image' \\
|
||||
-H '${X}' \\
|
||||
-H 'Content-Type: application/json' \\
|
||||
-d '{"image":"harbor.example.com/app:v1.0","container_name":"main"}'`,Ae=`curl -X POST '${n}/kubernetes/${G}/namespace/${J}/deployments/${V}/restart' \\
|
||||
-H '${X}'`,fe=b?"bg-red-500":g!=null&&g<=30?"bg-amber-400":"bg-[var(--dg-blue)]";return e.jsxs(e.Fragment,{children:[e.jsxs(z,{"code-path":"src/components/user/ApiAccessKeySection.tsx:229:7",className:"dg-card border-[var(--dg-blue)]/20",children:[e.jsxs(F,{"code-path":"src/components/user/ApiAccessKeySection.tsx:230:9",className:"flex flex-row items-start justify-between gap-4 space-y-0",children:[e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:231:11",children:[e.jsxs(H,{"code-path":"src/components/user/ApiAccessKeySection.tsx:232:13",className:"text-base flex items-center gap-2 text-[var(--dg-text-primary)]",children:[e.jsx(ae,{"code-path":"src/components/user/ApiAccessKeySection.tsx:233:15",className:"h-4 w-4 text-[var(--dg-blue)]"}),"CI/CD 访问凭证",e.jsx(_,{"code-path":"src/components/user/ApiAccessKeySection.tsx:235:15",className:"text-[10px] bg-[var(--dg-blue)]/15 text-[var(--dg-blue)] border-[var(--dg-blue)]/30",children:"长期有效"})]}),e.jsx(oe,{"code-path":"src/components/user/ApiAccessKeySection.tsx:237:13",className:"text-xs mt-1",children:"每人唯一凭证,Deployment 发布脚本自动引用,不随登录会话过期。"})]}),!y&&!s?.has_token&&e.jsxs(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:242:13",size:"sm",onClick:E,disabled:p,children:[e.jsx(re,{"code-path":"src/components/user/ApiAccessKeySection.tsx:243:15",className:"h-4 w-4 mr-1"}),"签发凭证"]})]}),e.jsxs(R,{"code-path":"src/components/user/ApiAccessKeySection.tsx:247:9",className:"space-y-4",children:[y?e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:249:13",className:"flex items-center gap-2 py-8 text-sm text-[var(--dg-text-muted)] justify-center",children:[e.jsx(D,{"code-path":"src/components/user/ApiAccessKeySection.tsx:250:15",className:"h-4 w-4 animate-spin"}),"加载中…"]}):s?.has_token?e.jsx("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:253:13",className:"rounded-xl border border-[var(--dg-border)] bg-[var(--dg-bg-tertiary)]/40 overflow-hidden",children:e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:255:15",className:"flex",children:[e.jsx("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:256:17",className:Q("w-1 shrink-0",b?"bg-red-500":g!=null&&g<=30?"bg-amber-400":"bg-gradient-to-b from-[var(--dg-blue)] to-[var(--dg-purple)]")}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:260:17",className:"flex-1 p-4 space-y-4",children:[e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:261:19",className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:262:21",className:"space-y-1 min-w-0 flex-1",children:[e.jsx("p",{"code-path":"src/components/user/ApiAccessKeySection.tsx:263:23",className:"text-[10px] uppercase tracking-wider text-[var(--dg-text-muted)]",children:"凭证字符串"}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:264:23",className:"flex items-center gap-2",children:[e.jsx("code",{"code-path":"src/components/user/ApiAccessKeySection.tsx:265:25",className:"flex-1 min-w-0 text-xs font-mono text-[var(--dg-text-primary)] bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded-md px-3 py-2 truncate block",children:A&&h?h:le}),h&&e.jsx(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:269:27",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0 border-[var(--dg-border)]",onClick:()=>N(!A),title:A?"隐藏":"显示",children:A?e.jsx(Se,{"code-path":"src/components/user/ApiAccessKeySection.tsx:276:42",className:"h-3.5 w-3.5"}):e.jsx(Ne,{"code-path":"src/components/user/ApiAccessKeySection.tsx:276:79",className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:281:21",className:"flex flex-wrap gap-1.5 shrink-0",children:[e.jsxs(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:282:23",variant:"outline",size:"sm",className:"h-8 text-xs border-[var(--dg-border)]",onClick:ue,disabled:p,children:[e.jsx(Pe,{"code-path":"src/components/user/ApiAccessKeySection.tsx:283:25",className:"h-3 w-3 mr-1"}),"调整"]}),e.jsxs(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:285:23",variant:"outline",size:"sm",className:"h-8 text-xs border-[var(--dg-border)]",onClick:E,disabled:p,children:[e.jsx(Ke,{"code-path":"src/components/user/ApiAccessKeySection.tsx:286:25",className:"h-3 w-3 mr-1"}),"轮换"]}),e.jsxs(l,{"code-path":"src/components/user/ApiAccessKeySection.tsx:288:23",variant:"outline",size:"sm",className:"h-8 text-xs border-red-500/30 text-red-400",onClick:ge,disabled:p,children:[e.jsx(we,{"code-path":"src/components/user/ApiAccessKeySection.tsx:289:25",className:"h-3 w-3 mr-1"}),"吊销"]})]})]}),e.jsxs("div",{"code-path":"src/components/user/ApiAccessKeySection.tsx:294:19",className:"grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-3 text-xs",children:[e.js
Line truncated
|
||||
Reference in new issue
Block a user