PageSourceSearch

https://nickz.ai/assets/js/index-Cv-P9mTL.js

js nickz.ai collected 2026-10-05 14:21:06 UTC 47,392 bytes, 1 lines download raw bytes

1import{r as e,j as s,R as l}from"./vendor-react-DejgYtBM.js";import{f as i,z as a,aF as t,i as n,u as r,l as o,G as d,B as c,r as m,aG as x,aH as u,aI as p,aJ as g,aK as h,aL as y,aM as f,aN as j,q as b,E as v,W as k,p as w,V as z,Y as _,J as N,K as S,o as C,v as T,aO as R,j as D,F as I,aP as A}from"./vendor-semi-D8d7bTtM.js";import{u as B,A as M,aI as O,aR as L}from"./index-BeIIFw6E.js";import{C as q}from"./CardPro-DfDWu9ok.js";import{u as F}from"./useIsMobile-D_kfVI0u.js";import{aX as G,aO as P,ag as $,ai as K,bF as W,ak as U,Z as H,v as V,a7 as E,r as Y}from"./vendor-icons-EJvJ5X-w.js";import{Q as J}from"./QuickGuide-BUkei3jq.js";import"./vendor-motion-Chfy_MiU.js";const{Text:Q}=i,X=9.72,Z=3.888,ee=.1944;function se(e){return"number"!=typeof e||Number.isNaN(e)?"0":Number(e.toFixed(2)).toString()}const le={cpu:{min:1,max:16,step:1},mem:{min:1,max:32,step:1},disk:{min:10,max:100,step:10}},ie=[{key:"small",labelKey:"经济型",cpu:2,mem:4,disk:20,descKey:"轻量代码补全、短对话任务"},{key:"medium",labelKey:"标准",recommended:!0,cpu:4,mem:8,disk:20,descKey:"日常编程、中等代码库(推荐)"},{key:"large",labelKey:"性能型",cpu:8,mem:16,disk:40,descKey:"重型任务、多文件大项目"}];function ae(e,s,l){for(const i of ie)if(i.cpu===e&&i.mem===s&&i.disk===l)return i.key;return"custom"}function te(e,s,l){return(e||0)*X+(s||0)*Z+(l||0)*ee}function ne({value:l,onChange:i,readOnly:n=!1,showPriceHint:r=!0}){const{t:o}=B(),d=l||{key:"medium",cpu:4,mem:8,disk:20},c="custom"===d.key,m=(e,s)=>{n||i?.({...d,key:"custom",[e]:s})},x=e.useMemo(()=>te(d.cpu,d.mem,d.disk),[d.cpu,d.mem,d.disk]);return s.jsxs("div",{className:"oc-preset-selector",children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[ie.map(e=>{const l=d.key===e.key;return s.jsx(re,{active:l,disabled:n,title:o(e.labelKey),recommended:e.recommended,cpu:e.cpu,mem:e.mem,disk:e.disk,desc:o(e.descKey),onClick:()=>{return s=e,void(n||i?.({key:s.key,cpu:s.cpu,mem:s.mem,disk:s.disk}));var s},recommendedLabel:o("推荐"),customLabel:o("自定义")},e.key)}),s.jsx(re,{active:c,disabled:n,title:o("自定义"),desc:o("按需调整 CPU / 内存 / 磁盘"),custom:!0,cpu:c?d.cpu:null,mem:c?d.mem:null,disk:c?d.disk:null,onClick:()=>{n||i?.({...d,key:"custom"})},recommendedLabel:o("推荐"),customLabel:o("自定义")})]}),c&&s.jsx("div",{className:"mt-3 p-3 rounded-lg",style:{border:"1px dashed var(--semi-color-primary)",background:"var(--semi-color-primary-light-default)"},children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[s.jsx(oe,{label:o("CPU 核数"),suffix:"vCPU",value:d.cpu,bounds:le.cpu,disabled:n,onChange:e=>m("cpu",e),rangeLabel:o("范围 {{min}} - {{max}} {{unit}}",{min:le.cpu.min,max:le.cpu.max,unit:"vCPU"})}),s.jsx(oe,{label:o("内存"),suffix:"GB",value:d.mem,bounds:le.mem,disabled:n,onChange:e=>m("mem",e),rangeLabel:o("范围 {{min}} - {{max}} {{unit}}",{min:le.mem.min,max:le.mem.max,unit:"GB"})}),s.jsx(oe,{label:o("磁盘"),suffix:"GB",value:d.disk,bounds:le.disk,disabled:n,onChange:e=>m("disk",e),rangeLabel:o("范围 {{min}} - {{max}} {{unit}}",{min:le.disk.min,max:le.disk.max,unit:"GB"})})]})}),r&&s.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs",children:[s.jsx(Q,{type:"tertiary",size:"small",children:o("当前规格:{{cpu}} vCPU · {{mem}} GB 内存 · {{disk}} GB 磁盘",{cpu:d.cpu,mem:d.mem,disk:d.disk})}),s.jsx(a,{content:s.jsx(de,{cpu:d.cpu,mem:d.mem,disk:d.disk}),children:s.jsxs("span",{className:"inline-flex items-center gap-1 cursor-help",style:{color:"var(--semi-color-text-1)"},children:[s.jsx(t,{size:"small"}),s.jsx(Q,{size:"small",children:o("{{price}} 额度/月",{price:se(x)})})]})})]})]})}function re({active:e,disabled:l,title:i,recommended:a,cpu:t,mem:r,disk:o,desc:d,custom:c,onClick:m,recommendedLabel:x,customLabel:u}){const p={cursor:l?"not-allowed":"pointer",border:e?"2px solid var(--semi-color-primary)":"1px solid var(--semi-color-border)",borderRadius:8,padding:"12px 14px",background:e?"var(--semi-color-primary-light-default)":"var(--semi-color-bg-2)",transition:"all 0.15s ease",opacity:l&&!e?.55:1,minHeight:110,display:"flex",flexDirection:"column",justifyContent:"space-between"};return s.jsxs("div",{onClick:l?void 0:m,style:p,role:"button",tabIndex:l?-1:0,"aria-pressed":e,children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx(Q,{strong:!0,style:{fontSize:14},children:i}),a&&s.jsx(n,{color:"green",size:"small",children:x}),c&&s.jsx(n,{color:"violet",size:"small",children:u})]}),c&&null==t?s.jsx(Q,{type:"tertiary",size:"small",children:d}):s.jsxs("div",{children:[s.jsxs("div",{style:{fontSize:13,color:"var(--semi-color-text-1)",lineHeight:1.6},children:[s.jsxs("span",{children:[t," vCPU"]}),s.jsx("span",{style:{margin:"0 6px",opacity:.5},children:"·"}),s.jsxs("span",{children:[r," GB"]}),s.jsx("span",{style:{margin:"0 6px",opacity:.5},children:"·"}),s.jsxs("span",{children:[o," GB"]})]}),d&&s.jsx(Q,{type:"tertiary",size:"small",style:{display:"block",marginTop:4},children:d})]})]})}function oe({label:e,suffix:l,value:i,bounds:a,disabled:t,onChange:n,rangeLabel:o}){return s.jsxs("div",{children:[s.jsx(Q,{size:"small",style:{display:"block",marginBottom:6},children:e}),s.jsx(r,{value:i,onChange:n,min:a.min,max:a.max,step:a.step,disabled:t,suffix:l,style:{width:"100%"}}),s.jsx(Q,{type:"tertiary",size:"small",style:{marginTop:4,display:"block"},children:o})]})}function de({cpu:e,mem:l,disk:i}){const{t:a}=B(),t=(e||0)*X,n=(l||0)*Z,r=(i||0)*ee,o=t+n+r;return s.jsxs("div",{style:{minWidth:220},children:[s.jsx("div",{style:{marginBottom:6,fontWeight:600},children:a("包月扣费明细")}),s.jsxs("div",{style:{fontSize:12,lineHeight:1.7},children:[s.jsxs("div",{children:["CPU:",e," × ",X," = ",se(t)," ",a("额度")]}),s.jsxs("div",{children:[a("内存"),":",l," × ",Z," = ",se(n)," ",a("额度")]}),s.jsxs("div",{children:[a("磁盘"),":",i," × ",ee," = ",se(r)," ",a("额度")]}),s.jsx("div",{style:{marginTop:4,paddingTop:4,borderTop:"1px dashed currentColor"},children:a("合计 = {{total}} 额度/月",{total:se(o)})})]}),s.jsx("div",{style:{marginTop:8,fontSize:11,opacity:.8},children:a("包月预付,删除不退费;同规格新建复用空闲槽位免扣费。")})]})}const{Text:ce,Title:me}=i,xe={creating:{color:"orange",textKey:"部署中",accent:"linear-gradient(90deg, #f97316 0%, #fbbf24 100%)",glow:"rgba(249, 115, 22, 0.35)"},running:{color:"green",textKey:"运行中",accent:"linear-gradient(90deg, #10b981 0%, #34d399 100%)",glow:"rgba(16, 185, 129, 0.35)"},stopped:{color:"grey",textKey:"已停止",accent:"linear-gradient(90deg, #94a3b8 0%, #cbd5e1 100%)",glow:"rgba(148, 163, 
1184, 0.25)"},error:{color:"red",textKey:"异常",accent:"linear-gradient(90deg, #ef4444 0%, #f87171 100%)",glow:"rgba(239, 68, 68, 0.35)"},unknown:{color:"grey",textKey:"未知",accent:"linear-gradient(90deg, #94a3b8 0%, #cbd5e1 100%)",glow:"rgba(148, 163, 184, 0.25)"}},ue=({icon:e,value:l,unit:i,label:a,color:t})=>s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg flex-1 min-w-0",style:{background:`${t}12`,border:`1px solid ${t}33`},children:[s.jsx(e,{size:16,style:{color:t,flexShrink:0}}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"leading-tight",style:{fontWeight:600,fontSize:14,color:"var(--semi-color-text-0)"},children:[l,s.jsx("span",{style:{fontSize:11,fontWeight:400,marginLeft:2,color:"var(--semi-color-text-2)"},children:i})]}),s.jsx("div",{style:{fontSize:11,color:"var(--semi-color-text-2)",lineHeight:1.2},children:a})]})]});function pe({instance:l,onOpen:i,onEdit:t,onCredentials:r,onDelete:y,onResume:f,onRenew:j,onRefund:b,onToggleAutoRenew:v,openingId:k,resumingId:w,loadingMaskMs:z=0}){const{t:_}=B(),N=xe[l.status]||xe.unknown,S="running"===l.status,C="creating"===l.status,T="suspended"===l.billing_status,R=!1!==l.auto_renew,D="number"==typeof l.days_remaining?l.days_remaining:function(e){if(!e)return-1;const s=new Date(e).getTime();if(Number.isNaN(s)||s<=0)return-1;const l=s-Date.now();return l<=0?0:Math.floor(l/864e5)+1}(l.paid_until),I=(()=>{if(!T||!l.suspended_at)return-1;const e=new Date(l.suspended_at).getTime();if(Number.isNaN(e))return-1;const s=e+6048e5;return Math.max(0,Math.ceil((s-Date.now())/864e5))})(),[A,M]=e.useState(0);e.useEffect(()=>{if(z<=0)return void M(0);M(Math.ceil(z/1e3));const e=Date.now(),s=setInterval(()=>{const l=Math.ceil((z-(Date.now()-e))/1e3);l<=0?(M(0),clearInterval(s)):M(l)},200);return()=>clearInterval(s)},[z]);const O=A>0,L=e.useMemo(()=>({position:"relative",border:"1px solid var(--semi-color-border)",borderRadius:14,padding:"0 0 16px 0",background:"var(--semi-color-bg-1)",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",minHeight:240,display:"flex",flexDirection:"column",overflow:"hidden"}),[]);return s.jsxs("div",{style:L,className:"oc-instance-card",children:[s.jsx("div",{style:{height:4,background:N.accent,flexShrink:0}}),s.jsxs("div",{className:"px-4 pt-4 flex flex-col gap-3 flex-1",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(me,{heading:5,ellipsis:{rows:1},style:{margin:0},children:l.name}),s.jsxs("div",{className:"flex items-center gap-3 mt-1 flex-wrap",style:{color:"var(--semi-color-text-2)"},children:[s.jsxs("span",{className:"flex items-center gap-1",style:{fontSize:12},children:[s.jsx(G,{size:11}),l.clawmanager_id]}),s.jsxs("span",{className:"flex items-center gap-1",style:{fontSize:12},children:[s.jsx(P,{size:11}),(q=l.created_at,q?new Date(1e3*q).toLocaleString():"-")]}),l.region_name&&s.jsxs("span",{className:"flex items-center gap-1",style:{fontSize:12},title:l.region_code?_("机房代码:{{code}}",{code:l.region_code}):void 0,children:[s.jsx($,{size:11}),l.region_name]})]})]}),s.jsxs(n,{color:N.color,size:"small",style:S||C?{boxShadow:`0 0 0 4px ${N.glow}`,transition:"box-shadow 0.3s ease"}:void 0,children:[C&&s.jsx("span",{className:"oc-pulse-dot",style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:"currentColor",marginRight:4,verticalAlign:"middle"}}),_(N.textKey)]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ue,{icon:K,value:l.cpu_cores||"-",unit:_("核"),label:"vCPU",color:"#3b82f6"}),s.jsx(ue,{icon:W,value:l.memory_gb||"-",unit:"GB",label:_("内存"),color:"#8b5cf6"}),s.jsx(ue,{icon:U,value:l.disk_gb||"-",unit:"GB",label:_("磁盘"),color:"#06b6d4"})]}),Array.isArray(l.model_names)&&l.model_names.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1 mb-1.5",style:{color:"var(--semi-color-text-2)"},children:[s.jsx(H,{size:12}),s.jsx(ce,{type:"tertiary",size:"small",children:_("已配置 {{count}} 个模型",{count:l.model_names.length})}),l.config_version>1&&s.jsx(n,{size:"small",color:"amber",style:{marginLeft:6},children:_("已编辑 {{count}} 次",{count:l.config_version-1})})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[l.model_names.slice(0,4).map(e=>{const i=e===l.default_model;return s.jsx(n,{size:"small",color:i?"violet":"grey",style:{maxWidth:180},children:s.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"inline-block",maxWidth:160},children:[i&&"★ ",e]})},e)}),l.model_names.length>4&&s.jsxs(n,{size:"small",color:"grey",children:["+",l.model_names.length-4]})]})]}),C&&s.jsxs("div",{className:"px-2.5 py-1.5 rounded-md flex items-center gap-2",style:{background:"rgba(249, 115, 22, 0.08)",border:"1px dashed rgba(249, 115, 22, 0.4)"},children:[s.jsx(o,{size:"small"}),s.jsx(ce,{type:"tertiary",size:"small",children:_("首次部署约 1-3 分钟,列表会自动刷新…")})]}),!C&&T&&s.jsxs("div",{className:"px-2.5 py-2 rounded-md",style:{background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.35)"},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(V,{size:14,style:{color:"#dc2626"}}),s.jsx(ce,{strong:!0,style:{color:"#dc2626",fontSize:13},children:_("实例已挂起")})]}),s.jsx(ce,{type:"secondary",size:"small",style:{display:"block",marginTop:4},children:I>0?_("{{days}} 天后将自动清除数据,请尽快充值并恢复",{days:I}):_("即将清除数据")})]}),!C&&!T&&-1===D&&s.jsxs("div",{className:"px-2.5 py-1.5 rounded-md flex items-center gap-2",style:{background:"rgba(148, 163, 
1184, 0.08)",border:"1px dashed rgba(148, 163, 184, 0.35)"},children:[s.jsx(V,{size:12,style:{color:"var(--semi-color-text-2)"}}),s.jsx(ce,{type:"tertiary",size:"small",children:_("无槽位(旧实例 / 数据缺失)")})]}),!C&&!T&&D>=0&&D<=3&&!(0===D&&R)&&s.jsxs("div",{className:"px-2.5 py-1.5 rounded-md flex items-center justify-between gap-2",style:{background:R?"rgba(245, 158, 11, 0.10)":"rgba(239, 68, 68, 0.08)",border:R?"1px solid rgba(245, 158, 11, 0.35)":"1px solid rgba(239, 68, 68, 0.35)"},children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(V,{size:12,style:{color:R?"#d97706":"#dc2626",flexShrink:0}}),s.jsx(ce,{size:"small",style:{color:R?"#92400e":"#991b1b"},children:0===D?_("已到期,即将挂起,请稍候片刻刷新页面使用「立即恢复」继续使用"):_(R?"{{days}} 天后自动续费":"{{days}} 天后将挂起",{days:D})})]}),D>=1&&l.slot_id>0&&s.jsx(d,{title:_("立即续费"),content:_("确认后立即扣费并续期 30 天;已剩余的天数会保留,不会丢失。"),onConfirm:()=>j?.(l),okText:_("确认续费"),cancelText:_("取消"),children:s.jsx(c,{size:"small",type:"primary",theme:"solid",style:{flexShrink:0},children:_("立即续费")})})]}),!C&&!T&&l.slot_id>0&&s.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 rounded-md",style:{background:"rgba(99, 102, 241, 0.06)",border:"1px solid rgba(99, 102, 241, 0.18)"},children:[s.jsx(a,{content:_(0===D&&R?"系统正在为您续费,请稍候(约 1 分钟内生效)":0===D?"槽位已到期,请使用「立即续费」按钮续期":R?"到期且余额够时自动续费 30 天":"到期不续,将挂起 7 天后清除"),children:s.jsxs("span",{className:"flex items-center gap-1.5 cursor-help",style:{color:"var(--semi-color-text-1)"},children:[s.jsx(V,{size:12}),s.jsx(ce,{size:"small",children:_("自动续费")}),D>0&&s.jsx(ce,{type:"tertiary",size:"small",children:_("(剩 {{days}} 天)",{days:D})})]})}),s.jsx(m,{size:"small",checked:R,disabled:0===D,onChange:e=>v?.(l.slot_id,e)})]}),s.jsxs("div",{className:"oc-card-actions flex flex-wrap gap-2 mt-auto pt-2",children:[T?s.jsx(d,{title:_("扣费续期并恢复"),content:_("恢复实例将立即扣费续期 30 天,确定继续?"),onConfirm:()=>f?.(l),children:s.jsx(c,{icon:s.jsx(x,{}),type:"primary",theme:"solid",size:"small",loading:w===l.id,style:{background:"linear-gradient(135deg, #10b981 0%, #34d399 100%)",border:"none"},children:_("立即恢复")})}):s.jsx(c,{icon:s.jsx(u,{}),type:"primary",theme:"solid",size:"small",disabled:!S,loading:k===l.id,onClick:()=>i?.(l),children:_("打开")}),s.jsx(c,{icon:s.jsx(p,{}),size:"small",type:"tertiary",disabled:!S||T,onClick:()=>t?.(l),"aria-label":_("编辑"),children:s.jsx("span",{className:"oc-card-btn-label",children:_("编辑")})}),s.jsx(c,{icon:s.jsx(g,{}),size:"small",type:"tertiary",disabled:T,onClick:()=>r?.(l),"aria-label":_("凭证"),children:s.jsx("span",{className:"oc-card-btn-label",children:_("凭证")})}),s.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[!T&&!C&&(l.slot_id??0)>0&&D>=2&&s.jsxs(c,{size:"small",type:"warning",theme:"borderless",onClick:()=>b?.(l),"aria-label":_("申请退款"),children:[s.jsx("span",{className:"oc-card-btn-label",children:_("申请退款")}),s.jsx("span",{className:"oc-card-btn-label-mobile","aria-hidden":"true",children:"¥"})]}),s.jsx(d,{title:_("确认删除"),content:_(T?"挂起中的实例删除后,已扣费用不退还且数据立即清除,确认?":"如需退款请用「申请退款」按钮;直接删除不退已扣费用。删除后数据不可恢复,当前槽位保留至到期日(期间可免费重建)。"),onConfirm:()=>y?.(l),okText:_("删除"),cancelText:_("取消"),okButtonProps:{type:"danger"},children:s.jsx(c,{icon:s.jsx(h,{}),type:"danger",theme:"borderless",size:"small","aria-label":_("删除")})})]})]})]}),O&&s.jsxs("div",{style:{position:"absolute",inset:0,background:"rgba(255, 255, 255, 0.82)",backdropFilter:"blur(3px)",borderRadius:14,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,zIndex:5},children:[s.jsx(o,{size:"middle"}),s.jsx(ce,{strong:!0,children:_("配置已下发,gateway 重启中")}),s.jsx(ce,{type:"tertiary",size:"small",children:_("约 {{seconds}} 秒后可重新打开",{seconds:A})})]})]});var q}pe.STATUS_MAP=xe;const{Text:ge}=i;
1function he({region:l,selected:i,onClick:a}){const{t}=B(),{id:r,code:o,name:d,description:c,instance_count:m,capacity_hint:x,available:u}=l,p=e.useMemo(()=>!x||x<=0?null:Math.min(100,Math.round(m/x*100)),[m,x]),g=!u;return s.jsxs("button",{type:"button",disabled:g,onClick:()=>!g&&a(r),style:{position:"relative",textAlign:"left",padding:"12px 14px",borderRadius:12,background:i?"linear-gradient(135deg, rgba(59,130,246,0.08) 0%, rgba(139,92,246,0.08) 100%)":"var(--semi-color-bg-1)",border:i?"2px solid #3b82f6":"2px solid var(--semi-color-border)",cursor:g?"not-allowed":"pointer",opacity:g?.55:1,transition:"all 0.18s ease",boxShadow:i?"0 4px 14px rgba(59,130,246,0.18)":"none",minHeight:92,display:"flex",flexDirection:"column",gap:6,flex:"1 1 200px",maxWidth:280,outline:"none",font:"inherit",color:"inherit"},className:"oc-region-card",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($,{size:14,style:{color:i?"#3b82f6":"var(--semi-color-text-2)",flexShrink:0}}),s.jsx(ge,{strong:!0,style:{fontSize:14,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d}),i&&s.jsx(n,{size:"small",color:"blue",shape:"circle",children:t("已选")}),g&&s.jsx(n,{size:"small",color:"grey",children:t("已满")})]}),s.jsxs("div",{className:"flex items-center gap-2",style:{fontSize:11,color:"var(--semi-color-text-2)"},children:[s.jsx("code",{style:{background:"var(--semi-color-fill-0)",padding:"1px 6px",borderRadius:4,fontSize:11},children:o}),c&&s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:c})]}),null!==p?s.jsxs("div",{style:{marginTop:"auto"},children:[s.jsxs("div",{className:"flex items-center justify-between",style:{fontSize:11,color:"var(--semi-color-text-2)"},children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(E,{size:10}),t("负载")]}),s.jsxs("span",{children:[m," / ",x]})]}),s.jsx("div",{style:{height:4,background:"var(--semi-color-fill-0)",borderRadius:2,overflow:"hidden",marginTop:3},children:s.jsx("div",{style:{width:`${p}%`,height:"100%",background:p>80?"linear-gradient(90deg, #f97316, #ef4444)":"linear-gradient(90deg, #3b82f6, #8b5cf6)",transition:"width 0.3s ease"}})})]}):s.jsx("div",{style:{marginTop:"auto",fontSize:11,color:"var(--semi-color-text-2)"},children:t("已部署 {{count}} 个实例",{count:m})})]})}function ye({regions:e,value:l,onChange:i,loading:r}){const{t:d}=B(),c=Array.isArray(e)&&e.length>0,m=!r&&!c;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[s.jsx(ge,{strong:!0,style:{fontSize:14},children:d("选择机房")}),s.jsx(a,{content:s.jsxs("div",{style:{maxWidth:240,lineHeight:1.6},children:[d("选择实例部署的物理机房。"),s.jsx("br",{}),d("不同机房之间网络隔离、数据不互通;选定后无法迁移。"),s.jsx("br",{}),d("选择「自动」时,系统按优先级和负载自动挑选可用机房。")]}),children:s.jsx(t,{style:{color:"var(--semi-color-text-2)",cursor:"help"}})})]}),r?s.jsx("div",{style:{padding:"24px 0",display:"flex",justifyContent:"center"},children:s.jsx(o,{})}):m?s.jsxs("div",{style:{padding:16,borderRadius:8,background:"rgba(239,68,68,0.06)",border:"1px dashed rgba(239,68,68,0.3)",fontSize:13,color:"var(--semi-color-text-1)",display:"flex",alignItems:"center",gap:8},children:[s.jsx(y,{style:{color:"#ef4444"}}),d("当前没有可用机房,请联系管理员。")]}):s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>i(null),style:{textAlign:"left",padding:"12px 14px",borderRadius:12,background:null===l?"linear-gradient(135deg, rgba(16,185,129,0.08) 0%, rgba(59,130,246,0.08) 100%)":"var(--semi-color-bg-1)",border:null===l?"2px solid #10b981":"2px solid var(--semi-color-border)",cursor:"pointer",transition:"all 0.18s ease",boxShadow:null===l?"0 4px 14px rgba(16,185,129,0.18)":"none",minHeight:92,display:"flex",flexDirection:"column",gap:6,flex:"1 1 200px",maxWidth:280,outline:"none",font:"inherit",color:"inherit"},className:"oc-region-card",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{size:14,style:{color:null===l?"#10b981":"var(--semi-color-text-2)",flexShrink:0}}),s.jsx(ge,{strong:!0,style:{fontSize:14,flex:1},children:d("自动选择")}),null===l&&s.jsx(n,{size:"small",color:"green",shape:"circle",children:d("推荐")})]}),s.jsx(ge,{type:"tertiary",size:"small",style:{marginTop:"auto"},children:d("按优先级与当前负载自动分配")})]}),e.map(e=>s.jsx(he,{region:e,selected:l===e.id,onClick:i},e.id))]})]})}const{Text:fe}=i;function je(e){if(!e)return"-";const s=new Date(e);return Number.isNaN(s.getTime())||s.getTime()<=0?"-":s.toISOString().slice(0,10)}function be({slots:e,instances:i,expanded:a,onToggleExpand:t,onToggleAutoRenew:r,onRefund:o}){const{t:d}=B(),c=Array.isArray(e)?e:[],m=l.useMemo(()=>{const e={};
1return Array.isArray(i)&&i.forEach(s=>{e[s.id]=s}),e},[i]);return s.jsxs("div",{style:{marginBottom:12,borderRadius:12,border:"1px solid var(--semi-color-border)",background:"var(--semi-color-bg-1)",overflow:"hidden"},children:[s.jsxs("div",{onClick:t,role:"button",tabIndex:0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",cursor:"pointer",userSelect:"none",background:"var(--semi-color-fill-0)"},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(V,{size:14,style:{color:"var(--semi-color-primary)"}}),s.jsx(fe,{strong:!0,style:{fontSize:14},children:d("我的槽位")}),s.jsx(n,{size:"small",color:"blue",children:c.length}),s.jsx(fe,{type:"tertiary",size:"small",children:d("槽位是包月计费容器,同规格实例可复用免扣费")})]}),a?s.jsx(f,{}):s.jsx(j,{})]}),s.jsx(b,{isOpen:a,keepDOM:!1,children:s.jsx("div",{style:{padding:"12px 16px"},children:0===c.length?s.jsx(v,{description:d("暂无槽位(创建第一个 OpenClaw 实例后会自动生成)"),style:{padding:16}}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:c.map(e=>s.jsx(ve,{slot:e,instance:e.instance_id?m[e.instance_id]:null,onToggleAutoRenew:r,onRefund:o},e.id))})})})]})}function ve({slot:e,instance:l,onToggleAutoRenew:i,onRefund:t}){const{t:r}=B(),o="number"==typeof e.days_remaining?e.days_remaining:-1,d=!!e.bound,x=!!e.auto_renew,u=l?l.name:null,p=d&&l&&"suspended"===l.billing_status,g=0===o&&!x,h=o>0&&o<=3,y=d&&l&&"creating"===l.status,f=o>=2&&!p&&!y;return s.jsxs("div",{className:"oc-slot-row",style:{padding:"10px 12px",borderRadius:8,border:"1px solid var(--semi-color-border)",background:"var(--semi-color-bg-2)",display:"flex",flexDirection:"column",gap:6},children:[s.jsxs("div",{className:"oc-slot-row-top flex items-center justify-between gap-2 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-3",style:{color:"var(--semi-color-text-1)"},children:[s.jsxs("span",{className:"flex items-center gap-1",style:{fontSize:13},children:[s.jsx(K,{size:12})," ",e.cpu_cores,"C"]}),s.jsxs("span",{className:"flex items-center gap-1",style:{fontSize:13},children:[s.jsx(W,{size:12})," ",e.memory_gb,"G"]}),s.jsxs("span",{className:"flex items-center gap-1",style:{fontSize:13},children:[s.jsx(U,{size:12})," ",e.disk_gb,"G"]})]}),s.jsxs("div",{className:"flex items-center gap-1 min-w-0",children:[p?s.jsx(n,{size:"small",color:"orange",children:r("实例已挂起")}):g?s.jsx(n,{size:"small",color:"red",children:r("已到期(宽限期)")}):s.jsx(n,{size:"small",color:d?"green":"grey",children:r(d?"使用中":"空闲(可复用)")}),d&&u&&s.jsx(fe,{size:"small",type:"secondary",style:{maxWidth:100,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]}),s.jsxs("div",{className:"oc-slot-row-bottom flex items-center justify-between gap-2 flex-wrap",children:[s.jsx("div",{className:"min-w-0",children:p?s.jsx(fe,{size:"small",style:{color:"#d97706"},children:r("实例已被挂起,在实例卡片点「立即恢复」将扣费续期 30 天")}):g?s.jsx(fe,{size:"small",style:{color:"#dc2626"},children:r("已到期 · 7 天内充值恢复可继续使用,超时数据清除")}):s.jsxs(s.Fragment,{children:[s.jsx(fe,{size:"small",type:"tertiary",children:r("到期:{{date}}",{date:je(e.paid_until)})}),o>0&&s.jsx(fe,{size:"small",style:{marginLeft:8,color:h?"#dc2626":"var(--semi-color-text-2)"},children:r("(剩 {{days}} 天)",{days:o})})]})}),s.jsxs("div",{className:"oc-slot-row-actions flex items-center gap-3 ml-auto",children:[f&&s.jsx(c,{size:"small",type:"warning",theme:"borderless",onClick:()=>t?.(e),children:r("申请退款")}),s.jsx(a,{content:r(p?"实例已挂起,请先在卡片上点「立即恢复」;恢复后可重新调整自动续费策略":0===o&&x?"系统正在为您续费,请稍候(约 1 分钟内生效)":0===o?"槽位已到期,请使用「立即续费」按钮续期":x?"到期且余额够时自动续费 30 天":"到期不续,将挂起 7 天后清除"),children:s.jsxs("span",{className:"flex items-center gap-1 cursor-help",children:[s.jsx(fe,{size:"small",children:r("自动续费")}),s.jsx(m,{size:"small",checked:x,disabled:0===o||p,onChange:s=>i?.(e.id,s)})]})})]})]})]})}const{Text:ke,Title:we}=i;function ze({open:l,slot:i,instance:a,onClose:t,onSubmit:n}){const{t:r}=B(),[o,d]=e.useState(!1),{billingDays:m,displayDays:x,refundUSD:u}=e.useMemo(()=>
1{if(!i?.paid_until)return{billingDays:0,displayDays:0,refundUSD:0};const e=new Date(i.paid_until).getTime()-Date.now();if(e<=0)return{billingDays:0,displayDays:0,refundUSD:0};const s=Math.floor(e/864e5),l=s/30;return{billingDays:s,displayDays:s+1,refundUSD:(i.price_shown??0)*l*.9}},[i]);if(!i)return null;const p=i.price_shown??0,g=!!a;return s.jsx(k,{title:r("退款确认"),visible:l,onCancel:t,width:480,placement:"right",footer:s.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[s.jsx(c,{onClick:t,disabled:o,children:r("取消")}),s.jsx(c,{theme:"solid",type:"warning",loading:o,onClick:async()=>{d(!0);try{await n()}finally{d(!1)}},children:r("确认退款")})]}),children:s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[s.jsx(w,{type:"warning",description:r(g?"退款后实例立即删除,数据无法恢复,槽位不保留":"退款后槽位立即删除,不可恢复(当前为空闲槽位,无实例数据需要清理)"),closeIcon:null}),2===x&&s.jsx(w,{type:"info",description:r("距到期日不足 48 小时,退款金额已按剩余整天数计算(差几小时不计入)"),closeIcon:null}),s.jsxs("div",{style:{background:"var(--semi-color-fill-0)",borderRadius:8,padding:"12px 16px"},children:[s.jsx(we,{heading:6,style:{marginBottom:8},children:g?a.name:r("空闲槽位 #{{id}}",{id:i.id})}),s.jsxs("div",{style:{display:"flex",gap:16,flexWrap:"wrap"},children:[s.jsxs(ke,{type:"tertiary",style:{display:"flex",alignItems:"center",gap:4},children:[s.jsx(K,{size:14}),i.cpu_cores??"-","C"]}),s.jsxs(ke,{type:"tertiary",style:{display:"flex",alignItems:"center",gap:4},children:[s.jsx(W,{size:14}),i.memory_gb??"-","G"]}),s.jsxs(ke,{type:"tertiary",style:{display:"flex",alignItems:"center",gap:4},children:[s.jsx(U,{size:14}),i.disk_gb??"-","G"]})]})]}),s.jsxs("div",{style:{background:"var(--semi-color-fill-0)",borderRadius:8,padding:"12px 16px"},children:[s.jsx(z,{align:"left",size:"small",data:[{key:r("原扣金额"),value:s.jsxs(ke,{children:[s.jsx(V,{size:13,style:{verticalAlign:"middle",marginRight:4}}),p.toFixed(2)," ",r("额度")]})},{key:r("算账天数 / 30"),value:s.jsxs("div",{children:[s.jsxs(ke,{children:[m," / ",30]}),x!==m&&s.jsx(ke,{type:"quaternary",size:"small",style:{display:"block",marginTop:2},children:r("卡片显示剩余 {{n}} 天,与算账天数差 1 天属正常",{n:x})})]})},{key:r("手续费"),value:s.jsx(ke,{children:"10%"})},{key:r("应退金额(预估)"),value:s.jsxs(ke,{strong:!0,style:{color:"var(--semi-color-warning)"},children:[u.toFixed(2)," ",r("额度")]})}]}),s.jsx(ke,{type:"quaternary",size:"small",style:{display:"block",marginTop:8},children:r("实际到账金额以退款完成后的系统提示为准")})]})]})})}const{Text:_e,Title:Ne}=i,Se={key:"medium",cpu:4,mem:8,disk:20};function Ce(){const{t:l}=B(),[i,a]=e.useState([]),[t,r]=e.useState(!1),[d,m]=e.useState(!1),[u,p]=e.useState(!1),[g,h]=e.useState([]),[y,f]=e.useState([]),[j,b]=e.useState([]),[z,G]=e.useState({visible:!1,token:"",modelNames:[],defaultModel:""}),[P,$]=e.useState(null),[K,W]=e.useState(Se),[U,V]=e.useState(null),[E,Q]=e.useState(!0),[X,Z]=e.useState([]),[ee,se]=e.useState([]),[ie,re]=e.useState(!1),oe=e.useRef(null),de=F(),[ce,me]=e.useState(null),[xe,ue]=e.useState(!1),[ge,he]=e.useState([]),fe=e.useRef(null),[je,ve]=e.useState([]),[ke,we]=e.useState([]),[Ce,Te]=e.useState({}),[Re,De]=e.useState(null),[Ie,Ae]=e.useState(!1),[Be,Me]=e.useState(null),[Oe,Le]=e.useState(!1),qe=e.useCallback(e=>{Te(s=>({...s,[e]:Date.now()+8e3})),setTimeout(()=>{Te(s=>{if(!s[e])return s;const{[e]:l,...i}=s;return i})},8500)},[]),Fe=e.useCallback(async()=>{r(!0);try{const e=await M.get("/api/openclaw/instances");e?.data?.success&&a(e.data.data||[])}catch{_.error(l("加载实例列表失败"))}finally{r(!1)}},[l]),Ge=e.useCallback(async()=>{try{const e=await M.get("/api/openclaw/quota_slots");e?.data?.success&&Z(e.data.data||[])}catch{}},[]),Pe=e.useCallback(async()=>{try{const e=await M.get("/api/token/?p=0&size=100");e?.data?.success&&h((e.data.data?.items||e.data.data||[]).filter(e=>1===e.status))}catch{}},[]),$e=e.useCallback(async()=>{try{const e=await M.get("/api/user/models");if(e?.data?.success){const s=(e.data.data||[]).filter(e=>"string"==typeof e&&e);f(s),b(s),he(s)}}catch{}},[]),Ke=e.useCallback(async()=>{re(!0);try{const e=await M.get("/api/openclaw/regions");se(e?.data?.success&&e.data.data||[])}catch{se([])}finally{re(!1)}},[]),We=e.useCallback(e=>{const s=g.find(s=>
1s.id===e);if(s&&s.model_limits_enabled&&s.model_limits){const e=O(s.model_limits);return y.filter(s=>e.includes(s))}return y},[g,y]),Ue=e.useCallback(e=>{oe.current&&(oe.current.setValue("model_names",[]),oe.current.setValue("default_model",void 0)),ve([]),b(We(e))},[We]),He=e.useCallback(e=>{if(fe.current){const s=We(e),l=(fe.current.getValue("model_names")||[]).filter(e=>s.includes(e));fe.current.setValue("model_names",l),we(l);const i=fe.current.getValue("default_model");i&&!l.includes(i)&&fe.current.setValue("default_model",l[0]),he(s)}},[We]),Ve=e.useCallback((e,s)=>{const l=(e||[]).slice(0,5),{formApi:i,setSelected:a}=s;if(l.length!==(e||[]).length&&i&&i.setValue("model_names",l),a(l),i){const e=i.getValue("default_model");e&&l.includes(e)||i.setValue("default_model",l[0]||void 0)}},[]);e.useEffect(()=>{Fe(),Pe(),$e(),Ke(),Ge()},[Fe,Pe,$e,Ke,Ge]),e.useEffect(()=>{if(!i.some(e=>"creating"===e.status))return;const e=setInterval(Fe,1e4);return()=>clearInterval(e)},[i,Fe]);const Ee=X.find(e=>!e.bound&&Number(e.cpu_cores)===Number(K.cpu)&&Number(e.memory_gb)===Number(K.mem)&&Number(e.disk_gb)===Number(K.disk)),Ye=te(K.cpu,K.mem,K.disk),Je=Number(Ye.toFixed(2)),Qe=async e=>{De(e.id);try{const s=await M.post(`/api/openclaw/instance/${e.id}/resume`);s?.data?.success?(_.success(l("实例恢复中,请稍候")),Fe(),Ge()):_.error(s?.data?.message||l("恢复失败"))}catch(s){const e=s?.response?.status,i=s?.response?.data?.message;402===e?_.error(i||l("余额不足,请充值后再恢复")):i?_.error(i):_.error(l("恢复失败,请重试"))}finally{De(null)}},Xe=async e=>{try{const s=await M.post(`/api/openclaw/instance/${e.id}/renew`);s?.data?.success?(_.success(s.data.message||l("续费成功")),Fe(),Ge()):_.error(s?.data?.message||l("续费失败"))}catch(s){const e=s?.response?.status,i=s?.response?.data?.message;402===e?_.error(i||l("余额不足,请充值后重试")):i?_.error(i):_.error(l("请求失败,请重试"))}},Ze=async(e,s)=>{try{const i=await M.patch(`/api/openclaw/quota_slots/${e}`,{auto_renew:s});i?.data?.success?(_.success(l(s?"已开启自动续费":"已关闭自动续费")),Ge(),Fe()):_.error(i?.data?.message||l("更新失败"))}catch{_.error(l("请求失败,请重试"))}},es=async e=>{$(e.id);try{const s=await M.get(`/api/openclaw/instance/${e.id}/open`);s?.data?.success?window.open(s.data.data.url,"_blank"):_.error(s?.data?.message||l("获取访问链接失败"))}catch{_.error(l("获取访问链接失败,请稍后重试"))}finally{$(null)}},ss=async e=>{try{const s=await M.get(`/api/openclaw/instance/${e.id}/credentials`);s?.data?.success&&G({visible:!0,token:s.data.data.gateway_token,modelNames:s.data.data.model_names||[],defaultModel:s.data.data.default_model||""})}catch{_.error(l("获取凭证失败"))}},ls=async e=>{try{const s=await M.delete(`/api/openclaw/instance/${e.id}`);s?.data?.success?(_.success(l("实例已删除")),Fe()):_.error(s?.data?.message||l("删除失败"))}catch{_.error(l("删除失败,请重试"))}},is=e=>{if(!e?.slot_id)return void _.error(l("该实例无关联槽位,无法退款"));const s=X.find(s=>s.id===e.slot_id);if(!s)return _.error(l("槽位信息加载中,请稍后再试")),void Ge();Me(s)},as=e=>{const s=We(e.token_id);he(s),we(e.model_names||[]),me(e)},ts=()=>{me(null),ue(!1),we([])},ns=i.length,rs=s.jsx("div",{className:"oc-hero mb-3",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 sm:gap-4 flex-wrap sm:flex-nowrap",children:[s.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 min-w-0 flex-1",children:[s.jsx("div",{className:"oc-hero-icon",children:s.jsx(L,{})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Ne,{heading:5,className:"oc-hero-title",style:{margin:0},children:l("OpenClaw 一键部署")}),s.jsx(n,{size:"small",color:"red",style:{background:"linear-gradient(90deg, #ff4d4d 0%, #f97316 100%)",border:"none",color:"#fff"},children:l("AI 编程助手")})]}),s.jsx(_e,{type:"tertiary",size:"small",className:"oc-hero-desc",style:{display:"block",marginTop:4},children:l("部署专属 OpenClaw 实例,使用您的 API 令牌,开箱即用,无需额外配置")})]})]}),s.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-shrink-0",children:[s.jsx(c,{className:"oc-guide-trigger",icon:s.jsx(H,{size:14}),theme:"solid",type:"primary",size:"small",onClick:()=>Le(!0),style:{background:"linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%)",border:"none",boxShadow:"0 4px 12px rgba(139, 92, 246, 0.35)"},children:s.jsx("span",{className:"oc-guide-trigger-label",children:l("使用指引")})}
1),s.jsxs("div",{className:"text-right oc-hero-counter",children:[s.jsx(_e,{type:"tertiary",size:"small",style:{display:"block"},children:l("已部署实例")}),s.jsx(_e,{strong:!0,className:"oc-hero-counter-num",style:{display:"block"},children:ns})]})]})]})}),os=s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(c,{icon:s.jsx(x,{}),type:"tertiary",size:"small",onClick:Fe,loading:t,children:l("刷新")}),s.jsx(c,{icon:s.jsx(Y,{size:14}),type:"primary",theme:"solid",size:"small",onClick:()=>{b(y),W(Se),ve([]),V(null),Q(!0),Ke(),Ge(),p(!0)},style:{background:"linear-gradient(135deg, #ff4d4d 0%, #f97316 100%)",border:"none",boxShadow:"0 4px 12px rgba(255, 77, 77, 0.35)"},children:l("新建实例")})]}),ds=s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3 p-1",children:i.map(e=>s.jsx(pe,{instance:e,onOpen:es,onEdit:as,onCredentials:ss,onDelete:ls,onRefund:is,onResume:Qe,onRenew:Xe,onToggleAutoRenew:Ze,openingId:P,resumingId:Re,loadingMaskMs:Ce[e.id]?Math.max(0,Ce[e.id]-Date.now()):0},e.id))});return s.jsxs("div",{className:"px-3 sm:px-2",children:[rs,s.jsx(be,{slots:X,instances:i,expanded:Ie,onToggleExpand:()=>Ae(e=>!e),onToggleAutoRenew:Ze,onRefund:e=>{e?.id&&Me(e)}}),s.jsx(q,{type:"type1",shadows:"always",bordered:!1,actionsArea:os,children:t&&0===i.length?s.jsx("div",{className:"flex justify-center py-10",children:s.jsx(o,{size:"large"})}):0===i.length?s.jsx(v,{image:s.jsx(S,{style:{width:150,height:150}}),darkModeImage:s.jsx(N,{style:{width:150,height:150}}),description:l("暂无 OpenClaw 实例,点击「新建实例」一键部署"),style:{padding:30}}):ds}),s.jsxs(k,{placement:de?"bottom":"right",title:s.jsxs(D,{children:[s.jsx(n,{color:"blue",shape:"circle",children:l("新建")}),s.jsx(Ne,{heading:4,className:"m-0",children:l("新建 OpenClaw 实例")})]}),visible:u,onCancel:()=>{p(!1),b(y)},width:de?"100%":640,height:de?"90vh":void 0,bodyStyle:{padding:"24px",overflowY:"auto"},maskStyle:{touchAction:"none",overscrollBehavior:"none"},headerStyle:{borderBottom:"1px solid var(--semi-color-border)"},footer:s.jsxs("div",{className:"flex justify-end gap-3 bg-white py-2",children:[s.jsx(c,{onClick:()=>{p(!1),b(y)},children:l("取消")}),s.jsx(c,{icon:s.jsx(R,{}),type:"primary",theme:"solid",loading:d,disabled:0===ee.length,onClick:()=>oe.current?.submitForm(),children:Ee?l("复用槽位创建(免费)"):l("扣 {{quota}} 额度创建",{quota:Je})})]}),children:[s.jsx(w,{type:"info",description:l("部署完成后,OpenClaw 将自动配置您选择的令牌和模型,直接进入即可使用 AI 编程助手,无需额外设置。"),closeIcon:null,style:{marginBottom:16,borderRadius:8}}),s.jsx(w,{type:Ee?"success":"warning",icon:null,description:Ee?l("检测到您有同规格的空闲槽位(剩余 {{days}} 天),本次创建将复用,不再扣费。",{days:Ee.days_remaining}):l("当前规格暂无空闲槽位。新建将扣除 {{quota}} 额度购买 1 个月使用权。删除不退费;如需退款请在实例卡片点「申请退款」(按剩余天数比例退、扣 10% 手续费)。",{quota:Je}),closeIcon:null,style:{marginBottom:24,borderRadius:8}}),s.jsxs(C,{onSubmit:async e=>{m(!0);try{const s=await M.post("/api/openclaw/instance",{name:e.name,token_id:e.token_id,model_names:e.model_names,default_model:e.default_model,cpu_cores:K.cpu,memory_gb:K.mem,disk_gb:K.disk,...U?{region_id:U}:{}});if(s?.data?.success){_.success(l("实例创建中,通常需要 1-3 分钟完成部署"));const e=s.data.data?.slot_id;if(!E&&e)try{await M.patch(`/api/openclaw/quota_slots/${e}`,{auto_renew:!1})}catch{_.warning(l("实例已创建但关闭自动续费失败,可在「我的槽位」中手动关闭"))}p(!1),Fe(),Ge()}else _.error(s?.data?.message||l("创建失败"))}catch(s){const e=s?.response?.status,i=s?.response?.data?.message;402===e?_.error(i||l("余额不足,请充值后重试")):i?_.error(i):_.error(l("请求失败,请重试"))}finally{m(!1)}},autoComplete:"off",getFormApi:e=>{oe.current=e},labelPosition:"top",children:[s.jsx("div",{style:{marginBottom:16},children:s.jsx(ye,{regions:ee,value:U,onChange:V,loading:ie})}),s.jsx(C.Input,{field:"name",label:l("实例名称"),placeholder:l("例如:my-openclaw"),size:"large",rules:[{required:!0,message:l("请输入实例名称")},{min:3,message:l("名称至少 3 个字符")},{max:50,message:l("名称最多 50 个字符")},{pattern:/^[a-z0-9-]+$/,message:l("只允许小写字母、数字和横杠")}]}),s.jsx(C.Select,{field:"token_id",label:l("使用的令牌"),placeholder:l("选择 API 令牌"),style:{width:"100%"},size:"large",rules:[{required:!0,message:l("请选择令牌")}],onChange:Ue,optionList:g.map(e=>({value:e.id,label:`${e.name}(${e.key?e.key.slice(0,8)+"…":""})`}))}),s.jsx(C.Select,{field:"model_names",label:s.jsxs(s.Fragment,{children:[l("可用模型")," ",s.jsx(_e,{type:"tertiary",size:"small",children:l("(最多 {{max}} 个,运行时可在 OpenClaw 用 /model 切换)",{max:5})})]}),placeholder:l("最多选择 {{max}} 个模型",{max:5}),style:{width:"100%"},size:"large",multiple:!0,filter:!0,maxTagCount:5,rules:[{required:!0,type:"array",min:1,message:l("至少选择一个模型")},{validator:(e,s)=>!s||s.length<=5,message:l("最多 {{max}} 个",{max:5})}],optionList:j.map(e=>({value:e,label:e})),onChange:e=>Ve(e,{formApi:oe.current,setSelected:ve})}),s.jsx(C.Select,{field:"default_model",label:s.jsxs(s.Fragment,{children:[l("默认模型")," ",s.jsx(_e,{type:"tertiary",size:"small",children:l("(OpenClaw 启动时的 primary)")})]}),placeholder:l("从已选模型中指定一个"),style:{width:"100%"},size:"large",rules:[{required:!0,message:l("请选择默认模型")}],disabled:0===je.length,optionList:je.map(e=>({value:e,label:e}))}),s.jsxs("div",{style:{marginTop:16},children:[s.jsxs(_e,{strong:!0,style:{display:"block",marginBottom:8},children:[l("规格")," ",s.jsx(_e,{type:"tertiary",size:"small",children:l("(创建后不可修改)")})]}),s.jsx(ne,{value:K,onChange:W})]}),s.jsxs("div",{style:{marginTop:16},children:[s.jsx(T,{checked:E,onChange:e=>Q(e.target.checked),children:l("到期自动续费")}),s.jsx(_e,{type:"tertiary",size:"small",style:{display:"block",marginTop:4},children:l("开启后,到期且余额充足时自动扣费续 30 å
1¤©ï¼›å…³é—­åŽåˆ°æœŸå°†è‡ªåŠ¨æŒ‚èµ· 7 天,超时数据清除。")})]})]})]}),s.jsx(k,{placement:de?"bottom":"right",title:s.jsxs(D,{children:[s.jsx(n,{color:"violet",shape:"circle",children:l("编辑")}),s.jsx(Ne,{heading:4,className:"m-0",children:l("编辑 {{name}}",{name:ce?.name})})]}),visible:!!ce,onCancel:ts,width:de?"100%":640,height:de?"90vh":void 0,bodyStyle:{padding:"24px",overflowY:"auto"},maskStyle:{touchAction:"none",overscrollBehavior:"none"},headerStyle:{borderBottom:"1px solid var(--semi-color-border)"},footer:s.jsxs("div",{className:"flex justify-end gap-3 bg-white py-2",children:[s.jsx(c,{onClick:ts,children:l("取消")}),s.jsx(c,{icon:s.jsx(R,{}),type:"primary",theme:"solid",loading:xe,onClick:()=>fe.current?.submitForm(),children:l("保存(gateway 将重启 ~6 秒)")})]}),children:ce&&s.jsxs(s.Fragment,{children:[s.jsx(w,{type:"warning",description:l("保存后,OpenClaw gateway 将自动重启以加载新配置(约 6-7 秒)。重启期间该实例无法访问,但其他实例不受影响。"),closeIcon:null,style:{marginBottom:20,borderRadius:8}}),s.jsxs(C,{onSubmit:async e=>{if(ce){ue(!0);try{const s={};e.token_id!==ce.token_id&&(s.token_id=e.token_id);const i=(ce.model_names||[]).slice().sort(),a=(e.model_names||[]).slice().sort();if((i.length!==a.length||i.some((e,s)=>e!==a[s]))&&(s.model_names=e.model_names),e.default_model!==ce.default_model&&(s.default_model=e.default_model),0===Object.keys(s).length)return _.info(l("没有变更")),void ts();const t=await M.put(`/api/openclaw/instance/${ce.id}`,s);t?.data?.success?(_.success(l("配置已下发,gateway 重启中(约 6-7 秒)")),qe(ce.id),ts(),Fe()):_.error(t?.data?.message||l("更新失败"))}catch(s){const e=s?.response?.data?.message||l("请求失败,请重试");_.error(e)}finally{ue(!1)}}},autoComplete:"off",initValues:{token_id:ce.token_id,model_names:ce.model_names||[],default_model:ce.default_model||""},getFormApi:e=>{fe.current=e},labelPosition:"top",children:[s.jsx(C.Select,{field:"token_id",label:l("使用的令牌"),style:{width:"100%"},size:"large",rules:[{required:!0,message:l("请选择令牌")}],onChange:He,optionList:g.map(e=>({value:e.id,label:`${e.name}(${e.key?e.key.slice(0,8)+"…":""})`}))}),s.jsx(C.Select,{field:"model_names",label:s.jsxs(s.Fragment,{children:[l("可用模型")," ",s.jsx(_e,{type:"tertiary",size:"small",children:l("(最多 {{max}} 个)",{max:5})})]}),style:{width:"100%"},size:"large",multiple:!0,filter:!0,maxTagCount:5,rules:[{required:!0,type:"array",min:1,message:l("至少选择一个模型")},{validator:(e,s)=>!s||s.length<=5,message:l("最多 {{max}} 个",{max:5})}],optionList:ge.map(e=>({value:e,label:e})),onChange:e=>Ve(e,{formApi:fe.current,setSelected:we})}),s.jsx(C.Select,{field:"default_model",label:l("默认模型"),style:{width:"100%"},size:"large",rules:[{required:!0,message:l("请选择默认模型")}],disabled:0===ke.length,optionList:ke.map(e=>({value:e,label:e}))}),s.jsxs("div",{style:{marginTop:16},children:[s.jsxs(_e,{strong:!0,style:{display:"block",marginBottom:8},children:[l("规格")," ",s.jsx(_e,{type:"tertiary",size:"small",children:l("(K8s 不支持热扩缩容,规格只读)")})]}),s.jsx(ne,{readOnly:!0,value:{key:ae(ce.cpu_cores,ce.memory_gb,ce.disk_gb),cpu:ce.cpu_cores||le.cpu.min,mem:ce.memory_gb||le.mem.min,disk:ce.disk_gb||le.disk.min},showPriceHint:!1})]})]})]})}),s.jsx(k,{placement:de?"bottom":"right",title:s.jsxs(D,{children:[s.jsx(n,{color:"amber",shape:"circle",children:l("凭证")}),s.jsx(Ne,{heading:4,className:"m-0",children:l("访问凭证")})]}),visible:z.visible,onCancel:()=>G({...z,visible:!1}),width:de?"100%":480,height:de?"80vh":void 0,bodyStyle:{padding:"24px",overflowY:"auto"},headerStyle:{borderBottom:"1px solid var(--semi-color-border)"},footer:s.jsx("div",{className:"flex justify-end py-2",children:s.jsx(c,{onClick:()=>G({...z,visible:!1}),children:l("关闭")})}),children:s.jsxs("div",{className:"space-y-5",children:[s.jsx(w,{type:"warning",title:l("首次使用说明"),description:l("进入 OpenClaw 后,点击右上角 Settings → 将下方 Gateway Token 粘贴到「Shared Secret」输入框,点击保存。之后浏览器会记住,无需重复操作。"),closeIcon:null,style:{borderRadius:8}}),s.jsxs("div",{children:[s.jsx(_e,{strong:!0,style:{display:"block",marginBottom:8},children:l("Gateway Token")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(I,{value:z.token,readOnly:!0,size:"large",style:{fontFamily:"monospace",flex:1}}),s.jsx(c,{icon:s.jsx(A,{}),size:"large",onClick:()=>{return e=z.token,void navigator.clipboard.writeText(e).then(()=>{_.success(l("已复制到剪贴板"))});var e},children:l("复制")})]})]}),s.jsxs("div",{children:[s.jsx(_e,{type:"tertiary",style:{fontSize:13,display:"block",marginBottom:6},children:l("已配置模型(在 OpenClaw 聊天框输入 /models 查看,/model <别名> 切换)")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:(z.modelNames||[]).map(e=>s.jsxs(n,{size:"small",color:e===z.defaultModel?"blue":"grey",children:[e===z.defaultModel?"★ ":"",e]},e))})]})]})}
1),s.jsx(ze,{open:!!Be,slot:Be,instance:Be?.instance_id?i.find(e=>e.id===Be.instance_id)??null:null,onClose:()=>Me(null),onSubmit:async()=>{if(!Be?.id)return;let e;try{e=await M.post(`/api/openclaw/quota_slots/${Be.id}/refund`)}catch{return}if(e?.data?.success){const s=e.data.data??{},i="number"==typeof s.refund_usd?s.refund_usd.toFixed(2):"-";_.success(l("退款成功,已退 {{quota}} 额度到您的账户",{quota:i})),Me(null),Fe(),Ge()}else _.error(e?.data?.message||l("退款失败,请重试"))}}),s.jsx(J,{visible:Oe,onClose:()=>Le(!1)})]})}export{Ce as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.