mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 00:53:33 +00:00
31 lines
236 KiB
JavaScript
31 lines
236 KiB
JavaScript
import{E as zs}from"./element-plus-CqiD73Lu.js";import{aP as ds,r as D,c as R,q as st,V as Fs,o as De,x as d,y as i,z as e,I as ye,C as z,P as u,R as le,J as Bs,L as h,B as pt,K as _,aq as ee,Q as te,ac as oe,T as Ws,a5 as Ue,D as Ns,_ as ze,Y as Ce,an as ne,O as A,aa as et,aV as tt,al as Te,f as Xe,u as Ze}from"./vue-vendor-Bsazo-x0.js";import{c as q,_ as _e,s as O,u as Hs}from"./index-DWQijCSH.js";import{Q as Oe}from"./vendor-Dr8jvgFu.js";import{_ as Ys}from"./WindowCountdown-BTXjZ8Dc.js";import{C as It}from"./CustomDropdown-BPr5U0mb.js";const Lt=ds("clients",{state:()=>({supportedClients:[],loading:!1,error:null}),actions:{async loadSupportedClients(){if(this.supportedClients.length>0)return this.supportedClients;this.loading=!0,this.error=null;try{const v=await q.get("/admin/supported-clients");return v.success?this.supportedClients=v.data||[]:(this.error=v.message||"加载支持的客户端失败",console.error("Failed to load supported clients:",this.error)),this.supportedClients}catch(v){return this.error=v.message||"加载支持的客户端失败",console.error("Error loading supported clients:",v),[]}finally{this.loading=!1}}}}),Dt=ds("apiKeys",()=>{const v=D([]),H=D(!1),c=D(null),M=D("all"),N=D(""),$=D("asc"),U=async()=>{H.value=!0,c.value=null;try{const S=await q.get("/admin/api-keys");if(S.success)v.value=S.data||[];else throw new Error(S.message||"获取API Keys失败")}catch(S){throw c.value=S.message,S}finally{H.value=!1}};return{apiKeys:v,loading:H,error:c,statsTimeRange:M,sortBy:N,sortOrder:$,fetchApiKeys:U,createApiKey:async S=>{H.value=!0,c.value=null;try{const W=await q.post("/admin/api-keys",S);if(W.success)return await U(),W.data;throw new Error(W.message||"创建API Key失败")}catch(W){throw c.value=W.message,W}finally{H.value=!1}},updateApiKey:async(S,W)=>{H.value=!0,c.value=null;try{const I=await q.put(`/admin/api-keys/${S}`,W);if(I.success)return await U(),I;throw new Error(I.message||"更新API Key失败")}catch(I){throw c.value=I.message,I}finally{H.value=!1}},toggleApiKey:async S=>{H.value=!0,c.value=null;try{const W=await q.put(`/admin/api-keys/${S}/toggle`);if(W.success)return await U(),W;throw new Error(W.message||"切换状态失败")}catch(W){throw c.value=W.message,W}finally{H.value=!1}},renewApiKey:async(S,W)=>{H.value=!0,c.value=null;try{const I=await q.put(`/admin/api-keys/${S}`,W);if(I.success)return await U(),I;throw new Error(I.message||"续期失败")}catch(I){throw c.value=I.message,I}finally{H.value=!1}},deleteApiKey:async S=>{H.value=!0,c.value=null;try{const W=await q.delete(`/admin/api-keys/${S}`);if(W.success)return await U(),W;throw new Error(W.message||"删除失败")}catch(W){throw c.value=W.message,W}finally{H.value=!1}},fetchApiKeyStats:async(S,W="all")=>{try{const I=await q.get(`/admin/api-keys/${S}/stats`,{params:{timeRange:W}});if(I.success)return I.stats;throw new Error(I.message||"获取统计失败")}catch(I){return console.error("获取API Key统计失败:",I),null}},fetchTags:async()=>{try{const S=await q.get("/admin/api-keys/tags");if(S.success)return S.data||[];throw new Error(S.message||"获取标签失败")}catch(S){return console.error("获取标签失败:",S),[]}},sortApiKeys:S=>{N.value===S?$.value=$.value==="asc"?"desc":"asc":(N.value=S,$.value="asc")},reset:()=>{v.value=[],H.value=!1,c.value=null,M.value="all",N.value="",$.value="asc"}}}),Qs={class:"flex-shrink-0 border-b border-gray-200 p-3 dark:border-gray-600"},Js={class:"relative"},Xs={class:"custom-scrollbar flex-1 overflow-y-auto"},Zs={key:0,class:"border-b border-gray-200 dark:border-gray-600"},ea=["onClick"],ta={class:"text-gray-700 dark:text-gray-300"},sa={key:0,class:"ml-2 text-xs text-gray-400 dark:text-gray-500"},aa={class:"text-gray-700 dark:text-gray-300"},ra={key:1},oa=["onClick"],la={class:"flex items-center justify-between"},ia={class:"text-gray-700 dark:text-gray-300"},na={class:"text-xs text-gray-500 dark:text-gray-400"},da={key:2},ua={class:"bg-gray-50 px-4 py-2 text-xs font-semibold text-gray-500 dark:bg-gray-700 dark:text-gray-400"},ca=["onClick"],ga={class:"flex items-center justify-between"},pa={class:"text-gray-700 dark:text-gray-300"},ma={class:"text-xs text-gray-400 dark:text-gray-500"},xa={key:3},ya=["onClick"],fa={class:"flex items-center justify-between"},ba={class:"text-gray-700 dark:text-gray-300"},va={class:"text-xs text-gray-400 dark:text-gray-500"},ka={key:4},wa=["onClick"],ha={class:"flex items-center justify-between"},Aa={class:"text-gray-700 dark:text-gray-300"},$a={class:"text-xs text-gray-400 dark:text-gray-500"},Ca={key:5},Ia=["onClick"],Ka={class:"flex items-center justify-between"},La={class:"text-gray-700 dark:text-gray-300"},Da={class:"text-xs text-gray-400 dark:text-gray-500"},_a={key:6,class:"px-4 py-8 text-center text-gray-500 dark:text-gray-400"},Sa={__name:"AccountSelector",props:{modelValue:{type:String,default:""},platform:{type:String,required:!0,validator:v=>["claude","gemini","openai","bedrock","droid"].includes(v)},accounts:{type:Array,default:()=>[]},groups:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:"请选择账号"},defaultOptionText:{type:String,default:"使用共享账号池"},specialOptions:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(v,{emit:H}){const c=v,M=H,N=D(!1),$=D(""),U=D(null),B=D(null),T=D({}),J=D(null),Y=D(""),f=R(()=>c.specialOptions||[]),L=R(()=>{const m=f.value.find(g=>g.value===c.modelValue);if(m)return m.label;if(!c.modelValue)return c.defaultOptionText;if(c.modelValue.startsWith("group:")){const g=c.modelValue.substring(6),l=c.groups.find(y=>y.id===g);return l?`${l.name} (${l.memberCount||0} 个成员)`:""}if(c.modelValue.startsWith("console:")){const g=c.modelValue.substring(8),l=c.accounts.find(y=>y.id===g&&y.platform==="claude-console");return l?`${l.name} (${p(l)})`:""}if(c.modelValue.startsWith("responses:")){const g=c.modelValue.substring(10),l=c.accounts.find(y=>y.id===g&&y.platform==="openai-responses");return l?`${l.name} (${p(l)})`:""}if(c.modelValue.startsWith("api:")){const g=c.modelValue.substring(4),l=c.accounts.find(y=>y.id===g&&y.platform==="gemini-api");return l?`${l.name} (${p(l)})`:""}const C=c.accounts.find(g=>g.id===c.modelValue);return C?`${C.name} (${p(C)})`:""}),p=m=>{if(!m)return"未知";if(!(m.isActive==="true"||m.isActive===!0))switch(m.status){case"unauthorized":return"未授权";case"error":return"Token错误";case"created":return"待验证";case"rate_limited":return"限流中";case"quota_exceeded":return"额度超限";default:return"异常"}return m.status==="rate_limited"?"限流中":"正常"},s=R(()=>[...c.accounts].sort((m,C)=>{const g=new Date(m.createdAt||0);return new Date(C.createdAt||0)-g})),V=R(()=>{let m=c.groups.filter(C=>C.platform?C.platform===c.platform:!0);if($.value){const C=$.value.toLowerCase();m=m.filter(g=>g.name.toLowerCase().includes(C))}return m}),S=R(()=>{let m=[];if(c.platform==="claude"?m=s.value.filter(C=>C.platform==="claude-oauth"):c.platform==="openai"?m=s.value.filter(C=>C.platform==="openai"):c.platform==="droid"?m=s.value.filter(C=>C.platform==="droid"):c.platform==="gemini"?m=s.value.filter(C=>C.platform==="gemini"):m=s.value.filter(C=>!["claude-oauth","claude-console","openai-responses","gemini-api"].includes(C.platform)),$.value){const C=$.value.toLowerCase();m=m.filter(g=>g.name.toLowerCase().includes(C))}return m}),W=R(()=>{if(c.platform!=="claude")return[];let m=s.value.filter(C=>C.platform==="claude-console");if($.value){const C=$.value.toLowerCase();m=m.filter(g=>g.name.toLowerCase().includes(C))}return m}),I=R(()=>{if(c.platform!=="openai")return[];let m=s.value.filter(C=>C.platform==="openai-responses");if($.value){const C=$.value.toLowerCase();m=m.filter(g=>g.name.toLowerCase().includes(C))}return m}),K=R(()=>{if(c.platform!=="gemini")return[];let m=s.value.filter(C=>C.platform==="gemini-api");if($.value){const C=$.value.toLowerCase();m=m.filter(g=>g.name.toLowerCase().includes(C))}return m}),se=R(()=>V.value.length>0||S.value.length>0||W.value.length>0||I.value.length>0||K.value.length>0),ie=m=>{if(!m)return"";const C=new Date(m),l=(new Date-C)/(1e3*60*60);return l<24?"今天创建":l<48?"昨天创建":l<168?`${Math.floor(l/24)} 天前`:C.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"})},de=()=>{if(!N.value||!B.value||!J.value)return;const m=J.value;if(!m)return;const C=m.getBoundingClientRect(),g=window.innerHeight,l=window.innerWidth,y=g-C.bottom,ae=C.top,ue=8,ge=y-ue,ve=ae-ue;let fe=!1,F=ge;Y.value==="above"&&ve>=150?(fe=!0,F=ve):Y.value==="below"&&ge>=150?(fe=!1,F=ge):ve>ge&&ge<200&&(fe=!0,F=ve),Y.value=fe?"above":"below";let Q=C.left;const me=C.width;Q+me>l-ue&&(Q=l-me-ue),Q<ue&&(Q=ue),T.value={position:"fixed",left:`${Q}px`,width:`${C.width}px`,maxHeight:`${Math.min(F,400)}px`,...fe?{bottom:`${g-C.top}px`}:{top:`${C.bottom}px`}}},pe=()=>{if(!N.value&&J.value){const m=J.value.getBoundingClientRect(),g=window.innerHeight-m.bottom,l=8;T.value={position:"fixed",left:`${m.left}px`,width:`${m.width}px`,maxHeight:`${Math.min(g-l,400)}px`,top:`${m.bottom}px`}}N.value=!N.value,N.value&&Ns(()=>{var m;de(),(m=U.value)==null||m.focus()})},X=m=>{M("update:modelValue",m||""),N.value=!1,$.value=""},be=()=>{},k=()=>{var m;$.value="",(m=U.value)==null||m.focus()},o=m=>{var C,g;!((C=J.value)!=null&&C.contains(m.target))&&!((g=B.value)!=null&&g.contains(m.target))&&(N.value=!1)},n=()=>{N.value&&de()};return st(()=>{document.addEventListener("click",o),window.addEventListener("scroll",n,!0),window.addEventListener("resize",de)}),Fs(()=>{document.removeEventListener("click",o),window.removeEventListener("scroll",n,!0),window.removeEventListener("resize",de)}),De(N,m=>{m||($.value="",Y.value="")}),(m,C)=>(i(),d("div",{ref_key:"triggerRef",ref:J,class:"relative"},[e("div",{class:z(["form-input flex w-full cursor-pointer items-center justify-between border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",{"opacity-50":v.disabled}]),onClick:C[0]||(C[0]=g=>!v.disabled&&pe())},[e("span",{class:z(v.modelValue?"text-gray-900 dark:text-gray-200":"text-gray-500 dark:text-gray-400")},u(L.value),3),e("i",{class:z(["fas fa-chevron-down text-gray-400 transition-transform duration-200 dark:text-gray-500",{"rotate-180":N.value}])},null,2)],2),(i(),ye(Ue,{to:"body"},[le(Ws,{"enter-active-class":"transition ease-out duration-100","enter-from-class":"transform opacity-0 scale-95","enter-to-class":"transform opacity-100 scale-100","leave-active-class":"transition ease-in duration-75","leave-from-class":"transform opacity-100 scale-100","leave-to-class":"transform opacity-0 scale-95"},{default:Bs(()=>[N.value?(i(),d("div",{key:0,ref_key:"dropdownRef",ref:B,class:"absolute z-50 flex flex-col rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-600 dark:bg-gray-800",style:pt(T.value)},[e("div",Qs,[e("div",Js,[_(e("input",{ref_key:"searchInput",ref:U,"onUpdate:modelValue":C[1]||(C[1]=g=>$.value=g),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",placeholder:"搜索账号名称...",style:{"padding-left":"40px","padding-right":"36px"},type:"text",onInput:be},null,544),[[ee,$.value]]),C[4]||(C[4]=e("i",{class:"fas fa-search pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-sm text-gray-400 dark:text-gray-500"},null,-1)),$.value?(i(),d("button",{key:0,class:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-400",type:"button",onClick:k},C[3]||(C[3]=[e("i",{class:"fas fa-times text-sm"},null,-1)]))):h("",!0)])]),e("div",Xs,[f.value.length>0?(i(),d("div",Zs,[(i(!0),d(te,null,oe(f.value,g=>(i(),d("div",{key:`special-${g.value}`,class:z(["cursor-pointer px-4 py-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-700",{"bg-blue-50 dark:bg-blue-900/20":v.modelValue===g.value}]),onClick:l=>X(g.value)},[e("span",ta,u(g.label),1),g.description?(i(),d("span",sa,u(g.description),1)):h("",!0)],10,ea))),128))])):h("",!0),e("div",{class:z(["cursor-pointer px-4 py-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-700",{"bg-blue-50 dark:bg-blue-900/20":!v.modelValue}]),onClick:C[2]||(C[2]=g=>X(null))},[e("span",aa,u(v.defaultOptionText),1)],2),V.value.length>0?(i(),d("div",ra,[C[5]||(C[5]=e("div",{class:"bg-gray-50 px-4 py-2 text-xs font-semibold text-gray-500 dark:bg-gray-700 dark:text-gray-400"}," 调度分组 ",-1)),(i(!0),d(te,null,oe(V.value,g=>(i(),d("div",{key:`group:${g.id}`,class:z(["cursor-pointer px-4 py-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-700",{"bg-blue-50 dark:bg-blue-900/20":v.modelValue===`group:${g.id}`}]),onClick:l=>X(`group:${g.id}`)},[e("div",la,[e("span",ia,u(g.name),1),e("span",na,u(g.memberCount||0)+" 个成员",1)])],10,oa))),128))])):h("",!0),S.value.length>0?(i(),d("div",da,[e("div",ua,u(v.platform==="claude"?"Claude OAuth 专属账号":v.platform==="openai"?"OpenAI 专属账号":v.platform==="droid"?"Droid 专属账号":v.platform==="gemini"?"Gemini OAuth 专属账号":"OAuth 专属账号"),1),(i(!0),d(te,null,oe(S.value,g=>(i(),d("div",{key:g.id,class:z(["cursor-pointer px-4 py-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-700",{"bg-blue-50 dark:bg-blue-900/20":v.modelValue===g.id}]),onClick:l=>X(g.id)},[e("div",ga,[e("div",null,[e("span",pa,u(g.name),1),e("span",{class:z(["ml-2 rounded-full px-2 py-0.5 text-xs",g.isActive?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":g.status==="unauthorized"?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"])},u(p(g)),3)]),e("span",ma,u(ie(g.createdAt)),1)])],10,ca))),128))])):h("",!0),v.platform==="claude"&&W.value.length>0?(i(),d("div",xa,[C[6]||(C[6]=e("div",{class:"bg-gray-50 px-4 py-2 text-xs font-semibold text-gray-500 dark:bg-gray-700 dark:text-gray-400"}," Claude Console 专属账号 ",-1)),(i(!0),d(te,null,oe(W.value,g=>(i(),d("div",{key:g.id,class:z(["cursor-pointer px-4 py-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-700",{"bg-blue-50 dark:bg-blue-900/20":v.modelValue===`console:${g.id}`}]),onClick:l=>X(`console:${g.id}`)},[e("div",fa,[e("div",null,[e("span",ba,u(g.name),1),e("span",{class:z(["ml-2 rounded-full px-2 py-0.5 text-xs",g.isActive?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":g.status==="unauthorized"?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"])},u(p(g)),3)]),e("span",va,u(ie(g.createdAt)),1)])],10,ya))),128))])):h("",!0),v.platform==="openai"&&I.value.length>0?(i(),d("div",ka,[C[7]||(C[7]=e("div",{class:"bg-gray-50 px-4 py-2 text-xs font-semibold text-gray-500 dark:bg-gray-700 dark:text-gray-400"}," OpenAI-Responses 专属账号 ",-1)),(i(!0),d(te,null,oe(I.value,g=>(i(),d("div",{key:g.id,class:z(["cursor-pointer px-4 py-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-700",{"bg-blue-50 dark:bg-blue-900/20":v.modelValue===`responses:${g.id}`}]),onClick:l=>X(`responses:${g.id}`)},[e("div",ha,[e("div",null,[e("span",Aa,u(g.name),1),e("span",{class:z(["ml-2 rounded-full px-2 py-0.5 text-xs",g.isActive==="true"||g.isActive===!0?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":g.status==="rate_limited"?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"])},u(p(g)),3)]),e("span",$a,u(ie(g.createdAt)),1)])],10,wa))),128))])):h("",!0),v.platform==="gemini"&&K.value.length>0?(i(),d("div",Ca,[C[8]||(C[8]=e("div",{class:"bg-gray-50 px-4 py-2 text-xs font-semibold text-gray-500 dark:bg-gray-700 dark:text-gray-400"}," Gemini-API 专属账号 ",-1)),(i(!0),d(te,null,oe(K.value,g=>(i(),d("div",{key:g.id,class:z(["cursor-pointer px-4 py-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-700",{"bg-blue-50 dark:bg-blue-900/20":v.modelValue===`api:${g.id}`}]),onClick:l=>X(`api:${g.id}`)},[e("div",Ka,[e("div",null,[e("span",La,u(g.name),1),e("span",{class:z(["ml-2 rounded-full px-2 py-0.5 text-xs",g.isActive==="true"||g.isActive===!0?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":g.status==="rate_limited"?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"])},u(p(g)),3)]),e("span",Da,u(ie(g.createdAt)),1)])],10,Ia))),128))])):h("",!0),$.value&&!se.value?(i(),d("div",_a,C[9]||(C[9]=[e("i",{class:"fas fa-search mb-2 text-2xl"},null,-1),e("p",{class:"text-sm"},"没有找到匹配的账号",-1)]))):h("",!0)])],4)):h("",!0)]),_:1})]))],512))}},Ae=_e(Sa,[["__scopeId","data-v-32c162ec"]]),Ta={class:"modal fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4"},Pa={class:"modal-content mx-auto flex max-h-[90vh] w-full max-w-4xl flex-col p-4 sm:p-6"},Ua={class:"mb-4 flex items-center justify-between"},Ma={class:"rounded-lg border border-blue-200 bg-gradient-to-r from-blue-50 to-indigo-50 p-3 dark:border-blue-700 dark:from-blue-900/20 dark:to-indigo-900/20 sm:p-4"},Va={class:"flex items-center gap-3 sm:gap-4"},Ra={class:"flex cursor-pointer items-center"},Ea={class:"flex cursor-pointer items-center"},Oa={key:0,class:"mt-3"},ja={class:"flex items-center gap-4"},Ga={class:"flex-1"},qa={class:"flex items-center gap-2"},za={class:"mt-2 flex items-start text-xs text-amber-600 dark:text-amber-400"},Fa=["placeholder"],Ba={key:0,class:"mt-1 text-xs text-red-500 dark:text-red-400"},Wa={class:"space-y-4"},Na={key:0},Ha={class:"flex flex-wrap gap-2"},Ya=["onClick"],Qa={key:1},Ja={class:"flex flex-wrap gap-2"},Xa=["onClick"],Za={class:"flex gap-2"},er=["onKeypress"],tr={class:"rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-700 dark:bg-blue-900/20"},sr={class:"space-y-2"},ar={class:"grid grid-cols-1 gap-2 lg:grid-cols-3"},rr={class:"space-y-2"},or={class:"flex gap-2"},lr={class:"space-y-2"},ir={class:"flex gap-2"},nr={class:"space-y-2"},dr={class:"flex gap-2"},ur={class:"mb-3 rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-gray-800"},cr={class:"flex items-center gap-4"},gr={class:"flex cursor-pointer items-center"},pr={class:"flex cursor-pointer items-center"},mr={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},xr={key:0},yr={key:1},fr={key:0},br={key:0,class:"mt-3"},vr=["min"],kr={key:1,class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},wr={key:1},hr={class:"flex items-center gap-2"},Ar=["max","placeholder"],$r={class:"mt-2 flex flex-wrap gap-2"},Cr=["onClick"],Ir={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},Kr={class:"flex gap-4"},Lr={class:"flex cursor-pointer items-center"},Dr={class:"flex cursor-pointer items-center"},_r={class:"flex cursor-pointer items-center"},Sr={class:"flex cursor-pointer items-center"},Tr={class:"flex cursor-pointer items-center"},Pr={class:"mb-2 flex items-center justify-between"},Ur=["disabled"],Mr={class:"grid grid-cols-1 gap-3"},Vr={class:"mb-2 flex items-center"},Rr={key:0,class:"space-y-3"},Er={class:"mb-3 flex min-h-[32px] flex-wrap gap-2 rounded-lg border border-gray-200 bg-gray-50 p-2"},Or=["onClick"],jr={key:0,class:"text-sm text-gray-400"},Gr={class:"space-y-3"},qr={class:"flex flex-wrap gap-2"},zr=["onClick"],Fr={key:0,class:"text-sm italic text-gray-400"},Br={class:"flex gap-2"},Wr=["onKeydown"],Nr={class:"mb-2 flex items-center"},Hr={key:0,class:"rounded-lg border border-green-200 bg-green-50 p-3 dark:border-green-700 dark:bg-green-900/20"},Yr={class:"space-y-1"},Qr=["id","value"],Jr=["for"],Xr={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Zr={class:"block text-xs text-gray-500 dark:text-gray-400"},eo={class:"flex gap-3 pt-2"},to=["disabled"],so={key:0,class:"loading-spinner mr-2"},ao={key:1,class:"fas fa-plus mr-2"},ro={__name:"CreateApiKeyModal",props:{accounts:{type:Object,default:()=>({claude:[],gemini:[],openai:[],bedrock:[],droid:[],claudeGroups:[],geminiGroups:[],openaiGroups:[],droidGroups:[]})}},emits:["close","success","batch-success"],setup(v,{emit:H}){const c=v,M=H,N=Lt(),$=Dt(),U=D(!1),B=D(!1),T=D({claude:[],gemini:[],openai:[],bedrock:[],droid:[],claudeGroups:[],geminiGroups:[],openaiGroups:[],droidGroups:[]}),J=D({name:""}),Y=D(""),f=D([]),L=R(()=>f.value.filter(g=>!s.tags.includes(g))),p=D([]),s=ze({createType:"single",batchCount:10,name:"",description:"",rateLimitWindow:"",rateLimitRequests:"",rateLimitCost:"",concurrencyLimit:"",dailyCostLimit:"",totalCostLimit:"",weeklyOpusCostLimit:"",expireDuration:"",customExpireDate:"",expiresAt:null,expirationMode:"fixed",activationDays:30,activationUnit:"days",permissions:"all",claudeAccountId:"",geminiAccountId:"",openaiAccountId:"",bedrockAccountId:"",droidAccountId:"",enableModelRestriction:!1,restrictedModels:[],modelInput:"",enableClientRestriction:!1,allowedClients:[],tags:[]});st(async()=>{if(p.value=await N.loadSupportedClients(),f.value=await $.fetchTags(),c.accounts){const g=[];c.accounts.openai&&c.accounts.openai.forEach(l=>{g.push({...l,platform:"openai"})}),c.accounts.openaiResponses&&c.accounts.openaiResponses.forEach(l=>{g.push({...l,platform:"openai-responses"})}),T.value={claude:c.accounts.claude||[],gemini:c.accounts.gemini||[],openai:g,bedrock:c.accounts.bedrock||[],droid:(c.accounts.droid||[]).map(l=>({...l,platform:"droid"})),claudeGroups:c.accounts.claudeGroups||[],geminiGroups:c.accounts.geminiGroups||[],openaiGroups:c.accounts.openaiGroups||[],droidGroups:c.accounts.droidGroups||[]}}await V()});const V=async()=>{var g,l;B.value=!0;try{const[y,ae,ue,ge,ve,fe,F,Q]=await Promise.all([q.get("/admin/claude-accounts"),q.get("/admin/claude-console-accounts"),q.get("/admin/gemini-accounts"),q.get("/admin/openai-accounts"),q.get("/admin/openai-responses-accounts"),q.get("/admin/bedrock-accounts"),q.get("/admin/droid-accounts"),q.get("/admin/account-groups")]),me=[];y.success&&((g=y.data)==null||g.forEach(re=>{me.push({...re,platform:"claude-oauth",isDedicated:re.accountType==="dedicated"})})),ae.success&&((l=ae.data)==null||l.forEach(re=>{me.push({...re,platform:"claude-console",isDedicated:re.accountType==="dedicated"})})),T.value.claude=me,ue.success&&(T.value.gemini=(ue.data||[]).map(re=>({...re,isDedicated:re.accountType==="dedicated"})));const Fe=[];if(ge.success&&(ge.data||[]).forEach(re=>{Fe.push({...re,platform:"openai",isDedicated:re.accountType==="dedicated"})}),ve.success&&(ve.data||[]).forEach(re=>{Fe.push({...re,platform:"openai-responses",isDedicated:re.accountType==="dedicated"})}),T.value.openai=Fe,fe.success&&(T.value.bedrock=(fe.data||[]).map(re=>({...re,isDedicated:re.accountType==="dedicated"}))),F.success&&(T.value.droid=(F.data||[]).map(re=>({...re,platform:"droid",isDedicated:re.accountType==="dedicated"}))),Q.success){const re=Q.data||[];T.value.claudeGroups=re.filter(Ie=>Ie.platform==="claude"),T.value.geminiGroups=re.filter(Ie=>Ie.platform==="gemini"),T.value.openaiGroups=re.filter(Ie=>Ie.platform==="openai"),T.value.droidGroups=re.filter(Ie=>Ie.platform==="droid")}O("账号列表已刷新","success")}catch{O("刷新账号列表失败","error")}finally{B.value=!1}},S=R(()=>{const g=new Date;return g.setMinutes(g.getMinutes()+1),g.toISOString().slice(0,16)}),W=()=>{if(!s.expireDuration){s.expiresAt=null;return}if(s.expireDuration==="custom")return;const g=new Date,y=s.expireDuration.match(/(\d+)([dhmy])/);if(y){const[,ae,ue]=y,ge=parseInt(ae);switch(ue){case"d":g.setDate(g.getDate()+ge);break;case"h":g.setHours(g.getHours()+ge);break;case"m":g.setMonth(g.getMonth()+ge);break;case"y":g.setFullYear(g.getFullYear()+ge);break}s.expiresAt=g.toISOString()}},I=()=>{s.customExpireDate&&(s.expiresAt=new Date(s.customExpireDate).toISOString())},K=g=>new Date(g).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),se=()=>{s.modelInput&&!s.restrictedModels.includes(s.modelInput)&&(s.restrictedModels.push(s.modelInput),s.modelInput="")},ie=g=>{s.restrictedModels.splice(g,1)},de=D(["claude-opus-4-20250514","claude-opus-4-1-20250805"]),pe=R(()=>de.value.filter(g=>!s.restrictedModels.includes(g))),X=g=>{s.restrictedModels.includes(g)||s.restrictedModels.push(g)},be=()=>{if(Y.value&&Y.value.trim()){const g=Y.value.trim();s.tags.includes(g)||s.tags.push(g),Y.value=""}},k=g=>{s.tags.includes(g)||s.tags.push(g)},o=g=>{s.tags.splice(g,1)},n=()=>s.activationUnit==="hours"?[{value:1,label:"1小时"},{value:3,label:"3小时"},{value:6,label:"6小时"},{value:12,label:"12小时"}]:[{value:30,label:"30天"},{value:90,label:"90天"},{value:180,label:"180天"},{value:365,label:"365天"}],m=()=>{s.activationUnit==="hours"?s.activationDays>24&&(s.activationDays=24):s.activationDays<1&&(s.activationDays=1)},C=async()=>{if(J.value.name="",!s.name||!s.name.trim()){J.value.name="请输入API Key名称";return}if(s.createType==="batch"&&(!s.batchCount||s.batchCount<2||s.batchCount>500)){O("批量创建数量必须在 2-500 之间","error");return}if(s.rateLimitWindow&&(!s.rateLimitCost||parseFloat(s.rateLimitCost)===0)){let g=!1;if(window.showConfirm?g=await window.showConfirm("费用限制提醒",`您设置了时间窗口但费用限制为0,这意味着不会有费用限制。
|
||
|
||
是否继续?`,"继续创建","返回修改"):g=confirm(`您设置了时间窗口但费用限制为0,这意味着不会有费用限制。
|
||
是否继续?`),!g)return}U.value=!0;try{const g={description:s.description||void 0,tokenLimit:0,rateLimitWindow:s.rateLimitWindow!==""&&s.rateLimitWindow!==null?parseInt(s.rateLimitWindow):null,rateLimitRequests:s.rateLimitRequests!==""&&s.rateLimitRequests!==null?parseInt(s.rateLimitRequests):null,rateLimitCost:s.rateLimitCost!==""&&s.rateLimitCost!==null?parseFloat(s.rateLimitCost):null,concurrencyLimit:s.concurrencyLimit!==""&&s.concurrencyLimit!==null?parseInt(s.concurrencyLimit):0,dailyCostLimit:s.dailyCostLimit!==""&&s.dailyCostLimit!==null?parseFloat(s.dailyCostLimit):0,totalCostLimit:s.totalCostLimit!==""&&s.totalCostLimit!==null?parseFloat(s.totalCostLimit):0,weeklyOpusCostLimit:s.weeklyOpusCostLimit!==""&&s.weeklyOpusCostLimit!==null?parseFloat(s.weeklyOpusCostLimit):0,expiresAt:s.expirationMode==="fixed"&&s.expiresAt||void 0,expirationMode:s.expirationMode,activationDays:s.expirationMode==="activation"?s.activationDays:void 0,activationUnit:s.expirationMode==="activation"?s.activationUnit:void 0,permissions:s.permissions,tags:s.tags.length>0?s.tags:void 0,enableModelRestriction:s.enableModelRestriction,restrictedModels:s.restrictedModels,enableClientRestriction:s.enableClientRestriction,allowedClients:s.allowedClients};if(s.claudeAccountId&&(s.claudeAccountId.startsWith("console:")?(g.claudeConsoleAccountId=s.claudeAccountId.substring(8),delete g.claudeAccountId):(g.claudeAccountId=s.claudeAccountId,delete g.claudeConsoleAccountId)),s.geminiAccountId&&(g.geminiAccountId=s.geminiAccountId),s.openaiAccountId&&(g.openaiAccountId=s.openaiAccountId),s.bedrockAccountId&&(g.bedrockAccountId=s.bedrockAccountId),s.droidAccountId&&(g.droidAccountId=s.droidAccountId),s.createType==="single"){const l={...g,name:s.name},y=await q.post("/admin/api-keys",l);y.success?(O("API Key 创建成功","success"),M("success",y.data),M("close")):O(y.message||"创建失败","error")}else{const l={...g,createType:"batch",baseName:s.name,count:s.batchCount},y=await q.post("/admin/api-keys/batch",l);y.success?(O(`成功创建 ${y.data.length} 个 API Key`,"success"),M("batch-success",y.data),M("close")):O(y.message||"批量创建失败","error")}}catch{O("创建失败","error")}finally{U.value=!1}};return(g,l)=>(i(),ye(Ue,{to:"body"},[e("div",Ta,[e("div",Pa,[e("div",Ua,[l[49]||(l[49]=e("div",{class:"flex items-center gap-2 sm:gap-3"},[e("div",{class:"flex h-8 w-8 items-center justify-center rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 sm:h-10 sm:w-10 sm:rounded-xl"},[e("i",{class:"fas fa-key text-sm text-white sm:text-base"})]),e("h3",{class:"text-lg font-bold text-gray-900 dark:text-gray-100 sm:text-xl"}," 创建新的 API Key ")],-1)),e("button",{class:"p-1 text-gray-400 transition-colors hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",onClick:l[0]||(l[0]=y=>g.$emit("close"))},l[48]||(l[48]=[e("i",{class:"fas fa-times text-lg sm:text-xl"},null,-1)]))]),e("form",{class:"modal-scroll-content custom-scrollbar flex-1 space-y-4",onSubmit:Ce(C,["prevent"])},[e("div",Ma,[e("div",{class:z(["flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",s.createType==="batch"?"mb-3":""])},[l[52]||(l[52]=e("label",{class:"flex h-full items-center text-xs font-semibold text-gray-700 dark:text-gray-300 sm:text-sm"},"创建类型",-1)),e("div",Va,[e("label",Ra,[_(e("input",{"onUpdate:modelValue":l[1]||(l[1]=y=>s.createType=y),class:"mr-1.5 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 sm:mr-2",type:"radio",value:"single"},null,512),[[ne,s.createType]]),l[50]||(l[50]=e("span",{class:"flex items-center text-xs text-gray-700 dark:text-gray-300 sm:text-sm"},[e("i",{class:"fas fa-key mr-1 text-xs"}),A(" 单个创建 ")],-1))]),e("label",Ea,[_(e("input",{"onUpdate:modelValue":l[2]||(l[2]=y=>s.createType=y),class:"mr-1.5 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 sm:mr-2",type:"radio",value:"batch"},null,512),[[ne,s.createType]]),l[51]||(l[51]=e("span",{class:"flex items-center text-xs text-gray-700 dark:text-gray-300 sm:text-sm"},[e("i",{class:"fas fa-layer-group mr-1 text-xs"}),A(" 批量创建 ")],-1))])])],2),s.createType==="batch"?(i(),d("div",Oa,[e("div",ja,[e("div",Ga,[l[54]||(l[54]=e("label",{class:"mb-1 block text-xs font-medium text-gray-600 dark:text-gray-400"},"创建数量",-1)),e("div",qa,[_(e("input",{"onUpdate:modelValue":l[3]||(l[3]=y=>s.batchCount=y),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",max:"500",min:"2",placeholder:"输入数量 (2-500)",required:"",type:"number"},null,512),[[ee,s.batchCount,void 0,{number:!0}]]),l[53]||(l[53]=e("div",{class:"whitespace-nowrap text-xs text-gray-500 dark:text-gray-400"}," 最大支持 500 个 ",-1))])])]),e("p",za,[l[55]||(l[55]=e("i",{class:"fas fa-info-circle mr-1 mt-0.5 flex-shrink-0"},null,-1)),e("span",null,"批量创建时,每个 Key 的名称会自动添加序号后缀,例如:"+u(s.name||"MyKey")+"_1, "+u(s.name||"MyKey")+"_2 ...",1)])])):h("",!0)]),e("div",null,[l[56]||(l[56]=e("label",{class:"mb-1.5 block text-xs font-semibold text-gray-700 dark:text-gray-300 sm:mb-2 sm:text-sm"},[A("名称 "),e("span",{class:"text-red-500"},"*")],-1)),e("div",null,[_(e("input",{"onUpdate:modelValue":l[4]||(l[4]=y=>s.name=y),class:z(["form-input flex-1 border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",{"border-red-500":J.value.name}]),placeholder:s.createType==="batch"?"输入基础名称(将自动添加序号)":"为您的 API Key 取一个名称",required:"",type:"text",onInput:l[5]||(l[5]=y=>J.value.name="")},null,42,Fa),[[ee,s.name]])]),J.value.name?(i(),d("p",Ba,u(J.value.name),1)):h("",!0)]),e("div",null,[l[64]||(l[64]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"标签",-1)),e("div",Wa,[s.tags.length>0?(i(),d("div",Na,[l[58]||(l[58]=e("div",{class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"}," 已选择的标签: ",-1)),e("div",Ha,[(i(!0),d(te,null,oe(s.tags,(y,ae)=>(i(),d("span",{key:"selected-"+ae,class:"inline-flex items-center gap-1 rounded-full bg-blue-100 px-3 py-1 text-sm text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"},[A(u(y)+" ",1),e("button",{class:"ml-1 hover:text-blue-900 dark:hover:text-blue-300",type:"button",onClick:ue=>o(ae)},l[57]||(l[57]=[e("i",{class:"fas fa-times text-xs"},null,-1)]),8,Ya)]))),128))])])):h("",!0),L.value.length>0?(i(),d("div",Qa,[l[60]||(l[60]=e("div",{class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"}," 点击选择已有标签: ",-1)),e("div",Ja,[(i(!0),d(te,null,oe(L.value,y=>(i(),d("button",{key:"available-"+y,class:"inline-flex items-center gap-1 rounded-full bg-gray-100 px-3 py-1 text-sm text-gray-700 transition-colors hover:bg-blue-100 hover:text-blue-700 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-blue-900/30 dark:hover:text-blue-400",type:"button",onClick:ae=>k(y)},[l[59]||(l[59]=e("i",{class:"fas fa-tag text-xs text-gray-500 dark:text-gray-400"},null,-1)),A(" "+u(y),1)],8,Xa))),128))])])):h("",!0),e("div",null,[l[62]||(l[62]=e("div",{class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"}," 创建新标签: ",-1)),e("div",Za,[_(e("input",{"onUpdate:modelValue":l[6]||(l[6]=y=>Y.value=y),class:"form-input flex-1 border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",placeholder:"输入新标签名称",type:"text",onKeypress:et(Ce(be,["prevent"]),["enter"])},null,40,er),[[ee,Y.value]]),e("button",{class:"rounded-lg bg-green-500 px-4 py-2 text-white transition-colors hover:bg-green-600",type:"button",onClick:be},l[61]||(l[61]=[e("i",{class:"fas fa-plus"},null,-1)]))])]),l[63]||(l[63]=e("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," 用于标记不同团队或用途,方便筛选管理 ",-1))])]),e("div",tr,[l[72]||(l[72]=e("div",{class:"mb-2 flex items-center gap-2"},[e("div",{class:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded bg-blue-500"},[e("i",{class:"fas fa-tachometer-alt text-xs text-white"})]),e("h4",{class:"text-sm font-semibold text-gray-800 dark:text-gray-200"}," 速率限制设置 (可选) ")],-1)),e("div",sr,[e("div",ar,[e("div",null,[l[65]||(l[65]=e("label",{class:"mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300"},"时间窗口 (分钟)",-1)),_(e("input",{"onUpdate:modelValue":l[7]||(l[7]=y=>s.rateLimitWindow=y),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"1",placeholder:"无限制",type:"number"},null,512),[[ee,s.rateLimitWindow]]),l[66]||(l[66]=e("p",{class:"ml-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400"},"时间段单位",-1))]),e("div",null,[l[67]||(l[67]=e("label",{class:"mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300"},"请求次数限制",-1)),_(e("input",{"onUpdate:modelValue":l[8]||(l[8]=y=>s.rateLimitRequests=y),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"1",placeholder:"无限制",type:"number"},null,512),[[ee,s.rateLimitRequests]]),l[68]||(l[68]=e("p",{class:"ml-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400"},"窗口内最大请求",-1))]),e("div",null,[l[69]||(l[69]=e("label",{class:"mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300"},"费用限制 (美元)",-1)),_(e("input",{"onUpdate:modelValue":l[9]||(l[9]=y=>s.rateLimitCost=y),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"0",placeholder:"无限制",step:"0.01",type:"number"},null,512),[[ee,s.rateLimitCost]]),l[70]||(l[70]=e("p",{class:"ml-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400"},"窗口内最大费用",-1))])]),l[71]||(l[71]=e("div",{class:"rounded-lg bg-blue-100 p-2 dark:bg-blue-900/30"},[e("h5",{class:"mb-1 text-xs font-semibold text-blue-800 dark:text-blue-400"}," 💡 使用示例 "),e("div",{class:"space-y-0.5 text-xs text-blue-700 dark:text-blue-300"},[e("div",null,[e("strong",null,"示例1:"),A(" 时间窗口=60,请求次数=1000 → 每60分钟最多1000次请求 ")]),e("div",null,[e("strong",null,"示例2:"),A(" 时间窗口=1,费用=0.1 → 每分钟最多$0.1费用")]),e("div",null,[e("strong",null,"示例3:"),A(" 窗口=30,请求=50,费用=5 → 每30分钟50次请求且不超$5费用 ")])])],-1))])]),e("div",null,[l[74]||(l[74]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"每日费用限制 (美元)",-1)),e("div",rr,[e("div",or,[e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[10]||(l[10]=y=>s.dailyCostLimit="50")}," $50 "),e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[11]||(l[11]=y=>s.dailyCostLimit="100")}," $100 "),e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[12]||(l[12]=y=>s.dailyCostLimit="200")}," $200 "),e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[13]||(l[13]=y=>s.dailyCostLimit="")}," 自定义 ")]),_(e("input",{"onUpdate:modelValue":l[14]||(l[14]=y=>s.dailyCostLimit=y),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"0",placeholder:"0 表示无限制",step:"0.01",type:"number"},null,512),[[ee,s.dailyCostLimit]]),l[73]||(l[73]=e("p",{class:"dark:text灰-400 text-xs text-gray-500"}," 设置此 API Key 每日的费用限制,超过限制将拒绝请求,0 或留空表示无限制 ",-1))])]),e("div",null,[l[76]||(l[76]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"总费用限制 (美元)",-1)),e("div",lr,[e("div",ir,[e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[15]||(l[15]=y=>s.totalCostLimit="100")}," $100 "),e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[16]||(l[16]=y=>s.totalCostLimit="500")}," $500 "),e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[17]||(l[17]=y=>s.totalCostLimit="1000")}," $1000 "),e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[18]||(l[18]=y=>s.totalCostLimit="")}," 自定义 ")]),_(e("input",{"onUpdate:modelValue":l[19]||(l[19]=y=>s.totalCostLimit=y),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"0",placeholder:"0 表示无限制",step:"0.01",type:"number"},null,512),[[ee,s.totalCostLimit]]),l[75]||(l[75]=e("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," 设置此 API Key 的累计总费用限制,达到限制后将拒绝所有后续请求,0 或留空表示无限制 ",-1))])]),e("div",null,[l[78]||(l[78]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"Opus 模型周费用限制 (美元)",-1)),e("div",nr,[e("div",dr,[e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[20]||(l[20]=y=>s.weeklyOpusCostLimit="100")}," $100 "),e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[21]||(l[21]=y=>s.weeklyOpusCostLimit="500")}," $500 "),e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[22]||(l[22]=y=>s.weeklyOpusCostLimit="1000")}," $1000 "),e("button",{class:"rounded bg-gray-100 px-2 py-1 text-xs font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[23]||(l[23]=y=>s.weeklyOpusCostLimit="")}," 自定义 ")]),_(e("input",{"onUpdate:modelValue":l[24]||(l[24]=y=>s.weeklyOpusCostLimit=y),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"0",placeholder:"0 表示无限制",step:"0.01",type:"number"},null,512),[[ee,s.weeklyOpusCostLimit]]),l[77]||(l[77]=e("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," 设置 Opus 模型的周费用限制(周一到周日),仅限 Claude 官方账户,0 或留空表示无限制 ",-1))])]),e("div",null,[l[79]||(l[79]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"并发限制 (可选)",-1)),_(e("input",{"onUpdate:modelValue":l[25]||(l[25]=y=>s.concurrencyLimit=y),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"0",placeholder:"0 表示无限制",type:"number"},null,512),[[ee,s.concurrencyLimit]]),l[80]||(l[80]=e("p",{class:"mt-2 text-xs text-gray-500 dark:text-gray-400"}," 设置此 API Key 可同时处理的最大请求数,0 或留空表示无限制 ",-1))]),e("div",null,[l[81]||(l[81]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"备注 (可选)",-1)),_(e("textarea",{"onUpdate:modelValue":l[26]||(l[26]=y=>s.description=y),class:"form-input w-full resize-none border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",placeholder:"描述此 API Key 的用途...",rows:"2"},null,512),[[ee,s.description]])]),e("div",null,[l[89]||(l[89]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"过期设置",-1)),e("div",ur,[e("div",cr,[e("label",gr,[_(e("input",{"onUpdate:modelValue":l[27]||(l[27]=y=>s.expirationMode=y),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"fixed"},null,512),[[ne,s.expirationMode]]),l[82]||(l[82]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"固定时间过期",-1))]),e("label",pr,[_(e("input",{"onUpdate:modelValue":l[28]||(l[28]=y=>s.expirationMode=y),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"activation"},null,512),[[ne,s.expirationMode]]),l[83]||(l[83]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"首次使用后激活",-1))])]),e("p",mr,[s.expirationMode==="fixed"?(i(),d("span",xr,l[84]||(l[84]=[e("i",{class:"fas fa-info-circle mr-1"},null,-1),A(" 固定时间模式:Key 创建后立即生效,按设定时间过期(支持小时和天数) ",-1)]))):(i(),d("span",yr,l[85]||(l[85]=[e("i",{class:"fas fa-info-circle mr-1"},null,-1),A(" 激活模式:Key 首次使用时激活,激活后按设定时间过期(支持小时和天数,适合批量销售) ",-1)])))])]),s.expirationMode==="fixed"?(i(),d("div",fr,[_(e("select",{"onUpdate:modelValue":l[29]||(l[29]=y=>s.expireDuration=y),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",onChange:W},l[86]||(l[86]=[e("option",{value:""},"永不过期",-1),e("option",{value:"1h"},"1 小时",-1),e("option",{value:"3h"},"3 小时",-1),e("option",{value:"6h"},"6 小时",-1),e("option",{value:"12h"},"12 小时",-1),e("option",{value:"1d"},"1 天",-1),e("option",{value:"7d"},"7 天",-1),e("option",{value:"30d"},"30 天",-1),e("option",{value:"90d"},"90 天",-1),e("option",{value:"180d"},"180 天",-1),e("option",{value:"365d"},"365 天",-1),e("option",{value:"custom"},"自定义日期",-1)]),544),[[tt,s.expireDuration]]),s.expireDuration==="custom"?(i(),d("div",br,[_(e("input",{"onUpdate:modelValue":l[30]||(l[30]=y=>s.customExpireDate=y),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",min:S.value,type:"datetime-local",onChange:I},null,40,vr),[[ee,s.customExpireDate]])])):h("",!0),s.expiresAt?(i(),d("p",kr," 将于 "+u(K(s.expiresAt))+" 过期 ",1)):h("",!0)])):(i(),d("div",wr,[e("div",hr,[_(e("input",{"onUpdate:modelValue":l[31]||(l[31]=y=>s.activationDays=y),class:"form-input flex-1 border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",max:s.activationUnit==="hours"?8760:3650,min:"1",placeholder:s.activationUnit==="hours"?"输入小时数":"输入天数",type:"number"},null,8,Ar),[[ee,s.activationDays,void 0,{number:!0}]]),_(e("select",{"onUpdate:modelValue":l[32]||(l[32]=y=>s.activationUnit=y),class:"form-input w-20 border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",onChange:m},l[87]||(l[87]=[e("option",{value:"hours"},"小时",-1),e("option",{value:"days"},"天",-1)]),544),[[tt,s.activationUnit]])]),e("div",$r,[(i(!0),d(te,null,oe(n(),y=>(i(),d("button",{key:y.value,class:"rounded-md border border-gray-300 px-3 py-1 text-xs hover:bg-gray-100 dark:border-gray-600 dark:hover:bg-gray-700",type:"button",onClick:ae=>s.activationDays=y.value},u(y.label),9,Cr))),128))]),e("p",Ir,[l[88]||(l[88]=e("i",{class:"fas fa-clock mr-1"},null,-1)),A(" Key 将在首次使用后激活,激活后 "+u(s.activationDays||(s.activationUnit==="hours"?24:30))+" "+u(s.activationUnit==="hours"?"小时":"天")+"过期 ",1)])]))]),e("div",null,[l[95]||(l[95]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"服务权限",-1)),e("div",Kr,[e("label",Lr,[_(e("input",{"onUpdate:modelValue":l[33]||(l[33]=y=>s.permissions=y),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"all"},null,512),[[ne,s.permissions]]),l[90]||(l[90]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"全部服务",-1))]),e("label",Dr,[_(e("input",{"onUpdate:modelValue":l[34]||(l[34]=y=>s.permissions=y),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"claude"},null,512),[[ne,s.permissions]]),l[91]||(l[91]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"仅 Claude",-1))]),e("label",_r,[_(e("input",{"onUpdate:modelValue":l[35]||(l[35]=y=>s.permissions=y),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"gemini"},null,512),[[ne,s.permissions]]),l[92]||(l[92]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"仅 Gemini",-1))]),e("label",Sr,[_(e("input",{"onUpdate:modelValue":l[36]||(l[36]=y=>s.permissions=y),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"openai"},null,512),[[ne,s.permissions]]),l[93]||(l[93]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"仅 OpenAI",-1))]),e("label",Tr,[_(e("input",{"onUpdate:modelValue":l[37]||(l[37]=y=>s.permissions=y),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"droid"},null,512),[[ne,s.permissions]]),l[94]||(l[94]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"仅 Droid",-1))])]),l[96]||(l[96]=e("p",{class:"mt-2 text-xs text-gray-500 dark:text-gray-400"}," 控制此 API Key 可以访问哪些服务 ",-1))]),e("div",null,[e("div",Pr,[l[97]||(l[97]=e("label",{class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},"专属账号绑定 (可选)",-1)),e("button",{class:"flex items-center gap-1 text-sm text-blue-600 transition-colors hover:text-blue-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-blue-400 dark:hover:text-blue-300",disabled:B.value,title:"刷新账号列表",type:"button",onClick:V},[e("i",{class:z(["fas",B.value?"fa-spinner fa-spin":"fa-sync-alt","text-xs"])},null,2),e("span",null,u(B.value?"刷新中...":"刷新账号"),1)],8,Ur)]),e("div",Mr,[e("div",null,[l[98]||(l[98]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Claude 专属账号",-1)),le(Ae,{modelValue:s.claudeAccountId,"onUpdate:modelValue":l[38]||(l[38]=y=>s.claudeAccountId=y),accounts:T.value.claude,"default-option-text":"使用共享账号池",disabled:s.permissions!=="all"&&s.permissions!=="claude",groups:T.value.claudeGroups,placeholder:"请选择Claude账号",platform:"claude"},null,8,["modelValue","accounts","disabled","groups"])]),e("div",null,[l[99]||(l[99]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Gemini 专属账号",-1)),le(Ae,{modelValue:s.geminiAccountId,"onUpdate:modelValue":l[39]||(l[39]=y=>s.geminiAccountId=y),accounts:T.value.gemini,"default-option-text":"使用共享账号池",disabled:s.permissions!=="all"&&s.permissions!=="gemini",groups:T.value.geminiGroups,placeholder:"请选择Gemini账号",platform:"gemini"},null,8,["modelValue","accounts","disabled","groups"])]),e("div",null,[l[100]||(l[100]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"OpenAI 专属账号",-1)),le(Ae,{modelValue:s.openaiAccountId,"onUpdate:modelValue":l[40]||(l[40]=y=>s.openaiAccountId=y),accounts:T.value.openai,"default-option-text":"使用共享账号池",disabled:s.permissions!=="all"&&s.permissions!=="openai",groups:T.value.openaiGroups,placeholder:"请选择OpenAI账号",platform:"openai"},null,8,["modelValue","accounts","disabled","groups"])]),e("div",null,[l[101]||(l[101]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Bedrock 专属账号",-1)),le(Ae,{modelValue:s.bedrockAccountId,"onUpdate:modelValue":l[41]||(l[41]=y=>s.bedrockAccountId=y),accounts:T.value.bedrock,"default-option-text":"使用共享账号池",disabled:s.permissions!=="all"&&s.permissions!=="openai",groups:[],placeholder:"请选择Bedrock账号",platform:"bedrock"},null,8,["modelValue","accounts","disabled"])]),e("div",null,[l[102]||(l[102]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Droid 专属账号",-1)),le(Ae,{modelValue:s.droidAccountId,"onUpdate:modelValue":l[42]||(l[42]=y=>s.droidAccountId=y),accounts:T.value.droid,"default-option-text":"使用共享账号池",disabled:s.permissions!=="all"&&s.permissions!=="droid",groups:T.value.droidGroups,placeholder:"请选择Droid账号",platform:"droid"},null,8,["modelValue","accounts","disabled","groups"])])]),l[103]||(l[103]=e("p",{class:"mt-2 text-xs text-gray-500 dark:text-gray-400"}," 选择专属账号后,此API Key将只使用该账号,不选择则使用共享账号池 ",-1))]),e("div",null,[e("div",Vr,[_(e("input",{id:"enableModelRestriction","onUpdate:modelValue":l[43]||(l[43]=y=>s.enableModelRestriction=y),class:"h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-blue-500",type:"checkbox"},null,512),[[Te,s.enableModelRestriction]]),l[104]||(l[104]=e("label",{class:"ml-2 cursor-pointer text-sm font-semibold text-gray-700 dark:text-gray-300",for:"enableModelRestriction"}," 启用模型限制 ",-1))]),s.enableModelRestriction?(i(),d("div",Rr,[e("div",null,[l[107]||(l[107]=e("label",{class:"mb-2 block text-sm font-medium text-gray-600"},"限制的模型列表",-1)),e("div",Er,[(i(!0),d(te,null,oe(s.restrictedModels,(y,ae)=>(i(),d("span",{key:ae,class:"inline-flex items-center rounded-full bg-red-100 px-3 py-1 text-sm text-red-800"},[A(u(y)+" ",1),e("button",{class:"ml-2 text-red-600 hover:text-red-800",type:"button",onClick:ue=>ie(ae)},l[105]||(l[105]=[e("i",{class:"fas fa-times text-xs"},null,-1)]),8,Or)]))),128)),s.restrictedModels.length===0?(i(),d("span",jr," 暂无限制的模型 ")):h("",!0)]),e("div",Gr,[e("div",qr,[(i(!0),d(te,null,oe(pe.value,y=>(i(),d("button",{key:y,class:"flex-shrink-0 rounded-lg bg-gray-100 px-3 py-1 text-xs text-gray-700 transition-colors hover:bg-gray-200 sm:text-sm",type:"button",onClick:ae=>X(y)},u(y),9,zr))),128)),pe.value.length===0?(i(),d("span",Fr," 所有常用模型已在限制列表中 ")):h("",!0)]),e("div",Br,[_(e("input",{"onUpdate:modelValue":l[44]||(l[44]=y=>s.modelInput=y),class:"form-input flex-1",placeholder:"输入模型名称,按回车添加",type:"text",onKeydown:et(Ce(se,["prevent"]),["enter"])},null,40,Wr),[[ee,s.modelInput]]),e("button",{class:"rounded-lg bg-red-500 px-4 py-2 text-white transition-colors hover:bg-red-600",type:"button",onClick:se},l[106]||(l[106]=[e("i",{class:"fas fa-plus"},null,-1)]))])]),l[108]||(l[108]=e("p",{class:"mt-2 text-xs text-gray-500"}," 设置此API Key无法访问的模型,例如:claude-opus-4-20250514 ",-1))])])):h("",!0)]),e("div",null,[e("div",Nr,[_(e("input",{id:"enableClientRestriction","onUpdate:modelValue":l[45]||(l[45]=y=>s.enableClientRestriction=y),class:"h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-blue-500",type:"checkbox"},null,512),[[Te,s.enableClientRestriction]]),l[109]||(l[109]=e("label",{class:"ml-2 cursor-pointer text-sm font-semibold text-gray-700 dark:text-gray-300",for:"enableClientRestriction"}," 启用客户端限制 ",-1))]),s.enableClientRestriction?(i(),d("div",Hr,[e("div",null,[l[110]||(l[110]=e("label",{class:"mb-2 block text-xs font-medium text-gray-700 dark:text-gray-300"},"允许的客户端",-1)),e("div",Yr,[(i(!0),d(te,null,oe(p.value,y=>(i(),d("div",{key:y.id,class:"flex items-start"},[_(e("input",{id:`client_${y.id}`,"onUpdate:modelValue":l[46]||(l[46]=ae=>s.allowedClients=ae),class:"mt-0.5 h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-blue-500",type:"checkbox",value:y.id},null,8,Qr),[[Te,s.allowedClients]]),e("label",{class:"ml-2 flex-1 cursor-pointer",for:`client_${y.id}`},[e("span",Xr,u(y.name),1),e("span",Zr,u(y.description),1)],8,Jr)]))),128))])])])):h("",!0)]),e("div",eo,[e("button",{class:"flex-1 rounded-lg bg-gray-100 px-4 py-2.5 text-sm font-semibold text-gray-700 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:l[47]||(l[47]=y=>g.$emit("close"))}," 取消 "),e("button",{class:"btn btn-primary flex-1 px-4 py-2.5 text-sm font-semibold",disabled:U.value,type:"submit"},[U.value?(i(),d("div",so)):(i(),d("i",ao)),A(" "+u(U.value?"创建中...":"创建"),1)],8,to)])],32)])])]))}},oo=_e(ro,[["__scopeId","data-v-4adaa454"]]),lo={class:"modal fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4"},io={class:"modal-content mx-auto flex max-h-[90vh] w-full max-w-4xl flex-col p-4 sm:p-6 md:p-8"},no={class:"mb-4 flex items-center justify-between sm:mb-6"},uo=["value"],co={key:0,class:"text-gray-500"},go={class:"space-y-4"},po={key:0},mo={class:"flex flex-wrap gap-2"},xo=["onClick"],yo={key:1},fo={class:"flex flex-wrap gap-2"},bo=["onClick"],vo={class:"flex gap-2"},ko=["onKeypress"],wo={class:"rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-700 dark:bg-blue-900/20"},ho={class:"space-y-2"},Ao={class:"grid grid-cols-1 gap-2 lg:grid-cols-3"},$o={class:"space-y-3"},Co={class:"flex gap-2"},Io={class:"space-y-3"},Ko={class:"flex gap-2"},Lo={class:"space-y-3"},Do={class:"flex gap-2"},_o={class:"mb-3 flex items-center"},So={class:"flex gap-4"},To={class:"flex cursor-pointer items-center"},Po={class:"flex cursor-pointer items-center"},Uo={class:"flex cursor-pointer items-center"},Mo={class:"flex cursor-pointer items-center"},Vo={class:"flex cursor-pointer items-center"},Ro={class:"mb-3 flex items-center justify-between"},Eo=["disabled"],Oo={class:"grid grid-cols-1 gap-3"},jo={class:"mb-3 flex items-center"},Go={key:0,class:"space-y-3"},qo={class:"mb-3 flex min-h-[32px] flex-wrap gap-2 rounded-lg border border-gray-200 bg-gray-50 p-2 dark:border-gray-600 dark:bg-gray-700"},zo=["onClick"],Fo={key:0,class:"text-sm text-gray-400 dark:text-gray-500"},Bo={class:"space-y-3"},Wo={class:"flex flex-wrap gap-2"},No=["onClick"],Ho={key:0,class:"text-sm italic text-gray-400 dark:text-gray-500"},Yo={class:"flex gap-2"},Qo=["onKeydown"],Jo={class:"mb-3 flex items-center"},Xo={key:0,class:"space-y-3"},Zo={class:"space-y-2"},el=["id","value"],tl=["for"],sl={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},al={class:"block text-xs text-gray-500 dark:text-gray-400"},rl={class:"flex gap-3 pt-4"},ol=["disabled"],ll={key:0,class:"loading-spinner mr-2"},il={key:1,class:"fas fa-save mr-2"},nl={__name:"EditApiKeyModal",props:{apiKey:{type:Object,required:!0},accounts:{type:Object,default:()=>({claude:[],gemini:[],openai:[],bedrock:[],droid:[],claudeGroups:[],geminiGroups:[],openaiGroups:[],droidGroups:[],openaiResponses:[]})}},emits:["close","success"],setup(v,{emit:H}){const c=v,M=H,N=Lt(),$=Dt(),U=D(!1),B=D(!1),T=D({claude:[],gemini:[],openai:[],bedrock:[],droid:[],claudeGroups:[],geminiGroups:[],openaiGroups:[],droidGroups:[]}),J=D([]),Y=D([]),f=D(""),L=D([]),p=R(()=>L.value.filter(k=>!s.tags.includes(k))),s=ze({name:"",tokenLimit:"",rateLimitWindow:"",rateLimitRequests:"",rateLimitCost:"",concurrencyLimit:"",dailyCostLimit:"",totalCostLimit:"",weeklyOpusCostLimit:"",permissions:"all",claudeAccountId:"",geminiAccountId:"",openaiAccountId:"",bedrockAccountId:"",droidAccountId:"",enableModelRestriction:!1,restrictedModels:[],modelInput:"",enableClientRestriction:!1,allowedClients:[],tags:[],isActive:!0,ownerId:""}),V=()=>{s.modelInput&&!s.restrictedModels.includes(s.modelInput)&&(s.restrictedModels.push(s.modelInput),s.modelInput="")},S=k=>{s.restrictedModels.splice(k,1)},W=D(["claude-opus-4-20250514","claude-opus-4-1-20250805"]),I=R(()=>W.value.filter(k=>!s.restrictedModels.includes(k))),K=k=>{s.restrictedModels.includes(k)||s.restrictedModels.push(k)},se=()=>{if(f.value&&f.value.trim()){const k=f.value.trim();s.tags.includes(k)||s.tags.push(k),f.value=""}},ie=k=>{s.tags.includes(k)||s.tags.push(k)},de=k=>{s.tags.splice(k,1)},pe=async()=>{if(s.rateLimitWindow&&(!s.rateLimitCost||parseFloat(s.rateLimitCost)===0)){let k=!1;if(window.showConfirm?k=await window.showConfirm("费用限制提醒",`您设置了时间窗口但费用限制为0,这意味着不会有费用限制。
|
||
|
||
是否继续?`,"继续保存","返回修改"):k=confirm(`您设置了时间窗口但费用限制为0,这意味着不会有费用限制。
|
||
是否继续?`),!k)return}U.value=!0;try{const k={name:s.name,tokenLimit:0,rateLimitWindow:s.rateLimitWindow!==""&&s.rateLimitWindow!==null?parseInt(s.rateLimitWindow):0,rateLimitRequests:s.rateLimitRequests!==""&&s.rateLimitRequests!==null?parseInt(s.rateLimitRequests):0,rateLimitCost:s.rateLimitCost!==""&&s.rateLimitCost!==null?parseFloat(s.rateLimitCost):0,concurrencyLimit:s.concurrencyLimit!==""&&s.concurrencyLimit!==null?parseInt(s.concurrencyLimit):0,dailyCostLimit:s.dailyCostLimit!==""&&s.dailyCostLimit!==null?parseFloat(s.dailyCostLimit):0,totalCostLimit:s.totalCostLimit!==""&&s.totalCostLimit!==null?parseFloat(s.totalCostLimit):0,weeklyOpusCostLimit:s.weeklyOpusCostLimit!==""&&s.weeklyOpusCostLimit!==null?parseFloat(s.weeklyOpusCostLimit):0,permissions:s.permissions,tags:s.tags};s.claudeAccountId?s.claudeAccountId.startsWith("console:")?(k.claudeConsoleAccountId=s.claudeAccountId.substring(8),k.claudeAccountId=null):(s.claudeAccountId.startsWith("group:"),k.claudeAccountId=s.claudeAccountId,k.claudeConsoleAccountId=null):(k.claudeAccountId=null,k.claudeConsoleAccountId=null),s.geminiAccountId?k.geminiAccountId=s.geminiAccountId:k.geminiAccountId=null,s.openaiAccountId?k.openaiAccountId=s.openaiAccountId:k.openaiAccountId=null,s.bedrockAccountId?k.bedrockAccountId=s.bedrockAccountId:k.bedrockAccountId=null,s.droidAccountId?k.droidAccountId=s.droidAccountId:k.droidAccountId=null,k.enableModelRestriction=s.enableModelRestriction,k.restrictedModels=s.restrictedModels,k.enableClientRestriction=s.enableClientRestriction,k.allowedClients=s.allowedClients,k.isActive=s.isActive,s.ownerId!==void 0&&(k.ownerId=s.ownerId);const o=await q.put(`/admin/api-keys/${c.apiKey.id}`,k);o.success?(M("success"),M("close")):O(o.message||"更新失败","error")}catch{O("更新失败","error")}finally{U.value=!1}},X=async()=>{var k,o;B.value=!0;try{const[n,m,C,g,l,y,ae,ue,ge]=await Promise.all([q.get("/admin/claude-accounts"),q.get("/admin/claude-console-accounts"),q.get("/admin/gemini-accounts"),q.get("/admin/gemini-api-accounts"),q.get("/admin/openai-accounts"),q.get("/admin/openai-responses-accounts"),q.get("/admin/bedrock-accounts"),q.get("/admin/droid-accounts"),q.get("/admin/account-groups")]),ve=[];n.success&&((k=n.data)==null||k.forEach(Q=>{ve.push({...Q,platform:"claude-oauth",isDedicated:Q.accountType==="dedicated"})})),m.success&&((o=m.data)==null||o.forEach(Q=>{ve.push({...Q,platform:"claude-console",isDedicated:Q.accountType==="dedicated"})})),T.value.claude=ve;const fe=[];C.success&&(C.data||[]).forEach(Q=>{fe.push({...Q,platform:"gemini",isDedicated:Q.accountType==="dedicated"})}),g.success&&(g.data||[]).forEach(Q=>{fe.push({...Q,platform:"gemini-api",isDedicated:Q.accountType==="dedicated"})}),T.value.gemini=fe;const F=[];if(l.success&&(l.data||[]).forEach(Q=>{F.push({...Q,platform:"openai",isDedicated:Q.accountType==="dedicated"})}),y.success&&(y.data||[]).forEach(Q=>{F.push({...Q,platform:"openai-responses",isDedicated:Q.accountType==="dedicated"})}),T.value.openai=F,ae.success&&(T.value.bedrock=(ae.data||[]).map(Q=>({...Q,isDedicated:Q.accountType==="dedicated"}))),ue.success&&(T.value.droid=(ue.data||[]).map(Q=>({...Q,platform:"droid",isDedicated:Q.accountType==="dedicated"}))),ge.success){const Q=ge.data||[];T.value.claudeGroups=Q.filter(me=>me.platform==="claude"),T.value.geminiGroups=Q.filter(me=>me.platform==="gemini"),T.value.openaiGroups=Q.filter(me=>me.platform==="openai"),T.value.droidGroups=Q.filter(me=>me.platform==="droid")}O("账号列表已刷新","success")}catch{O("刷新账号列表失败","error")}finally{B.value=!1}},be=async()=>{try{const k=await q.get("/admin/users");k.success&&(Y.value=k.data||[])}catch{Y.value=[{id:"admin",username:"admin",displayName:"Admin",email:"",role:"admin"}]}};return st(async()=>{try{const[k,o]=await Promise.all([N.loadSupportedClients(),$.fetchTags(),be()]);J.value=k||[],L.value=o||[]}catch{J.value=[],L.value=[]}if(c.accounts){const k=[];c.accounts.gemini&&c.accounts.gemini.forEach(n=>{k.push({...n,platform:"gemini"})}),c.accounts.geminiApi&&c.accounts.geminiApi.forEach(n=>{k.push({...n,platform:"gemini-api"})});const o=[];c.accounts.openai&&c.accounts.openai.forEach(n=>{o.push({...n,platform:"openai"})}),c.accounts.openaiResponses&&c.accounts.openaiResponses.forEach(n=>{o.push({...n,platform:"openai-responses"})}),T.value={claude:c.accounts.claude||[],gemini:k,openai:o,bedrock:c.accounts.bedrock||[],droid:(c.accounts.droid||[]).map(n=>({...n,platform:"droid"})),claudeGroups:c.accounts.claudeGroups||[],geminiGroups:c.accounts.geminiGroups||[],openaiGroups:c.accounts.openaiGroups||[],droidGroups:c.accounts.droidGroups||[]}}await X(),s.name=c.apiKey.name,s.tokenLimit=c.apiKey.tokenLimit||"",s.rateLimitCost=c.apiKey.rateLimitCost||"",c.apiKey.tokenLimit>0&&c.apiKey.rateLimitCost,s.rateLimitWindow=c.apiKey.rateLimitWindow||"",s.rateLimitRequests=c.apiKey.rateLimitRequests||"",s.concurrencyLimit=c.apiKey.concurrencyLimit||"",s.dailyCostLimit=c.apiKey.dailyCostLimit||"",s.totalCostLimit=c.apiKey.totalCostLimit||"",s.weeklyOpusCostLimit=c.apiKey.weeklyOpusCostLimit||"",s.permissions=c.apiKey.permissions||"all",c.apiKey.claudeConsoleAccountId?s.claudeAccountId=`console:${c.apiKey.claudeConsoleAccountId}`:s.claudeAccountId=c.apiKey.claudeAccountId||"",s.geminiAccountId=c.apiKey.geminiAccountId||"",s.openaiAccountId=c.apiKey.openaiAccountId||"",s.bedrockAccountId=c.apiKey.bedrockAccountId||"",s.droidAccountId=c.apiKey.droidAccountId||"",s.restrictedModels=c.apiKey.restrictedModels||[],s.allowedClients=c.apiKey.allowedClients||[],s.tags=c.apiKey.tags||[],s.enableModelRestriction=c.apiKey.enableModelRestriction||!1,s.enableClientRestriction=c.apiKey.enableClientRestriction||!1,s.isActive=c.apiKey.isActive!==void 0?c.apiKey.isActive:!0,s.ownerId=c.apiKey.userId||"admin"}),(k,o)=>(i(),ye(Ue,{to:"body"},[e("div",lo,[e("div",io,[e("div",no,[o[40]||(o[40]=e("div",{class:"flex items-center gap-2 sm:gap-3"},[e("div",{class:"flex h-8 w-8 items-center justify-center rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 sm:h-10 sm:w-10 sm:rounded-xl"},[e("i",{class:"fas fa-edit text-sm text-white sm:text-base"})]),e("h3",{class:"text-lg font-bold text-gray-900 dark:text-gray-100 sm:text-xl"}," 编辑 API Key ")],-1)),e("button",{class:"p-1 text-gray-400 transition-colors hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",onClick:o[0]||(o[0]=n=>k.$emit("close"))},o[39]||(o[39]=[e("i",{class:"fas fa-times text-lg sm:text-xl"},null,-1)]))]),e("form",{class:"modal-scroll-content custom-scrollbar flex-1 space-y-4 sm:space-y-6",onSubmit:Ce(pe,["prevent"])},[e("div",null,[o[41]||(o[41]=e("label",{class:"mb-1.5 block text-xs font-semibold text-gray-700 dark:text-gray-300 sm:mb-3 sm:text-sm"},"名称",-1)),e("div",null,[_(e("input",{"onUpdate:modelValue":o[1]||(o[1]=n=>s.name=n),class:"form-input flex-1 border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",maxlength:"100",placeholder:"请输入API Key名称",required:"",type:"text"},null,512),[[ee,s.name]])]),o[42]||(o[42]=e("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400 sm:mt-2"}," 用于识别此 API Key 的用途 ",-1))]),e("div",null,[o[43]||(o[43]=e("label",{class:"mb-1.5 block text-xs font-semibold text-gray-700 dark:text-gray-300 sm:mb-3 sm:text-sm"},"所有者",-1)),_(e("select",{"onUpdate:modelValue":o[2]||(o[2]=n=>s.ownerId=n),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200"},[(i(!0),d(te,null,oe(Y.value,n=>(i(),d("option",{key:n.id,value:n.id},[A(u(n.displayName)+" ("+u(n.username)+") ",1),n.role==="admin"?(i(),d("span",co,"- 管理员")):h("",!0)],8,uo))),128))],512),[[tt,s.ownerId]]),o[44]||(o[44]=e("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400 sm:mt-2"}," 分配此 API Key 给指定用户或管理员,管理员分配时不受用户 API Key 数量限制 ",-1))]),e("div",null,[o[52]||(o[52]=e("label",{class:"mb-1.5 block text-xs font-semibold text-gray-700 dark:text-gray-300 sm:mb-3 sm:text-sm"},"标签",-1)),e("div",go,[s.tags.length>0?(i(),d("div",po,[o[46]||(o[46]=e("div",{class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"}," 已选择的标签: ",-1)),e("div",mo,[(i(!0),d(te,null,oe(s.tags,(n,m)=>(i(),d("span",{key:"selected-"+m,class:"inline-flex items-center gap-1 rounded-full bg-blue-100 px-3 py-1 text-sm text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"},[A(u(n)+" ",1),e("button",{class:"ml-1 hover:text-blue-900 dark:hover:text-blue-300",type:"button",onClick:C=>de(m)},o[45]||(o[45]=[e("i",{class:"fas fa-times text-xs"},null,-1)]),8,xo)]))),128))])])):h("",!0),p.value.length>0?(i(),d("div",yo,[o[48]||(o[48]=e("div",{class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"}," 点击选择已有标签: ",-1)),e("div",fo,[(i(!0),d(te,null,oe(p.value,n=>(i(),d("button",{key:"available-"+n,class:"inline-flex items-center gap-1 rounded-full bg-gray-100 px-3 py-1 text-sm text-gray-700 transition-colors hover:bg-blue-100 hover:text-blue-700 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-blue-900/30 dark:hover:text-blue-400",type:"button",onClick:m=>ie(n)},[o[47]||(o[47]=e("i",{class:"fas fa-tag text-xs text-gray-500 dark:text-gray-400"},null,-1)),A(" "+u(n),1)],8,bo))),128))])])):h("",!0),e("div",null,[o[50]||(o[50]=e("div",{class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"}," 创建新标签: ",-1)),e("div",vo,[_(e("input",{"onUpdate:modelValue":o[3]||(o[3]=n=>f.value=n),class:"form-input flex-1 border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",placeholder:"输入新标签名称",type:"text",onKeypress:et(Ce(se,["prevent"]),["enter"])},null,40,ko),[[ee,f.value]]),e("button",{class:"rounded-lg bg-green-500 px-4 py-2 text-white transition-colors hover:bg-green-600",type:"button",onClick:se},o[49]||(o[49]=[e("i",{class:"fas fa-plus"},null,-1)]))])]),o[51]||(o[51]=e("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," 用于标记不同团队或用途,方便筛选管理 ",-1))])]),e("div",wo,[o[60]||(o[60]=e("div",{class:"mb-2 flex items-center gap-2"},[e("div",{class:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded bg-blue-500"},[e("i",{class:"fas fa-tachometer-alt text-xs text-white"})]),e("h4",{class:"text-sm font-semibold text-gray-800 dark:text-gray-200"}," 速率限制设置 (可选) ")],-1)),e("div",ho,[e("div",Ao,[e("div",null,[o[53]||(o[53]=e("label",{class:"mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300"},"时间窗口 (分钟)",-1)),_(e("input",{"onUpdate:modelValue":o[4]||(o[4]=n=>s.rateLimitWindow=n),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"1",placeholder:"无限制",type:"number"},null,512),[[ee,s.rateLimitWindow]]),o[54]||(o[54]=e("p",{class:"ml-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400"},"时间段单位",-1))]),e("div",null,[o[55]||(o[55]=e("label",{class:"mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300"},"请求次数限制",-1)),_(e("input",{"onUpdate:modelValue":o[5]||(o[5]=n=>s.rateLimitRequests=n),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"1",placeholder:"无限制",type:"number"},null,512),[[ee,s.rateLimitRequests]]),o[56]||(o[56]=e("p",{class:"ml-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400"},"窗口内最大请求",-1))]),e("div",null,[o[57]||(o[57]=e("label",{class:"mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300"},"费用限制 (美元)",-1)),_(e("input",{"onUpdate:modelValue":o[6]||(o[6]=n=>s.rateLimitCost=n),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"0",placeholder:"无限制",step:"0.01",type:"number"},null,512),[[ee,s.rateLimitCost]]),o[58]||(o[58]=e("p",{class:"ml-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400"},"窗口内最大费用",-1))])]),o[59]||(o[59]=e("div",{class:"rounded-lg bg-blue-100 p-2 dark:bg-blue-900/30"},[e("h5",{class:"mb-1 text-xs font-semibold text-blue-800 dark:text-blue-400"}," 💡 使用示例 "),e("div",{class:"space-y-0.5 text-xs text-blue-700 dark:text-blue-300"},[e("div",null,[e("strong",null,"示例1:"),A(" 时间窗口=60,请求次数=1000 → 每60分钟最多1000次请求 ")]),e("div",null,[e("strong",null,"示例2:"),A(" 时间窗口=1,费用=0.1 → 每分钟最多$0.1费用")]),e("div",null,[e("strong",null,"示例3:"),A(" 窗口=30,请求=50,费用=5 → 每30分钟50次请求且不超$5费用 ")])])],-1))])]),e("div",null,[o[62]||(o[62]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"每日费用限制 (美元)",-1)),e("div",$o,[e("div",Co,[e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[7]||(o[7]=n=>s.dailyCostLimit="50")}," $50 "),e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[8]||(o[8]=n=>s.dailyCostLimit="100")}," $100 "),e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[9]||(o[9]=n=>s.dailyCostLimit="200")}," $200 "),e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[10]||(o[10]=n=>s.dailyCostLimit="")}," 自定义 ")]),_(e("input",{"onUpdate:modelValue":o[11]||(o[11]=n=>s.dailyCostLimit=n),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"0",placeholder:"0 表示无限制",step:"0.01",type:"number"},null,512),[[ee,s.dailyCostLimit]]),o[61]||(o[61]=e("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," 设置此 API Key 每日的费用限制,超过限制将拒绝请求,0 或留空表示无限制 ",-1))])]),e("div",null,[o[64]||(o[64]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"总费用限制 (美元)",-1)),e("div",Io,[e("div",Ko,[e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[12]||(o[12]=n=>s.totalCostLimit="100")}," $100 "),e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[13]||(o[13]=n=>s.totalCostLimit="500")}," $500 "),e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[14]||(o[14]=n=>s.totalCostLimit="1000")}," $1000 "),e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[15]||(o[15]=n=>s.totalCostLimit="")}," 自定义 ")]),_(e("input",{"onUpdate:modelValue":o[16]||(o[16]=n=>s.totalCostLimit=n),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"0",placeholder:"0 表示无限制",step:"0.01",type:"number"},null,512),[[ee,s.totalCostLimit]]),o[63]||(o[63]=e("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," 设置此 API Key 的累计总费用限制,达到限制后将拒绝所有后续请求,0 或留空表示无限制 ",-1))])]),e("div",null,[o[66]||(o[66]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"Opus 模型周费用限制 (美元)",-1)),e("div",Lo,[e("div",Do,[e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[17]||(o[17]=n=>s.weeklyOpusCostLimit="100")}," $100 "),e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[18]||(o[18]=n=>s.weeklyOpusCostLimit="500")}," $500 "),e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[19]||(o[19]=n=>s.weeklyOpusCostLimit="1000")}," $1000 "),e("button",{class:"rounded-lg bg-gray-100 px-3 py-1 text-sm font-medium hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[20]||(o[20]=n=>s.weeklyOpusCostLimit="")}," 自定义 ")]),_(e("input",{"onUpdate:modelValue":o[21]||(o[21]=n=>s.weeklyOpusCostLimit=n),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"0",placeholder:"0 表示无限制",step:"0.01",type:"number"},null,512),[[ee,s.weeklyOpusCostLimit]]),o[65]||(o[65]=e("p",{class:"text-xs text-gray-500 dark:text-gray-400"}," 设置 Opus 模型的周费用限制(周一到周日),仅限 Claude 官方账户,0 或留空表示无限制 ",-1))])]),e("div",null,[o[67]||(o[67]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"并发限制",-1)),_(e("input",{"onUpdate:modelValue":o[22]||(o[22]=n=>s.concurrencyLimit=n),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",min:"0",placeholder:"0 表示无限制",type:"number"},null,512),[[ee,s.concurrencyLimit]]),o[68]||(o[68]=e("p",{class:"mt-2 text-xs text-gray-500 dark:text-gray-400"}," 设置此 API Key 可同时处理的最大请求数 ",-1))]),e("div",null,[e("div",_o,[_(e("input",{id:"editIsActive","onUpdate:modelValue":o[23]||(o[23]=n=>s.isActive=n),class:"h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"checkbox"},null,512),[[Te,s.isActive]]),o[69]||(o[69]=e("label",{class:"ml-2 cursor-pointer text-sm font-semibold text-gray-700 dark:text-gray-300",for:"editIsActive"}," 激活账号 ",-1))]),o[70]||(o[70]=e("p",{class:"mb-4 text-xs text-gray-500 dark:text-gray-400"}," 取消勾选将禁用此 API Key,暂停所有请求,客户端返回 401 错误 ",-1))]),e("div",null,[o[76]||(o[76]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"服务权限",-1)),e("div",So,[e("label",To,[_(e("input",{"onUpdate:modelValue":o[24]||(o[24]=n=>s.permissions=n),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"all"},null,512),[[ne,s.permissions]]),o[71]||(o[71]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"全部服务",-1))]),e("label",Po,[_(e("input",{"onUpdate:modelValue":o[25]||(o[25]=n=>s.permissions=n),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"claude"},null,512),[[ne,s.permissions]]),o[72]||(o[72]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"仅 Claude",-1))]),e("label",Uo,[_(e("input",{"onUpdate:modelValue":o[26]||(o[26]=n=>s.permissions=n),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"gemini"},null,512),[[ne,s.permissions]]),o[73]||(o[73]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"仅 Gemini",-1))]),e("label",Mo,[_(e("input",{"onUpdate:modelValue":o[27]||(o[27]=n=>s.permissions=n),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"openai"},null,512),[[ne,s.permissions]]),o[74]||(o[74]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"仅 OpenAI",-1))]),e("label",Vo,[_(e("input",{"onUpdate:modelValue":o[28]||(o[28]=n=>s.permissions=n),class:"mr-2 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"radio",value:"droid"},null,512),[[ne,s.permissions]]),o[75]||(o[75]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"仅 Droid",-1))])]),o[77]||(o[77]=e("p",{class:"mt-2 text-xs text-gray-500 dark:text-gray-400"}," 控制此 API Key 可以访问哪些服务 ",-1))]),e("div",null,[e("div",Ro,[o[78]||(o[78]=e("label",{class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},"专属账号绑定",-1)),e("button",{class:"flex items-center gap-1 text-sm text-blue-600 transition-colors hover:text-blue-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-blue-400 dark:hover:text-blue-300",disabled:B.value,title:"刷新账号列表",type:"button",onClick:X},[e("i",{class:z(["fas",B.value?"fa-spinner fa-spin":"fa-sync-alt","text-xs"])},null,2),e("span",null,u(B.value?"刷新中...":"刷新账号"),1)],8,Eo)]),e("div",Oo,[e("div",null,[o[79]||(o[79]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Claude 专属账号",-1)),le(Ae,{modelValue:s.claudeAccountId,"onUpdate:modelValue":o[29]||(o[29]=n=>s.claudeAccountId=n),accounts:T.value.claude,"default-option-text":"使用共享账号池",disabled:s.permissions!=="all"&&s.permissions!=="claude",groups:T.value.claudeGroups,placeholder:"请选择Claude账号",platform:"claude"},null,8,["modelValue","accounts","disabled","groups"])]),e("div",null,[o[80]||(o[80]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Gemini 专属账号",-1)),le(Ae,{modelValue:s.geminiAccountId,"onUpdate:modelValue":o[30]||(o[30]=n=>s.geminiAccountId=n),accounts:T.value.gemini,"default-option-text":"使用共享账号池",disabled:s.permissions!=="all"&&s.permissions!=="gemini",groups:T.value.geminiGroups,placeholder:"请选择Gemini账号",platform:"gemini"},null,8,["modelValue","accounts","disabled","groups"])]),e("div",null,[o[81]||(o[81]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"OpenAI 专属账号",-1)),le(Ae,{modelValue:s.openaiAccountId,"onUpdate:modelValue":o[31]||(o[31]=n=>s.openaiAccountId=n),accounts:T.value.openai,"default-option-text":"使用共享账号池",disabled:s.permissions!=="all"&&s.permissions!=="openai",groups:T.value.openaiGroups,placeholder:"请选择OpenAI账号",platform:"openai"},null,8,["modelValue","accounts","disabled","groups"])]),e("div",null,[o[82]||(o[82]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Bedrock 专属账号",-1)),le(Ae,{modelValue:s.bedrockAccountId,"onUpdate:modelValue":o[32]||(o[32]=n=>s.bedrockAccountId=n),accounts:T.value.bedrock,"default-option-text":"使用共享账号池",disabled:s.permissions!=="all"&&s.permissions!=="openai",groups:[],placeholder:"请选择Bedrock账号",platform:"bedrock"},null,8,["modelValue","accounts","disabled"])]),e("div",null,[o[83]||(o[83]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Droid 专属账号",-1)),le(Ae,{modelValue:s.droidAccountId,"onUpdate:modelValue":o[33]||(o[33]=n=>s.droidAccountId=n),accounts:T.value.droid,"default-option-text":"使用共享账号池",disabled:s.permissions!=="all"&&s.permissions!=="droid",groups:T.value.droidGroups,placeholder:"请选择Droid账号",platform:"droid"},null,8,["modelValue","accounts","disabled","groups"])])]),o[84]||(o[84]=e("p",{class:"mt-2 text-xs text-gray-500 dark:text-gray-400"}," 修改绑定账号将影响此API Key的请求路由 ",-1))]),e("div",null,[e("div",jo,[_(e("input",{id:"editEnableModelRestriction","onUpdate:modelValue":o[34]||(o[34]=n=>s.enableModelRestriction=n),class:"h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"checkbox"},null,512),[[Te,s.enableModelRestriction]]),o[85]||(o[85]=e("label",{class:"ml-2 cursor-pointer text-sm font-semibold text-gray-700 dark:text-gray-300",for:"editEnableModelRestriction"}," 启用模型限制 ",-1))]),s.enableModelRestriction?(i(),d("div",Go,[e("div",null,[o[88]||(o[88]=e("label",{class:"mb-2 block text-sm font-medium text-gray-600 dark:text-gray-400"},"限制的模型列表",-1)),e("div",qo,[(i(!0),d(te,null,oe(s.restrictedModels,(n,m)=>(i(),d("span",{key:m,class:"inline-flex items-center rounded-full bg-red-100 px-3 py-1 text-sm text-red-800 dark:bg-red-900/30 dark:text-red-400"},[A(u(n)+" ",1),e("button",{class:"ml-2 text-red-600 hover:text-red-800 dark:text-red-400 dark:hover:text-red-300",type:"button",onClick:C=>S(m)},o[86]||(o[86]=[e("i",{class:"fas fa-times text-xs"},null,-1)]),8,zo)]))),128)),s.restrictedModels.length===0?(i(),d("span",Fo," 暂无限制的模型 ")):h("",!0)]),e("div",Bo,[e("div",Wo,[(i(!0),d(te,null,oe(I.value,n=>(i(),d("button",{key:n,class:"flex-shrink-0 rounded-lg bg-gray-100 px-3 py-1 text-xs text-gray-700 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600 sm:text-sm",type:"button",onClick:m=>K(n)},u(n),9,No))),128)),I.value.length===0?(i(),d("span",Ho," 所有常用模型已在限制列表中 ")):h("",!0)]),e("div",Yo,[_(e("input",{"onUpdate:modelValue":o[35]||(o[35]=n=>s.modelInput=n),class:"form-input flex-1 border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:placeholder-gray-400",placeholder:"输入模型名称,按回车添加",type:"text",onKeydown:et(Ce(V,["prevent"]),["enter"])},null,40,Qo),[[ee,s.modelInput]]),e("button",{class:"rounded-lg bg-red-500 px-4 py-2 text-white transition-colors hover:bg-red-600",type:"button",onClick:V},o[87]||(o[87]=[e("i",{class:"fas fa-plus"},null,-1)]))])]),o[89]||(o[89]=e("p",{class:"mt-2 text-xs text-gray-500 dark:text-gray-400"}," 设置此API Key无法访问的模型,例如:claude-opus-4-20250514 ",-1))])])):h("",!0)]),e("div",null,[e("div",Jo,[_(e("input",{id:"editEnableClientRestriction","onUpdate:modelValue":o[36]||(o[36]=n=>s.enableClientRestriction=n),class:"h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700",type:"checkbox"},null,512),[[Te,s.enableClientRestriction]]),o[90]||(o[90]=e("label",{class:"ml-2 cursor-pointer text-sm font-semibold text-gray-700 dark:text-gray-300",for:"editEnableClientRestriction"}," 启用客户端限制 ",-1))]),s.enableClientRestriction?(i(),d("div",Xo,[e("div",null,[o[91]||(o[91]=e("label",{class:"mb-2 block text-sm font-medium text-gray-600 dark:text-gray-400"},"允许的客户端",-1)),o[92]||(o[92]=e("p",{class:"mb-3 text-xs text-gray-500 dark:text-gray-400"}," 勾选允许使用此API Key的客户端 ",-1)),e("div",Zo,[(i(!0),d(te,null,oe(J.value,n=>(i(),d("div",{key:n.id,class:"flex items-start"},[_(e("input",{id:`edit_client_${n.id}`,"onUpdate:modelValue":o[37]||(o[37]=m=>s.allowedClients=m),class:"mt-0.5 h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-blue-500",type:"checkbox",value:n.id},null,8,el),[[Te,s.allowedClients]]),e("label",{class:"ml-2 flex-1 cursor-pointer",for:`edit_client_${n.id}`},[e("span",sl,u(n.name),1),e("span",al,u(n.description),1)],8,tl)]))),128))])])])):h("",!0)]),e("div",rl,[e("button",{class:"flex-1 rounded-xl bg-gray-100 px-6 py-3 font-semibold text-gray-700 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:o[38]||(o[38]=n=>k.$emit("close"))}," 取消 "),e("button",{class:"btn btn-primary flex-1 px-6 py-3 font-semibold",disabled:U.value,type:"submit"},[U.value?(i(),d("div",ll)):(i(),d("i",il)),A(" "+u(U.value?"保存中...":"保存修改"),1)],8,ol)])],32)])])]))}},dl=_e(nl,[["__scopeId","data-v-d0cd0aca"]]),ul={class:"modal fixed inset-0 z-50 flex items-center justify-center p-4"},cl={class:"modal-content mx-auto flex max-h-[90vh] w-full max-w-md flex-col p-8"},gl={class:"mb-6 flex items-center justify-between"},pl={class:"modal-scroll-content custom-scrollbar flex-1 space-y-6"},ml={class:"rounded-lg border border-blue-200 bg-blue-50 p-4"},xl={class:"flex items-start gap-3"},yl={class:"text-sm text-gray-700"},fl={class:"mt-1 text-xs text-gray-600"},bl={key:0,class:"mt-3"},vl=["min"],kl={key:1,class:"mt-2 text-xs text-gray-500"},wl={class:"flex gap-3 pt-4"},hl=["disabled"],Al={key:0,class:"loading-spinner mr-2"},$l={key:1,class:"fas fa-clock mr-2"},Cl={__name:"RenewApiKeyModal",props:{apiKey:{type:Object,required:!0}},emits:["close","success"],setup(v,{emit:H}){const c=v,M=H,N=D(!1),$=ze({renewDuration:"30d",customExpireDate:"",newExpiresAt:null}),U=R(()=>{const f=new Date;return c.apiKey.expiresAt&&new Date(c.apiKey.expiresAt)>f?new Date(c.apiKey.expiresAt).toISOString().slice(0,16):(f.setMinutes(f.getMinutes()+1),f.toISOString().slice(0,16))}),B=f=>new Date(f).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),T=()=>{if(!$.renewDuration){$.newExpiresAt=null;return}if($.renewDuration==="permanent"){$.newExpiresAt=null;return}if($.renewDuration==="custom")return;const f=c.apiKey.expiresAt&&new Date(c.apiKey.expiresAt)>new Date?new Date(c.apiKey.expiresAt):new Date,p=$.renewDuration.match(/(\d+)([dhmy])/);if(p){const[,s,V]=p,S=parseInt(s);switch(V){case"d":f.setDate(f.getDate()+S);break;case"h":f.setHours(f.getHours()+S);break;case"m":f.setMonth(f.getMonth()+S);break;case"y":f.setFullYear(f.getFullYear()+S);break}$.newExpiresAt=f.toISOString()}},J=()=>{$.customExpireDate&&($.newExpiresAt=new Date($.customExpireDate).toISOString())},Y=async()=>{N.value=!0;try{const f={expiresAt:$.renewDuration==="permanent"?null:$.newExpiresAt},L=await q.put(`/admin/api-keys/${c.apiKey.id}`,f);L.success?(O("API Key 续期成功","success"),M("success"),M("close")):O(L.message||"续期失败","error")}catch{O("续期失败","error")}finally{N.value=!1}};return T(),(f,L)=>(i(),ye(Ue,{to:"body"},[e("div",ul,[e("div",cl,[e("div",gl,[L[5]||(L[5]=e("div",{class:"flex items-center gap-3"},[e("div",{class:"flex h-10 w-10 items-center justify-center rounded-xl bg-gradient-to-br from-green-500 to-green-600"},[e("i",{class:"fas fa-clock text-white"})]),e("h3",{class:"text-xl font-bold text-gray-900"},"续期 API Key")],-1)),e("button",{class:"text-gray-400 transition-colors hover:text-gray-600",onClick:L[0]||(L[0]=p=>f.$emit("close"))},L[4]||(L[4]=[e("i",{class:"fas fa-times text-xl"},null,-1)]))]),e("div",pl,[e("div",ml,[e("div",xl,[L[7]||(L[7]=e("div",{class:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg bg-blue-500"},[e("i",{class:"fas fa-info text-sm text-white"})],-1)),e("div",null,[L[6]||(L[6]=e("h4",{class:"mb-1 font-semibold text-gray-800"},"API Key 信息",-1)),e("p",yl,u(v.apiKey.name),1),e("p",fl," 当前过期时间:"+u(v.apiKey.expiresAt?B(v.apiKey.expiresAt):"永不过期"),1)])])]),e("div",null,[L[9]||(L[9]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700"},"续期时长",-1)),_(e("select",{"onUpdate:modelValue":L[1]||(L[1]=p=>$.renewDuration=p),class:"form-input w-full",onChange:T},L[8]||(L[8]=[e("option",{value:"7d"},"延长 7 天",-1),e("option",{value:"30d"},"延长 30 天",-1),e("option",{value:"90d"},"延长 90 天",-1),e("option",{value:"180d"},"延长 180 天",-1),e("option",{value:"365d"},"延长 365 天",-1),e("option",{value:"custom"},"自定义日期",-1),e("option",{value:"permanent"},"设为永不过期",-1)]),544),[[tt,$.renewDuration]]),$.renewDuration==="custom"?(i(),d("div",bl,[_(e("input",{"onUpdate:modelValue":L[2]||(L[2]=p=>$.customExpireDate=p),class:"form-input w-full",min:U.value,type:"datetime-local",onChange:J},null,40,vl),[[ee,$.customExpireDate]])])):h("",!0),$.newExpiresAt?(i(),d("p",kl," 新的过期时间:"+u(B($.newExpiresAt)),1)):h("",!0)])]),e("div",wl,[e("button",{class:"flex-1 rounded-xl bg-gray-100 px-6 py-3 font-semibold text-gray-700 transition-colors hover:bg-gray-200",type:"button",onClick:L[3]||(L[3]=p=>f.$emit("close"))}," 取消 "),e("button",{class:"btn btn-primary flex-1 px-6 py-3 font-semibold",disabled:N.value||!$.renewDuration,type:"button",onClick:Y},[N.value?(i(),d("div",Al)):(i(),d("i",$l)),A(" "+u(N.value?"续期中...":"确认续期"),1)],8,hl)])])])]))}},Il=_e(Cl,[["__scopeId","data-v-2fba52a3"]]),Kl={class:"modal fixed inset-0 z-50 flex items-center justify-center p-4"},Ll={class:"modal-content custom-scrollbar mx-auto max-h-[90vh] w-full max-w-lg overflow-y-auto p-8"},Dl={class:"mb-6 space-y-4"},_l={class:"rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-600 dark:bg-gray-800"},Sl={class:"font-medium text-gray-900 dark:text-gray-100"},Tl={key:0},Pl={class:"rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-600 dark:bg-gray-800"},Ul={class:"text-gray-700 dark:text-gray-300"},Ml={class:"relative"},Vl={class:"flex min-h-[60px] items-center break-all rounded-lg border border-gray-700 bg-gray-900 p-4 pr-14 font-mono text-sm text-white dark:border-gray-600 dark:bg-gray-900"},Rl={class:"absolute right-3 top-3"},El=["title"],Ol={__name:"NewApiKeyModal",props:{apiKey:{type:Object,required:!0}},emits:["close"],setup(v,{emit:H}){const c=v,M=H,N=D(!1),$=()=>{if(typeof window<"u"){const s=window.location.protocol,V=window.location.host;let S=s+"//"+V;const W=window.location.href,I=W.indexOf("/",8);return I!==-1&&(S=W.substring(0,I)),S}return""},U=R(()=>$()+"/api"),B=()=>{N.value=!N.value},T=()=>{const s=c.apiKey.apiKey||c.apiKey.key||"";return s?N.value||s.length<=12?s:s.substring(0,8)+"●".repeat(Math.max(0,s.length-12))+s.substring(s.length-4):""},J=async(s,V)=>{try{await navigator.clipboard.writeText(s),O(V,"success")}catch{const W=document.createElement("textarea");W.value=s,document.body.appendChild(W),W.select();try{document.execCommand("copy"),O(V,"success")}catch{O("复制失败,请手动复制","error")}finally{document.body.removeChild(W)}}},Y=async()=>{const s=c.apiKey.apiKey||c.apiKey.key||"";if(!s){O("API Key 不存在","error");return}const V=`ANTHROPIC_BASE_URL="${U.value}"
|
||
ANTHROPIC_AUTH_TOKEN="${s}"`;await J(V,"配置信息已复制到剪贴板")},f=async()=>{const s=c.apiKey.apiKey||c.apiKey.key||"";if(!s){O("API Key 不存在","error");return}await J(s,"API Key 已复制")},L=async()=>{window.showConfirm?await window.showConfirm("关闭提醒",`关闭后将无法再次查看完整的API Key,请确保已经妥善保存。
|
||
|
||
确定要关闭吗?`,"确定关闭","取消")&&M("close"):confirm(`关闭后将无法再次查看完整的API Key,请确保已经妥善保存。
|
||
|
||
确定要关闭吗?`)&&M("close")},p=async()=>{window.showConfirm?await window.showConfirm("确定要关闭吗?",`您还没有保存API Key,关闭后将无法再次查看。
|
||
|
||
建议您先复制API Key再关闭。`,"仍然关闭","返回复制")&&M("close"):confirm(`您还没有保存API Key,关闭后将无法再次查看。
|
||
|
||
确定要关闭吗?`)&&M("close")};return(s,V)=>(i(),ye(Ue,{to:"body"},[e("div",Kl,[e("div",Ll,[e("div",{class:"mb-6 flex items-center justify-between"},[V[1]||(V[1]=e("div",{class:"flex items-center gap-3"},[e("div",{class:"flex h-12 w-12 items-center justify-center rounded-xl bg-gradient-to-br from-green-500 to-green-600"},[e("i",{class:"fas fa-check text-lg text-white"})]),e("div",null,[e("h3",{class:"text-xl font-bold text-gray-900 dark:text-gray-100"},"API Key 创建成功"),e("p",{class:"text-sm text-gray-600 dark:text-gray-400"},"请妥善保存您的 API Key")])],-1)),e("button",{class:"text-gray-400 transition-colors hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",title:"直接关闭(不推荐)",onClick:p},V[0]||(V[0]=[e("i",{class:"fas fa-times text-xl"},null,-1)]))]),V[9]||(V[9]=e("div",{class:"mb-6 border-l-4 border-amber-400 bg-amber-50 p-4 dark:border-amber-500 dark:bg-amber-900/20"},[e("div",{class:"flex items-start"},[e("div",{class:"mt-0.5 flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-lg bg-amber-400 dark:bg-amber-500"},[e("i",{class:"fas fa-exclamation-triangle text-sm text-white"})]),e("div",{class:"ml-3"},[e("h5",{class:"mb-1 font-semibold text-amber-900 dark:text-amber-400"},"重要提醒"),e("p",{class:"text-sm text-amber-800 dark:text-amber-300"}," 这是您唯一能看到完整 API Key 的机会。关闭此窗口后,系统将不再显示完整的 API Key。请立即复制并妥善保存。 ")])])],-1)),e("div",Dl,[e("div",null,[V[2]||(V[2]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"API Key 名称",-1)),e("div",_l,[e("span",Sl,u(v.apiKey.name),1)])]),v.apiKey.description?(i(),d("div",Tl,[V[3]||(V[3]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"备注",-1)),e("div",Pl,[e("span",Ul,u(v.apiKey.description||"无描述"),1)])])):h("",!0),e("div",null,[V[4]||(V[4]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"API Key",-1)),e("div",Ml,[e("div",Vl,u(T()),1),e("div",Rl,[e("button",{class:"btn-icon-sm bg-gray-700 hover:bg-gray-800 dark:bg-gray-700 dark:hover:bg-gray-600",title:N.value?"隐藏API Key":"显示完整API Key",type:"button",onClick:B},[e("i",{class:z(["fas",N.value?"fa-eye-slash":"fa-eye","text-gray-300"])},null,2)],8,El)])]),V[5]||(V[5]=e("p",{class:"mt-2 text-xs text-gray-500 dark:text-gray-400"}," 点击眼睛图标切换显示模式,使用下方按钮复制环境变量配置 ",-1))])]),e("div",{class:"flex flex-col gap-3 sm:gap-4"},[e("div",{class:"flex flex-col gap-3 sm:flex-row sm:gap-4"},[e("button",{class:"flex w-full items-center justify-center gap-2 rounded-xl border border-blue-200 bg-blue-50 px-5 py-3 text-sm font-semibold text-blue-700 transition-colors hover:border-blue-300 hover:bg-blue-100 dark:border-blue-500/50 dark:bg-blue-500/10 dark:text-blue-200 dark:hover:bg-blue-500/20 sm:flex-1 sm:text-base",onClick:f},V[6]||(V[6]=[e("i",{class:"fas fa-key"},null,-1),A(" 仅复制密钥 ",-1)])),e("button",{class:"btn btn-primary flex w-full items-center justify-center gap-2 px-5 py-3 text-sm font-semibold sm:flex-1 sm:text-base",onClick:Y},V[7]||(V[7]=[e("i",{class:"fas fa-copy"},null,-1),A(" 复制Claude配置 ",-1)]))]),e("button",{class:"flex w-full items-center justify-center gap-2 rounded-xl border border-gray-300 bg-gray-200 px-5 py-3 text-sm font-semibold text-gray-800 transition-colors hover:border-gray-400 hover:bg-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200 dark:hover:bg-gray-600 sm:text-base",onClick:L},V[8]||(V[8]=[e("i",{class:"fas fa-check-circle"},null,-1),A(" 我已保存 ",-1)]))])])])]))}},jl=_e(Ol,[["__scopeId","data-v-d2440499"]]),Gl={class:"modal fixed inset-0 z-50 flex items-center justify-center p-4"},ql={class:"modal-content custom-scrollbar mx-auto max-h-[90vh] w-full max-w-2xl overflow-y-auto p-8"},zl={class:"mb-6 flex items-center justify-between"},Fl={class:"flex items-center gap-3"},Bl={class:"text-sm text-gray-600"},Wl={class:"mb-6 grid grid-cols-2 gap-4 md:grid-cols-4"},Nl={class:"rounded-lg border border-blue-200 bg-gradient-to-br from-blue-50 to-blue-100 p-4"},Hl={class:"flex items-center justify-between"},Yl={class:"mt-1 text-2xl font-bold text-blue-900"},Ql={class:"rounded-lg border border-green-200 bg-gradient-to-br from-green-50 to-green-100 p-4"},Jl={class:"flex items-center justify-between"},Xl={class:"mt-1 truncate text-lg font-bold text-green-900"},Zl={class:"rounded-lg border border-purple-200 bg-gradient-to-br from-purple-50 to-purple-100 p-4"},ei={class:"flex items-center justify-between"},ti={class:"mt-1 text-lg font-bold text-purple-900"},si={class:"rounded-lg border border-orange-200 bg-gradient-to-br from-orange-50 to-orange-100 p-4"},ai={class:"flex items-center justify-between"},ri={class:"mt-1 text-lg font-bold text-orange-900"},oi={class:"mb-6"},li={class:"mb-3 flex items-center justify-between"},ii={class:"flex items-center gap-2"},ni={key:0,class:"custom-scrollbar max-h-48 overflow-y-auto rounded-lg bg-gray-900 p-4"},di={class:"font-mono text-xs text-gray-300"},ui={__name:"BatchApiKeyModal",props:{apiKeys:{type:Array,required:!0}},emits:["close"],setup(v,{emit:H}){const c=v,M=H,N=D(!1),$=R(()=>{if(c.apiKeys.length>0){const p=c.apiKeys[0],s=p.name.match(/^(.+)_\d+$/);return s?s[1]:p.name}return""}),U=()=>{if(c.apiKeys.length===0)return"未知";const p=c.apiKeys[0].permissions;return{all:"全部服务",claude:"仅 Claude",gemini:"仅 Gemini"}[p]||p},B=()=>{if(c.apiKeys.length===0)return"未知";const p=c.apiKeys[0].expiresAt;if(!p)return"永不过期";const s=new Date(p),S=Math.ceil((s-new Date)/(1e3*60*60*24));return S<=7?`${S}天`:S<=30?`${Math.ceil(S/7)}周`:S<=365?`${Math.ceil(S/30)}个月`:`${Math.ceil(S/365)}年`},T=()=>{N.value=!N.value},J=()=>{const s=c.apiKeys.slice(0,10).map(V=>`${V.name}: ${V.apiKey||V.key||""}`);return c.apiKeys.length>10&&s.push(`... 还有 ${c.apiKeys.length-10} 个 API Key`),s.join(`
|
||
`)},Y=()=>{const p=c.apiKeys.map(I=>`${I.name}: ${I.apiKey||I.key||""}`).join(`
|
||
`),s=new Blob([p],{type:"text/plain;charset=utf-8"}),V=URL.createObjectURL(s),S=document.createElement("a");S.href=V;const W=new Date().toISOString().replace(/[:.]/g,"-").slice(0,-5);S.download=`api-keys-${$.value}-${W}.txt`,document.body.appendChild(S),S.click(),document.body.removeChild(S),URL.revokeObjectURL(V),O("API Keys 文件已下载","success")},f=async()=>{window.showConfirm?await window.showConfirm("关闭提醒",`关闭后将无法再次查看这些 API Key,请确保已经下载并妥善保存。
|
||
|
||
确定要关闭吗?`,"确定关闭","返回下载")&&M("close"):confirm(`关闭后将无法再次查看这些 API Key,请确保已经下载并妥善保存。
|
||
|
||
确定要关闭吗?`)&&M("close")},L=async()=>{window.showConfirm?await window.showConfirm("确定要关闭吗?",`您还没有下载 API Keys,关闭后将无法再次查看。
|
||
|
||
强烈建议您先下载保存。`,"仍然关闭","返回下载")&&M("close"):confirm(`您还没有下载 API Keys,关闭后将无法再次查看。
|
||
|
||
确定要关闭吗?`)&&M("close")};return(p,s)=>(i(),ye(Ue,{to:"body"},[e("div",Gl,[e("div",ql,[e("div",zl,[e("div",Fl,[s[1]||(s[1]=e("div",{class:"flex h-12 w-12 items-center justify-center rounded-xl bg-gradient-to-br from-green-500 to-green-600"},[e("i",{class:"fas fa-layer-group text-lg text-white"})],-1)),e("div",null,[s[0]||(s[0]=e("h3",{class:"text-xl font-bold text-gray-900"},"批量创建成功",-1)),e("p",Bl,"成功创建 "+u(v.apiKeys.length)+" 个 API Key",1)])]),e("button",{class:"text-gray-400 transition-colors hover:text-gray-600",title:"直接关闭(不推荐)",onClick:L},s[2]||(s[2]=[e("i",{class:"fas fa-times text-xl"},null,-1)]))]),s[14]||(s[14]=e("div",{class:"mb-6 border-l-4 border-amber-400 bg-amber-50 p-4"},[e("div",{class:"flex items-start"},[e("div",{class:"mt-0.5 flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-lg bg-amber-400"},[e("i",{class:"fas fa-exclamation-triangle text-sm text-white"})]),e("div",{class:"ml-3"},[e("h5",{class:"mb-1 font-semibold text-amber-900"},"重要提醒"),e("p",{class:"text-sm text-amber-800"}," 这是您唯一能看到所有 API Key 的机会。关闭此窗口后,系统将不再显示完整的 API Key。请立即下载并妥善保存。 ")])])],-1)),e("div",Wl,[e("div",Nl,[e("div",Hl,[e("div",null,[s[3]||(s[3]=e("p",{class:"text-xs font-medium text-blue-600"},"创建数量",-1)),e("p",Yl,u(v.apiKeys.length),1)]),s[4]||(s[4]=e("div",{class:"flex h-10 w-10 items-center justify-center rounded-lg bg-blue-500 bg-opacity-20"},[e("i",{class:"fas fa-key text-blue-600"})],-1))])]),e("div",Ql,[e("div",Jl,[e("div",null,[s[5]||(s[5]=e("p",{class:"text-xs font-medium text-green-600"},"基础名称",-1)),e("p",Xl,u($.value),1)]),s[6]||(s[6]=e("div",{class:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-500 bg-opacity-20"},[e("i",{class:"fas fa-tag text-green-600"})],-1))])]),e("div",Zl,[e("div",ei,[e("div",null,[s[7]||(s[7]=e("p",{class:"text-xs font-medium text-purple-600"},"权限范围",-1)),e("p",ti,u(U()),1)]),s[8]||(s[8]=e("div",{class:"flex h-10 w-10 items-center justify-center rounded-lg bg-purple-500 bg-opacity-20"},[e("i",{class:"fas fa-shield-alt text-purple-600"})],-1))])]),e("div",si,[e("div",ai,[e("div",null,[s[9]||(s[9]=e("p",{class:"text-xs font-medium text-orange-600"},"过期时间",-1)),e("p",ri,u(B()),1)]),s[10]||(s[10]=e("div",{class:"flex h-10 w-10 items-center justify-center rounded-lg bg-orange-500 bg-opacity-20"},[e("i",{class:"fas fa-clock text-orange-600"})],-1))])])]),e("div",oi,[e("div",li,[s[12]||(s[12]=e("label",{class:"text-sm font-semibold text-gray-700"},"API Keys 预览",-1)),e("div",ii,[e("button",{class:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800",type:"button",onClick:T},[e("i",{class:z(["fas",N.value?"fa-eye-slash":"fa-eye"])},null,2),A(" "+u(N.value?"隐藏":"显示")+"预览 ",1)]),s[11]||(s[11]=e("span",{class:"text-xs text-gray-500"},"(最多显示前10个)",-1))])]),N.value?(i(),d("div",ni,[e("pre",di,u(J()),1)])):h("",!0)]),e("div",{class:"flex gap-3"},[e("button",{class:"btn btn-primary flex flex-1 items-center justify-center gap-2 px-6 py-3 font-semibold",onClick:Y},s[13]||(s[13]=[e("i",{class:"fas fa-download"},null,-1),A(" 下载所有 API Keys ",-1)])),e("button",{class:"rounded-xl border border-gray-300 bg-gray-200 px-6 py-3 font-semibold text-gray-800 transition-colors hover:bg-gray-300",onClick:f}," 我已保存 ")]),s[15]||(s[15]=e("div",{class:"mt-4 rounded-lg border border-blue-200 bg-blue-50 p-3"},[e("p",{class:"flex items-start text-xs text-blue-700"},[e("i",{class:"fas fa-info-circle mr-2 mt-0.5 flex-shrink-0"}),e("span",null," 下载的文件格式为文本文件(.txt),每行包含一个 API Key。 请将文件保存在安全的位置,避免泄露。 ")])],-1))])])]))}},ci=_e(ui,[["__scopeId","data-v-b0b904b9"]]),gi={class:"modal fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4"},pi={class:"modal-content mx-auto flex max-h-[90vh] w-full max-w-4xl flex-col p-4 sm:p-6 md:p-8"},mi={class:"mb-4 flex items-center justify-between sm:mb-6"},xi={class:"flex items-center gap-2 sm:gap-3"},yi={class:"text-lg font-bold text-gray-900 dark:text-gray-100 sm:text-xl"},fi={class:"rounded-lg bg-blue-50 p-4 dark:bg-blue-900/20"},bi={class:"flex items-start gap-3"},vi={class:"mt-1 text-sm text-blue-700 dark:text-blue-400"},ki={class:"space-y-4"},wi={class:"flex flex-wrap gap-4"},hi={class:"flex cursor-pointer items-center"},Ai={class:"flex cursor-pointer items-center"},$i={class:"flex cursor-pointer items-center"},Ci={class:"flex cursor-pointer items-center"},Ii={key:0,class:"space-y-3"},Ki={key:0},Li={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Di={class:"flex flex-wrap gap-2"},_i=["onClick"],Si={key:1},Ti={class:"flex flex-wrap gap-2"},Pi=["onClick"],Ui={class:"flex gap-2"},Mi=["onKeypress"],Vi={class:"rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-700 dark:bg-blue-900/20"},Ri={class:"space-y-2"},Ei={class:"grid grid-cols-1 gap-2 lg:grid-cols-3"},Oi={class:"mb-3 flex items-center gap-4"},ji={class:"flex gap-4"},Gi={class:"flex cursor-pointer items-center"},qi={class:"flex cursor-pointer items-center"},zi={class:"flex cursor-pointer items-center"},Fi={class:"flex flex-wrap gap-4"},Bi={class:"flex cursor-pointer items-center"},Wi={class:"flex cursor-pointer items-center"},Ni={class:"flex cursor-pointer items-center"},Hi={class:"flex cursor-pointer items-center"},Yi={class:"flex cursor-pointer items-center"},Qi={class:"flex cursor-pointer items-center"},Ji={class:"mb-3 flex items-center justify-between"},Xi=["disabled"],Zi={class:"grid grid-cols-1 gap-3"},en={class:"flex gap-3 pt-4"},tn=["disabled"],sn={key:0,class:"loading-spinner mr-2"},an={key:1,class:"fas fa-save mr-2"},Kt="__KEEP_ORIGINAL__",rn={__name:"BatchEditApiKeyModal",props:{selectedKeys:{type:Array,required:!0},accounts:{type:Object,default:()=>({claude:[],gemini:[],openai:[],openaiResponses:[],bedrock:[],droid:[],claudeGroups:[],geminiGroups:[],openaiGroups:[],droidGroups:[]})}},emits:["close","success"],setup(v,{emit:H}){const c=v,M=H,N=Dt(),$=D(!1),U=D(!1),B=D({claude:[],gemini:[],openai:[],bedrock:[],droid:[],claudeGroups:[],geminiGroups:[],openaiGroups:[],droidGroups:[]}),T=D(""),J=D([]),Y=D("none"),f=R(()=>c.selectedKeys.length),L=R(()=>J.value.filter(o=>!p.tags.includes(o))),p=ze({rateLimitCost:"",rateLimitWindow:"",rateLimitRequests:"",concurrencyLimit:"",dailyCostLimit:"",totalCostLimit:"",weeklyOpusCostLimit:"",permissions:"",claudeAccountId:"",geminiAccountId:"",openaiAccountId:"",bedrockAccountId:"",droidAccountId:"",tags:[],isActive:null}),s=[{value:Kt,label:"不修改"},{value:"SHARED_POOL",label:"使用共享账号池"}],V=o=>R({get:()=>p[o]===""?Kt:p[o],set:n=>{!n||n===Kt?p[o]="":p[o]=n}}),S=V("claudeAccountId"),W=V("geminiAccountId"),I=V("openaiAccountId"),K=V("bedrockAccountId"),se=V("droidAccountId"),ie=o=>!p.permissions||p.permissions==="all"?!0:p.permissions===o,de=()=>{if(T.value&&T.value.trim()){const o=T.value.trim();p.tags.includes(o)||p.tags.push(o),T.value=""}},pe=o=>{p.tags.includes(o)||p.tags.push(o)},X=o=>{p.tags.splice(o,1)},be=async()=>{var o,n;U.value=!0;try{const[m,C,g,l,y,ae,ue,ge]=await Promise.all([q.get("/admin/claude-accounts"),q.get("/admin/claude-console-accounts"),q.get("/admin/gemini-accounts"),q.get("/admin/openai-accounts"),q.get("/admin/openai-responses-accounts"),q.get("/admin/bedrock-accounts"),q.get("/admin/droid-accounts"),q.get("/admin/account-groups")]),ve=[];m.success&&((o=m.data)==null||o.forEach(F=>{ve.push({...F,platform:"claude-oauth",isDedicated:F.accountType==="dedicated"})})),C.success&&((n=C.data)==null||n.forEach(F=>{ve.push({...F,platform:"claude-console",isDedicated:F.accountType==="dedicated"})})),B.value.claude=ve,g.success&&(B.value.gemini=(g.data||[]).map(F=>({...F,isDedicated:F.accountType==="dedicated"})));const fe=[];if(l.success&&(l.data||[]).forEach(F=>{fe.push({...F,platform:"openai",isDedicated:F.accountType==="dedicated"})}),y.success&&(y.data||[]).forEach(F=>{fe.push({...F,platform:"openai-responses",isDedicated:F.accountType==="dedicated"})}),B.value.openai=fe,ae.success&&(B.value.bedrock=(ae.data||[]).map(F=>({...F,isDedicated:F.accountType==="dedicated"}))),ue.success&&(B.value.droid=(ue.data||[]).map(F=>({...F,platform:"droid",isDedicated:F.accountType==="dedicated"}))),ge.success){const F=ge.data||[];B.value.claudeGroups=F.filter(Q=>Q.platform==="claude"),B.value.geminiGroups=F.filter(Q=>Q.platform==="gemini"),B.value.openaiGroups=F.filter(Q=>Q.platform==="openai"),B.value.droidGroups=F.filter(Q=>Q.platform==="droid")}O("账号列表已刷新","success")}catch{O("刷新账号列表失败","error")}finally{U.value=!1}},k=async()=>{$.value=!0;try{const o={};p.rateLimitCost!==""&&p.rateLimitCost!==null&&(o.rateLimitCost=parseFloat(p.rateLimitCost)),p.rateLimitWindow!==""&&p.rateLimitWindow!==null&&(o.rateLimitWindow=parseInt(p.rateLimitWindow)),p.rateLimitRequests!==""&&p.rateLimitRequests!==null&&(o.rateLimitRequests=parseInt(p.rateLimitRequests)),p.concurrencyLimit!==""&&p.concurrencyLimit!==null&&(o.concurrencyLimit=parseInt(p.concurrencyLimit)),p.dailyCostLimit!==""&&p.dailyCostLimit!==null&&(o.dailyCostLimit=parseFloat(p.dailyCostLimit)),p.totalCostLimit!==""&&p.totalCostLimit!==null&&(o.totalCostLimit=parseFloat(p.totalCostLimit)),p.weeklyOpusCostLimit!==""&&p.weeklyOpusCostLimit!==null&&(o.weeklyOpusCostLimit=parseFloat(p.weeklyOpusCostLimit)),p.permissions!==""&&(o.permissions=p.permissions),p.claudeAccountId!==""&&(p.claudeAccountId==="SHARED_POOL"?(o.claudeAccountId=null,o.claudeConsoleAccountId=null):p.claudeAccountId.startsWith("console:")?(o.claudeConsoleAccountId=p.claudeAccountId.substring(8),o.claudeAccountId=null):(p.claudeAccountId.startsWith("group:"),o.claudeAccountId=p.claudeAccountId,o.claudeConsoleAccountId=null)),p.geminiAccountId!==""&&(p.geminiAccountId==="SHARED_POOL"?o.geminiAccountId=null:o.geminiAccountId=p.geminiAccountId),p.openaiAccountId!==""&&(p.openaiAccountId==="SHARED_POOL"?o.openaiAccountId=null:o.openaiAccountId=p.openaiAccountId),p.bedrockAccountId!==""&&(p.bedrockAccountId==="SHARED_POOL"?o.bedrockAccountId=null:o.bedrockAccountId=p.bedrockAccountId),p.droidAccountId!==""&&(p.droidAccountId==="SHARED_POOL"?o.droidAccountId=null:o.droidAccountId=p.droidAccountId),p.isActive!==null&&(o.isActive=p.isActive),Y.value!=="none"&&(o.tags=p.tags,o.tagOperation=Y.value);const n=await q.put("/admin/api-keys/batch",{keyIds:c.selectedKeys,updates:o});if(n.success){const{successCount:m,failedCount:C,errors:g}=n.data;if(m>0){if(O(`成功批量编辑 ${m} 个 API Keys`,"success"),C>0){const l=g.map(y=>`${y.keyId}: ${y.error}`).join(`
|
||
`);O(`${C} 个编辑失败:
|
||
${l}`,"warning")}}else O("所有 API Keys 编辑失败","error");M("success"),M("close")}else O(n.message||"批量编辑失败","error")}catch(o){O("批量编辑失败","error"),console.error("批量编辑 API Keys 失败:",o)}finally{$.value=!1}};return st(async()=>{if(J.value=await N.fetchTags(),c.accounts){const o=[];c.accounts.openai&&c.accounts.openai.forEach(n=>{o.push({...n,platform:"openai"})}),c.accounts.openaiResponses&&c.accounts.openaiResponses.forEach(n=>{o.push({...n,platform:"openai-responses"})}),B.value={claude:c.accounts.claude||[],gemini:c.accounts.gemini||[],openai:o,bedrock:c.accounts.bedrock||[],droid:c.accounts.droid||[],claudeGroups:c.accounts.claudeGroups||[],geminiGroups:c.accounts.geminiGroups||[],openaiGroups:c.accounts.openaiGroups||[],droidGroups:c.accounts.droidGroups||[]}}}),(o,n)=>(i(),ye(Ue,{to:"body"},[e("div",gi,[e("div",pi,[e("div",mi,[e("div",xi,[n[28]||(n[28]=e("div",{class:"flex h-8 w-8 items-center justify-center rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 sm:h-10 sm:w-10 sm:rounded-xl"},[e("i",{class:"fas fa-edit text-sm text-white sm:text-base"})],-1)),e("h3",yi," 批量编辑 API Keys ("+u(f.value)+" 个) ",1)]),e("button",{class:"p-1 text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-gray-300",onClick:n[0]||(n[0]=m=>o.$emit("close"))},n[29]||(n[29]=[e("i",{class:"fas fa-times text-lg sm:text-xl"},null,-1)]))]),e("form",{class:"modal-scroll-content custom-scrollbar flex-1 space-y-4 sm:space-y-6",onSubmit:Ce(k,["prevent"])},[e("div",fi,[e("div",bi,[n[31]||(n[31]=e("i",{class:"fas fa-info-circle mt-1 text-blue-500"},null,-1)),e("div",null,[n[30]||(n[30]=e("p",{class:"text-sm font-medium text-blue-800 dark:text-blue-300"},"批量编辑说明",-1)),e("p",vi," 以下设置将应用到所选的 "+u(f.value)+" 个 API Key。只有填写或修改的字段才会被更新,空白字段将保持原值不变。 ",1)])])]),e("div",null,[n[41]||(n[41]=e("label",{class:"mb-1.5 block text-xs font-semibold text-gray-700 dark:text-gray-300 sm:mb-3 sm:text-sm"}," 标签 (批量操作) ",-1)),e("div",ki,[e("div",wi,[e("label",hi,[_(e("input",{"onUpdate:modelValue":n[1]||(n[1]=m=>Y.value=m),class:"mr-2",type:"radio",value:"replace"},null,512),[[ne,Y.value]]),n[32]||(n[32]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"替换标签",-1))]),e("label",Ai,[_(e("input",{"onUpdate:modelValue":n[2]||(n[2]=m=>Y.value=m),class:"mr-2",type:"radio",value:"add"},null,512),[[ne,Y.value]]),n[33]||(n[33]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"添加标签",-1))]),e("label",$i,[_(e("input",{"onUpdate:modelValue":n[3]||(n[3]=m=>Y.value=m),class:"mr-2",type:"radio",value:"remove"},null,512),[[ne,Y.value]]),n[34]||(n[34]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"移除标签",-1))]),e("label",Ci,[_(e("input",{"onUpdate:modelValue":n[4]||(n[4]=m=>Y.value=m),class:"mr-2",type:"radio",value:"none"},null,512),[[ne,Y.value]]),n[35]||(n[35]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"不修改标签",-1))])]),Y.value!=="none"?(i(),d("div",Ii,[p.tags.length>0?(i(),d("div",Ki,[e("div",Li,u(Y.value==="replace"?"新标签列表:":Y.value==="add"?"要添加的标签:":"要移除的标签:"),1),e("div",Di,[(i(!0),d(te,null,oe(p.tags,(m,C)=>(i(),d("span",{key:"selected-"+C,class:"inline-flex items-center gap-1 rounded-full bg-blue-100 px-3 py-1 text-sm text-blue-800 dark:bg-blue-900/30 dark:text-blue-300"},[A(u(m)+" ",1),e("button",{class:"ml-1 hover:text-blue-900",type:"button",onClick:g=>X(C)},n[36]||(n[36]=[e("i",{class:"fas fa-times text-xs"},null,-1)]),8,_i)]))),128))])])):h("",!0),L.value.length>0?(i(),d("div",Si,[n[38]||(n[38]=e("div",{class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"}," 点击选择已有标签: ",-1)),e("div",Ti,[(i(!0),d(te,null,oe(L.value,m=>(i(),d("button",{key:"available-"+m,class:"inline-flex items-center gap-1 rounded-full bg-gray-100 px-3 py-1 text-sm text-gray-700 transition-colors hover:bg-blue-100 hover:text-blue-700 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-blue-900/30 dark:hover:text-blue-300",type:"button",onClick:C=>pe(m)},[n[37]||(n[37]=e("i",{class:"fas fa-tag text-xs text-gray-500 dark:text-gray-400"},null,-1)),A(" "+u(m),1)],8,Pi))),128))])])):h("",!0),e("div",null,[n[40]||(n[40]=e("div",{class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"}," 创建新标签: ",-1)),e("div",Ui,[_(e("input",{"onUpdate:modelValue":n[5]||(n[5]=m=>T.value=m),class:"form-input flex-1 border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",placeholder:"输入新标签名称",type:"text",onKeypress:et(Ce(de,["prevent"]),["enter"])},null,40,Mi),[[ee,T.value]]),e("button",{class:"rounded-lg bg-green-500 px-4 py-2 text-white transition-colors hover:bg-green-600 dark:bg-green-600 dark:hover:bg-green-700",type:"button",onClick:de},n[39]||(n[39]=[e("i",{class:"fas fa-plus"},null,-1)]))])])])):h("",!0)])]),e("div",Vi,[n[45]||(n[45]=e("div",{class:"mb-2 flex items-center gap-2"},[e("div",{class:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded bg-blue-500"},[e("i",{class:"fas fa-tachometer-alt text-xs text-white"})]),e("h4",{class:"text-sm font-semibold text-gray-800 dark:text-gray-200"},"速率限制设置")],-1)),e("div",Ri,[e("div",Ei,[e("div",null,[n[42]||(n[42]=e("label",{class:"mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300"}," 时间窗口 (分钟) ",-1)),_(e("input",{"onUpdate:modelValue":n[6]||(n[6]=m=>p.rateLimitWindow=m),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",min:"1",placeholder:"不修改",type:"number"},null,512),[[ee,p.rateLimitWindow]])]),e("div",null,[n[43]||(n[43]=e("label",{class:"mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300"},"请求次数限制",-1)),_(e("input",{"onUpdate:modelValue":n[7]||(n[7]=m=>p.rateLimitRequests=m),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",min:"1",placeholder:"不修改",type:"number"},null,512),[[ee,p.rateLimitRequests]])]),e("div",null,[n[44]||(n[44]=e("label",{class:"mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300"},"费用限制 (美元)",-1)),_(e("input",{"onUpdate:modelValue":n[8]||(n[8]=m=>p.rateLimitCost=m),class:"form-input w-full border-gray-300 text-sm dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",min:"0",placeholder:"不修改",step:"0.01",type:"number"},null,512),[[ee,p.rateLimitCost]])])])])]),e("div",null,[n[46]||(n[46]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"}," 每日费用限制 (美元) ",-1)),_(e("input",{"onUpdate:modelValue":n[9]||(n[9]=m=>p.dailyCostLimit=m),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",min:"0",placeholder:"不修改 (0 表示无限制)",step:"0.01",type:"number"},null,512),[[ee,p.dailyCostLimit]])]),e("div",null,[n[47]||(n[47]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"}," 总费用限制 (美元) ",-1)),_(e("input",{"onUpdate:modelValue":n[10]||(n[10]=m=>p.totalCostLimit=m),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",min:"0",placeholder:"不修改 (0 表示无限制)",step:"0.01",type:"number"},null,512),[[ee,p.totalCostLimit]])]),e("div",null,[n[48]||(n[48]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"}," Opus 模型周费用限制 (美元) ",-1)),_(e("input",{"onUpdate:modelValue":n[11]||(n[11]=m=>p.weeklyOpusCostLimit=m),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",min:"0",placeholder:"不修改 (0 表示无限制)",step:"0.01",type:"number"},null,512),[[ee,p.weeklyOpusCostLimit]]),n[49]||(n[49]=e("p",{class:"mt-1 text-xs text-gray-500 dark:text-gray-400"}," 设置 Opus 模型的周费用限制(周一到周日),仅限 Claude 官方账户 ",-1))]),e("div",null,[n[50]||(n[50]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"并发限制",-1)),_(e("input",{"onUpdate:modelValue":n[12]||(n[12]=m=>p.concurrencyLimit=m),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",min:"0",placeholder:"不修改 (0 表示无限制)",type:"number"},null,512),[[ee,p.concurrencyLimit]])]),e("div",null,[e("div",Oi,[n[54]||(n[54]=e("label",{class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},"激活状态",-1)),e("div",ji,[e("label",Gi,[_(e("input",{"onUpdate:modelValue":n[13]||(n[13]=m=>p.isActive=m),class:"mr-2",type:"radio",value:!0},null,512),[[ne,p.isActive]]),n[51]||(n[51]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"激活",-1))]),e("label",qi,[_(e("input",{"onUpdate:modelValue":n[14]||(n[14]=m=>p.isActive=m),class:"mr-2",type:"radio",value:!1},null,512),[[ne,p.isActive]]),n[52]||(n[52]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"禁用",-1))]),e("label",zi,[_(e("input",{"onUpdate:modelValue":n[15]||(n[15]=m=>p.isActive=m),class:"mr-2",type:"radio",value:null},null,512),[[ne,p.isActive]]),n[53]||(n[53]=e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"不修改",-1))])])])]),e("div",null,[n[61]||(n[61]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"服务权限",-1)),e("div",Fi,[e("label",Bi,[_(e("input",{"onUpdate:modelValue":n[16]||(n[16]=m=>p.permissions=m),class:"mr-2",type:"radio",value:""},null,512),[[ne,p.permissions]]),n[55]||(n[55]=e("span",{class:"text-sm text-gray-700"},"不修改",-1))]),e("label",Wi,[_(e("input",{"onUpdate:modelValue":n[17]||(n[17]=m=>p.permissions=m),class:"mr-2",type:"radio",value:"all"},null,512),[[ne,p.permissions]]),n[56]||(n[56]=e("span",{class:"text-sm text-gray-700"},"全部服务",-1))]),e("label",Ni,[_(e("input",{"onUpdate:modelValue":n[18]||(n[18]=m=>p.permissions=m),class:"mr-2",type:"radio",value:"claude"},null,512),[[ne,p.permissions]]),n[57]||(n[57]=e("span",{class:"text-sm text-gray-700"},"仅 Claude",-1))]),e("label",Hi,[_(e("input",{"onUpdate:modelValue":n[19]||(n[19]=m=>p.permissions=m),class:"mr-2",type:"radio",value:"gemini"},null,512),[[ne,p.permissions]]),n[58]||(n[58]=e("span",{class:"text-sm text-gray-700"},"仅 Gemini",-1))]),e("label",Yi,[_(e("input",{"onUpdate:modelValue":n[20]||(n[20]=m=>p.permissions=m),class:"mr-2",type:"radio",value:"openai"},null,512),[[ne,p.permissions]]),n[59]||(n[59]=e("span",{class:"text-sm text-gray-700"},"仅 OpenAI",-1))]),e("label",Qi,[_(e("input",{"onUpdate:modelValue":n[21]||(n[21]=m=>p.permissions=m),class:"mr-2",type:"radio",value:"droid"},null,512),[[ne,p.permissions]]),n[60]||(n[60]=e("span",{class:"text-sm text-gray-700"},"仅 Droid",-1))])])]),e("div",null,[e("div",Ji,[n[62]||(n[62]=e("label",{class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},"专属账号绑定",-1)),e("button",{class:"flex items-center gap-1 text-sm text-blue-600 transition-colors hover:text-blue-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-blue-400 dark:hover:text-blue-300",disabled:U.value,title:"刷新账号列表",type:"button",onClick:be},[e("i",{class:z(["fas",U.value?"fa-spinner fa-spin":"fa-sync-alt","text-xs"])},null,2),e("span",null,u(U.value?"刷新中...":"刷新账号"),1)],8,Xi)]),e("div",Zi,[e("div",null,[n[63]||(n[63]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Claude 专属账号",-1)),le(Ae,{modelValue:Ze(S),"onUpdate:modelValue":n[22]||(n[22]=m=>Xe(S)?S.value=m:null),accounts:B.value.claude,"default-option-text":"请选择Claude账号",disabled:!ie("claude"),groups:B.value.claudeGroups,placeholder:"请选择Claude账号",platform:"claude","special-options":s},null,8,["modelValue","accounts","disabled","groups"])]),e("div",null,[n[64]||(n[64]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Gemini 专属账号",-1)),le(Ae,{modelValue:Ze(W),"onUpdate:modelValue":n[23]||(n[23]=m=>Xe(W)?W.value=m:null),accounts:B.value.gemini,"default-option-text":"请选择Gemini账号",disabled:!ie("gemini"),groups:B.value.geminiGroups,placeholder:"请选择Gemini账号",platform:"gemini","special-options":s},null,8,["modelValue","accounts","disabled","groups"])]),e("div",null,[n[65]||(n[65]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"OpenAI 专属账号",-1)),le(Ae,{modelValue:Ze(I),"onUpdate:modelValue":n[24]||(n[24]=m=>Xe(I)?I.value=m:null),accounts:B.value.openai,"default-option-text":"请选择OpenAI账号",disabled:!ie("openai"),groups:B.value.openaiGroups,placeholder:"请选择OpenAI账号",platform:"openai","special-options":s},null,8,["modelValue","accounts","disabled","groups"])]),e("div",null,[n[66]||(n[66]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Bedrock 专属账号",-1)),le(Ae,{modelValue:Ze(K),"onUpdate:modelValue":n[25]||(n[25]=m=>Xe(K)?K.value=m:null),accounts:B.value.bedrock,"default-option-text":"请选择Bedrock账号",disabled:!ie("openai"),groups:[],placeholder:"请选择Bedrock账号",platform:"bedrock","special-options":s},null,8,["modelValue","accounts","disabled"])]),e("div",null,[n[67]||(n[67]=e("label",{class:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-400"},"Droid 专属账号",-1)),le(Ae,{modelValue:Ze(se),"onUpdate:modelValue":n[26]||(n[26]=m=>Xe(se)?se.value=m:null),accounts:B.value.droid,"default-option-text":"请选择Droid账号",disabled:!ie("droid"),groups:B.value.droidGroups,placeholder:"请选择Droid账号",platform:"droid","special-options":s},null,8,["modelValue","accounts","disabled","groups"])])])]),e("div",en,[e("button",{class:"flex-1 rounded-xl bg-gray-100 px-6 py-3 font-semibold text-gray-700 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",type:"button",onClick:n[27]||(n[27]=m=>o.$emit("close"))}," 取消 "),e("button",{class:"btn btn-primary flex-1 px-6 py-3 font-semibold",disabled:$.value,type:"submit"},[$.value?(i(),d("div",sn)):(i(),d("i",an)),A(" "+u($.value?"保存中...":"批量保存"),1)],8,tn)])],32)])])]))}},on=_e(rn,[["__scopeId","data-v-0dc5b225"]]),ln={key:0,class:"modal fixed inset-0 z-50 flex items-center justify-center p-4"},nn={class:"modal-content relative mx-auto w-full max-w-lg p-8"},dn={class:"mb-6 flex items-center justify-between"},un={class:"flex items-center gap-3"},cn={class:"text-sm text-gray-600 dark:text-gray-400"},gn={class:"space-y-6"},pn={class:"rounded-lg border border-gray-200 bg-gradient-to-r from-gray-50 to-gray-100 p-4 dark:border-gray-600 dark:from-gray-700 dark:to-gray-800"},mn={class:"flex items-center justify-between"},xn={class:"text-sm font-semibold text-gray-800 dark:text-gray-200"},yn={class:"ml-2 text-xs font-normal text-gray-600"},fn={class:"flex h-12 w-12 items-center justify-center rounded-lg bg-white shadow-sm dark:bg-gray-700"},bn={key:0,class:"mb-4"},vn={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},kn={class:"mb-3 grid grid-cols-3 gap-2"},wn=["onClick"],hn={key:1,class:"animate-fadeIn"},An=["min"],$n={key:2,class:"rounded-lg border border-blue-200 bg-gradient-to-r from-blue-50 to-indigo-50 p-4 dark:border-blue-700 dark:from-blue-900/20 dark:to-indigo-900/20"},Cn={class:"flex items-center justify-between"},In={class:"text-sm font-semibold text-blue-900 dark:text-blue-200"},Kn={class:"flex gap-3 pt-2"},Ln=["disabled"],Dn={key:0,class:"loading-spinner mr-2"},_n={key:1,class:"fas fa-save mr-2"},Sn={__name:"ExpiryEditModal",props:{show:{type:Boolean,required:!0},apiKey:{type:Object,required:!0}},emits:["close","save"],setup(v,{expose:H,emit:c}){const M=v,N=c,$=D(!1),U=ze({expireDuration:"",customExpireDate:"",expiresAt:null}),B=[{value:"",label:"永不过期"},{value:"1d",label:"1 天"},{value:"7d",label:"7 天"},{value:"30d",label:"30 天"},{value:"90d",label:"90 天"},{value:"180d",label:"180 天"},{value:"365d",label:"1 年"},{value:"730d",label:"2 年"}],T=R(()=>{const I=new Date;return I.setMinutes(I.getMinutes()+1),I.toISOString().slice(0,16)});De(()=>M.show,I=>{I&&J()}),De(()=>{var I;return(I=M.apiKey)==null?void 0:I.id},I=>{I&&M.show&&J()});const J=()=>{$.value=!1,M.apiKey.expiresAt?(U.expireDuration="custom",U.customExpireDate=new Date(M.apiKey.expiresAt).toISOString().slice(0,16),U.expiresAt=M.apiKey.expiresAt):(U.expireDuration="",U.customExpireDate="",U.expiresAt=null)},Y=I=>{if(U.expireDuration=I,!I){U.expiresAt=null;return}if(I==="custom")return;const K=new Date,se=I.match(/(\d+)([dhmy])/);if(se){const[,ie,de]=se,pe=parseInt(ie);switch(de){case"d":K.setDate(K.getDate()+pe);break;case"h":K.setHours(K.getHours()+pe);break;case"m":K.setMonth(K.getMonth()+pe);break;case"y":K.setFullYear(K.getFullYear()+pe);break}U.expiresAt=K.toISOString()}},f=()=>{U.customExpireDate&&(U.expiresAt=new Date(U.customExpireDate).toISOString())},L=I=>I?new Date(I).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"",p=I=>I?new Date(I)<new Date:!1,s=I=>{if(!I)return null;const K=new Date,ie=new Date(I)-K,de=Math.ceil(ie/(1e3*60*60*24));return ie<0?{text:"已过期",class:"text-red-600"}:de<=7?{text:`${de} 天后过期`,class:"text-orange-600"}:de<=30?{text:`${de} 天后过期`,class:"text-yellow-600"}:{text:`${Math.ceil(de/30)} 个月后过期`,class:"text-green-600"}},V=()=>{$.value=!0,N("save",{keyId:M.apiKey.id,expiresAt:U.expiresAt})},S=async()=>{let I=!0;window.showConfirm?I=await window.showConfirm("激活 API Key",`确定要立即激活此 API Key 吗?激活后将在 ${M.apiKey.activationDays||(M.apiKey.activationUnit==="hours"?24:30)} ${M.apiKey.activationUnit==="hours"?"小时":"天"}后自动过期。`,"确定激活","取消"):I=confirm(`确定要立即激活此 API Key 吗?激活后将在 ${M.apiKey.activationDays||(M.apiKey.activationUnit==="hours"?24:30)} ${M.apiKey.activationUnit==="hours"?"小时":"天"}后自动过期。`),I&&($.value=!0,N("save",{keyId:M.apiKey.id,activateNow:!0}))};return H({resetSaving:()=>{$.value=!1}}),(I,K)=>(i(),ye(Ue,{to:"body"},[v.show?(i(),d("div",ln,[e("div",{class:"fixed inset-0 bg-gray-900 bg-opacity-50 backdrop-blur-sm",onClick:K[0]||(K[0]=se=>I.$emit("close"))}),e("div",nn,[e("div",dn,[e("div",un,[K[6]||(K[6]=e("div",{class:"flex h-10 w-10 items-center justify-center rounded-xl bg-gradient-to-br from-amber-500 to-orange-600"},[e("i",{class:"fas fa-clock text-white"})],-1)),e("div",null,[K[5]||(K[5]=e("h3",{class:"text-xl font-bold text-gray-900 dark:text-gray-100"},"修改过期时间",-1)),e("p",cn,' 为 "'+u(v.apiKey.name||"API Key")+'" 设置新的过期时间 ',1)])]),e("button",{class:"text-gray-400 transition-colors hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",onClick:K[1]||(K[1]=se=>I.$emit("close"))},K[7]||(K[7]=[e("i",{class:"fas fa-times text-xl"},null,-1)]))]),e("div",gn,[e("div",pn,[e("div",mn,[e("div",null,[K[12]||(K[12]=e("p",{class:"mb-1 text-xs font-medium text-gray-600 dark:text-gray-400"},"当前状态",-1)),e("p",xn,[v.apiKey.expirationMode==="activation"&&!v.apiKey.isActivated?(i(),d(te,{key:0},[K[8]||(K[8]=e("i",{class:"fas fa-pause-circle mr-1 text-blue-500"},null,-1)),K[9]||(K[9]=A(" 未激活 ",-1)),e("span",yn," (激活后 "+u(v.apiKey.activationDays||(v.apiKey.activationUnit==="hours"?24:30))+" "+u(v.apiKey.activationUnit==="hours"?"小时":"天")+"过期) ",1)],64)):v.apiKey.expiresAt?(i(),d(te,{key:1},[A(u(L(v.apiKey.expiresAt))+" ",1),s(v.apiKey.expiresAt)?(i(),d("span",{key:0,class:z(["ml-2 text-xs font-normal",s(v.apiKey.expiresAt).class])}," ("+u(s(v.apiKey.expiresAt).text)+") ",3)):h("",!0)],64)):(i(),d(te,{key:2},[K[10]||(K[10]=e("i",{class:"fas fa-infinity mr-1 text-gray-500"},null,-1)),K[11]||(K[11]=A(" 永不过期 ",-1))],64))])]),e("div",fn,[e("i",{class:z(["fas fa-hourglass-half text-lg",v.apiKey.expiresAt&&p(v.apiKey.expiresAt)?"text-red-500":"text-gray-400"])},null,2)])])]),v.apiKey.expirationMode==="activation"&&!v.apiKey.isActivated?(i(),d("div",bn,[e("button",{class:"w-full rounded-lg bg-gradient-to-r from-blue-500 to-blue-600 px-4 py-3 font-semibold text-white transition-all hover:from-blue-600 hover:to-blue-700 hover:shadow-lg",onClick:S},[K[13]||(K[13]=e("i",{class:"fas fa-rocket mr-2"},null,-1)),A(" 立即激活 (激活后 "+u(v.apiKey.activationDays||(v.apiKey.activationUnit==="hours"?24:30))+" "+u(v.apiKey.activationUnit==="hours"?"小时":"天")+"过期) ",1)]),e("p",vn,[K[14]||(K[14]=e("i",{class:"fas fa-info-circle mr-1"},null,-1)),A(" 点击立即激活此 API Key,激活后将在 "+u(v.apiKey.activationDays||(v.apiKey.activationUnit==="hours"?24:30))+" "+u(v.apiKey.activationUnit==="hours"?"小时":"天")+"后过期 ",1)])])):h("",!0),e("div",null,[K[16]||(K[16]=e("label",{class:"mb-3 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"选择新的期限",-1)),e("div",kn,[(i(),d(te,null,oe(B,se=>e("button",{key:se.value,class:z(["rounded-lg px-3 py-2 text-sm font-medium transition-all",U.expireDuration===se.value?"bg-blue-500 text-white shadow-md":"bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"]),onClick:ie=>Y(se.value)},u(se.label),11,wn)),64)),e("button",{class:z(["rounded-lg px-3 py-2 text-sm font-medium transition-all",U.expireDuration==="custom"?"bg-blue-500 text-white shadow-md":"bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"]),onClick:K[2]||(K[2]=se=>Y("custom"))},K[15]||(K[15]=[e("i",{class:"fas fa-calendar-alt mr-1"},null,-1),A(" 自定义 ",-1)]),2)])]),U.expireDuration==="custom"?(i(),d("div",hn,[K[17]||(K[17]=e("label",{class:"mb-2 block text-sm font-semibold text-gray-700 dark:text-gray-300"},"选择日期和时间",-1)),_(e("input",{"onUpdate:modelValue":K[3]||(K[3]=se=>U.customExpireDate=se),class:"form-input w-full border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",min:T.value,type:"datetime-local",onChange:f},null,40,An),[[ee,U.customExpireDate]]),K[18]||(K[18]=e("p",{class:"mt-2 text-xs text-gray-500 dark:text-gray-400"}," 选择一个未来的日期和时间作为过期时间 ",-1))])):h("",!0),U.expiresAt!==v.apiKey.expiresAt?(i(),d("div",$n,[e("div",Cn,[e("div",null,[K[21]||(K[21]=e("p",{class:"mb-1 text-xs font-medium text-blue-700 dark:text-blue-400"},[e("i",{class:"fas fa-arrow-right mr-1"}),A(" 新的过期时间 ")],-1)),e("p",In,[U.expiresAt?(i(),d(te,{key:0},[A(u(L(U.expiresAt))+" ",1),s(U.expiresAt)?(i(),d("span",{key:0,class:z(["ml-2 text-xs font-normal",s(U.expiresAt).class])}," ("+u(s(U.expiresAt).text)+") ",3)):h("",!0)],64)):(i(),d(te,{key:1},[K[19]||(K[19]=e("i",{class:"fas fa-infinity mr-1"},null,-1)),K[20]||(K[20]=A(" 永不过期 ",-1))],64))])]),K[22]||(K[22]=e("div",{class:"flex h-12 w-12 items-center justify-center rounded-lg bg-white shadow-sm dark:bg-gray-700"},[e("i",{class:"fas fa-check text-lg text-green-500"})],-1))])])):h("",!0),e("div",Kn,[e("button",{class:"flex-1 rounded-lg bg-gray-100 px-4 py-2.5 font-semibold text-gray-700 transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",onClick:K[4]||(K[4]=se=>I.$emit("close"))}," 取消 "),e("button",{class:"btn btn-primary flex-1 px-4 py-2.5 font-semibold",disabled:$.value||U.expiresAt===v.apiKey.expiresAt,onClick:V},[$.value?(i(),d("div",Dn)):(i(),d("i",_n)),A(" "+u($.value?"保存中...":"保存更改"),1)],8,Ln)])])])])):h("",!0)]))}},Tn=_e(Sn,[["__scopeId","data-v-fb30c1d3"]]),Pn={class:"w-full"},Un={key:0,class:"flex items-center justify-center rounded-lg px-3 py-2 text-xs"},Mn={key:1,class:"space-y-1.5"},Vn={class:"flex items-center justify-between text-[11px] font-medium"},Rn={class:"text-gray-700 dark:text-gray-200"},En={class:"relative h-1.5 overflow-hidden rounded-full bg-gray-200/85 dark:bg-gray-700/70"},On={class:"relative z-10 flex h-full items-center justify-between px-3"},jn={class:"flex items-center gap-1.5"},Gn={class:"flex items-center gap-1.5"},qn={key:0,class:"pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-700 group-hover:opacity-30",style:{background:"linear-gradient(105deg, transparent 35%, rgba(255,255,255,0.55) 48%, transparent 63%)",animation:"shine 2.8s infinite"}},zn={__name:"LimitProgressBar",props:{type:{type:String,required:!0,validator:v=>["daily","opus","window","total"].includes(v)},variant:{type:String,default:"full",validator:v=>["full","compact"].includes(v)},label:{type:String,required:!0},current:{type:Number,default:0},limit:{type:Number,required:!0},showShine:{type:Boolean,default:!1}},setup(v){const H=v,c=R(()=>H.variant==="compact"),M=R(()=>{if(!H.limit||H.limit<=0)return 0;const L=H.current/H.limit*100;return Math.min(L,100)}),N=R(()=>{switch(H.type){case"daily":return"border-emerald-200/80 bg-white/80 shadow-[0_10px_24px_rgba(16,185,129,0.18)] group-hover:shadow-[0_14px_30px_rgba(16,185,129,0.22)] dark:border-emerald-500/40 dark:bg-emerald-950/40 dark:shadow-[0_12px_28px_rgba(0,0,0,0.45)]";case"opus":return"border-violet-200/80 bg-white/80 shadow-[0_10px_24px_rgba(139,92,246,0.18)] group-hover:shadow-[0_14px_30px_rgba(139,92,246,0.22)] dark:border-violet-500/40 dark:bg-violet-950/40 dark:shadow-[0_12px_28px_rgba(0,0,0,0.45)]";case"window":return"border-sky-200/80 bg-white/80 shadow-[0_10px_24px_rgba(56,189,248,0.18)] group-hover:shadow-[0_14px_30px_rgba(56,189,248,0.22)] dark:border-sky-500/40 dark:bg-sky-950/40 dark:shadow-[0_12px_28px_rgba(0,0,0,0.45)]";case"total":return"border-blue-200/80 bg-white/80 shadow-[0_10px_24px_rgba(59,130,246,0.18)] group-hover:shadow-[0_14px_30px_rgba(59,130,246,0.22)] dark:border-blue-500/40 dark:bg-blue-950/40 dark:shadow-[0_12px_28px_rgba(0,0,0,0.45)]";default:return"border-gray-200/80 bg-white/80 shadow-[0_10px_24px_rgba(148,163,184,0.18)] group-hover:shadow-[0_14px_30px_rgba(148,163,184,0.22)] dark:border-gray-600/50 dark:bg-gray-900/50 dark:shadow-[0_12px_28px_rgba(0,0,0,0.45)]"}}),$=R(()=>{switch(H.type){case"daily":return"bg-gradient-to-r from-emerald-50 via-green-50 to-emerald-100 dark:from-emerald-900/40 dark:via-emerald-900/20 dark:to-emerald-800/30";case"opus":return"bg-gradient-to-r from-violet-50 via-violet-100 to-fuchsia-100 dark:from-violet-900/40 dark:via-violet-900/20 dark:to-fuchsia-900/30";case"window":return"bg-gradient-to-r from-sky-50 via-sky-100 to-cyan-100 dark:from-sky-900/40 dark:via-sky-900/20 dark:to-cyan-900/30";case"total":return"bg-gradient-to-r from-blue-50 via-blue-100 to-sky-100 dark:from-blue-900/40 dark:via-blue-900/20 dark:to-sky-900/30";default:return"bg-gradient-to-r from-gray-100 via-gray-50 to-gray-200 dark:from-gray-900/30 dark:via-gray-900/10 dark:to-gray-800/30"}}),U=R(()=>{const L=M.value;return H.type==="daily"?L>=90?"bg-gradient-to-r from-rose-500 via-red-500 to-rose-600 dark:from-rose-500 dark:via-red-500 dark:to-rose-600":L>=70?"bg-gradient-to-r from-amber-400 via-orange-400 to-amber-500 dark:from-amber-400 dark:via-orange-400 dark:to-amber-500":"bg-gradient-to-r from-emerald-400 via-emerald-500 to-teal-500 dark:from-emerald-400 dark:via-emerald-500 dark:to-teal-500":H.type==="opus"?L>=90?"bg-gradient-to-r from-rose-500 via-red-500 to-rose-600 dark:from-rose-500 dark:via-red-500 dark:to-rose-600":L>=70?"bg-gradient-to-r from-amber-400 via-orange-400 to-amber-500 dark:from-amber-400 dark:via-orange-400 dark:to-amber-500":"bg-gradient-to-r from-violet-400 via-purple-500 to-fuchsia-500 dark:from-violet-400 dark:via-purple-500 dark:to-fuchsia-500":H.type==="window"?L>=90?"bg-gradient-to-r from-rose-500 via-red-500 to-rose-600 dark:from-rose-500 dark:via-red-500 dark:to-rose-600":L>=70?"bg-gradient-to-r from-amber-400 via-orange-400 to-amber-500 dark:from-amber-400 dark:via-orange-400 dark:to-amber-500":"bg-gradient-to-r from-sky-400 via-cyan-400 to-blue-500 dark:from-sky-400 dark:via-cyan-400 dark:to-blue-500":H.type==="total"?L>=90?"bg-gradient-to-r from-rose-500 via-red-500 to-rose-600 dark:from-rose-500 dark:via-red-500 dark:to-rose-600":L>=70?"bg-gradient-to-r from-amber-400 via-orange-400 to-amber-500 dark:from-amber-400 dark:via-orange-400 dark:to-amber-500":"bg-gradient-to-r from-sky-500 via-blue-500 to-cyan-500 dark:from-sky-500 dark:via-blue-500 dark:to-cyan-500":"bg-gray-300 dark:bg-gray-400"}),B=R(()=>{const L=M.value;if(L>=95)return"bg-rose-500 dark:bg-rose-400";if(L>=80)return"bg-amber-400 dark:bg-amber-300";switch(H.type){case"daily":return"bg-emerald-500 dark:bg-emerald-400";case"opus":return"bg-violet-500 dark:bg-violet-400";case"window":return"bg-sky-500 dark:bg-sky-400";case"total":return"bg-blue-500 dark:bg-blue-400";default:return"bg-slate-400 dark:bg-slate-500"}}),T=R(()=>{const L=M.value;if(L>=95)return"text-rose-600 dark:text-rose-300";if(L>=80)return"text-amber-600 dark:text-amber-300";switch(H.type){case"daily":return"text-emerald-600 dark:text-emerald-300";case"opus":return"text-violet-600 dark:text-violet-300";case"window":return"text-sky-600 dark:text-sky-300";case"total":return"text-blue-600 dark:text-blue-300";default:return"text-gray-600 dark:text-gray-300"}}),J=R(()=>{const L=M.value;let p="";if(L>=90)p="text-red-700 dark:text-red-400";else if(L>=70)p="text-orange-700 dark:text-orange-400";else switch(H.type){case"daily":p="text-green-700 dark:text-green-400";break;case"opus":p="text-purple-700 dark:text-purple-400";break;case"window":p="text-blue-700 dark:text-blue-400";break;default:p="text-gray-600 dark:text-gray-400"}let s="";switch(H.type){case"daily":s="fas fa-calendar-day";break;case"opus":s="fas fa-gem";break;case"window":s="fas fa-clock";break;case"total":s="fas fa-wallet";break;default:s="fas fa-infinity"}return`${s} ${p}`}),Y=R(()=>{if(M.value>40)return"text-white drop-shadow-[0_1px_2px_rgba(0,0,0,0.8)]";switch(H.type){case"daily":return"text-gray-900 dark:text-gray-100";case"opus":return"text-purple-900 dark:text-purple-100";case"window":return"text-blue-900 dark:text-blue-100";case"total":return"text-blue-900 dark:text-blue-100";default:return"text-gray-900 dark:text-gray-100"}}),f=R(()=>{const L=M.value;if(L>70)return"text-white drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)]";if(L>=90)return"text-red-700 dark:text-red-300";if(L>=70)return"text-orange-700 dark:text-orange-300";switch(H.type){case"daily":return"text-green-800 dark:text-green-200";case"opus":return"text-purple-800 dark:text-purple-200";case"window":return"text-blue-800 dark:text-blue-200";case"total":return"text-blue-800 dark:text-blue-200";default:return"text-gray-900 dark:text-gray-100"}});return(L,p)=>(i(),d("div",Pn,[!v.limit||v.limit<=0?(i(),d("div",Un,p[0]||(p[0]=[e("div",{class:"flex items-center gap-1.5 text-gray-600 dark:text-gray-300"},[e("i",{class:"fas fa-infinity text-sm text-gray-500 dark:text-gray-400"}),e("span",{class:"font-medium"},"无限制")],-1)]))):c.value?(i(),d("div",Mn,[e("div",Vn,[e("div",{class:z(["flex items-center gap-1.5",T.value])},[e("i",{class:z(["text-[11px]",J.value])},null,2),e("span",null,u(v.label),1)],2),e("span",Rn,"$"+u(v.current.toFixed(2))+" / $"+u(v.limit.toFixed(2)),1)]),e("div",En,[e("div",{class:z(["absolute inset-y-0 rounded-full transition-all duration-500 ease-out",B.value]),style:pt({width:M.value+"%"})},null,6)])])):(i(),d("div",{key:2,class:z(["group relative h-9 w-full overflow-hidden rounded-xl border transition-all duration-300 ease-out",N.value])},[e("div",{class:z(["absolute inset-0",$.value])},null,2),e("div",{class:z(["absolute inset-0 h-full transition-all duration-500 ease-out",U.value]),style:pt({width:M.value+"%"})},null,6),p[1]||(p[1]=e("div",{class:"pointer-events-none absolute inset-0 rounded-xl border border-white/50 opacity-40 mix-blend-overlay dark:border-white/10"},null,-1)),e("div",On,[e("div",jn,[e("i",{class:z(["text-xs",J.value])},null,2),e("span",{class:z(["text-xs font-semibold",Y.value])},u(v.label),3)]),e("div",Gn,[e("span",{class:z(["text-xs font-bold tabular-nums",f.value])}," $"+u(v.current.toFixed(2))+" / $"+u(v.limit.toFixed(2)),3)])]),v.showShine&&M.value>0?(i(),d("div",qn)):h("",!0)],2))]))}},Pe=_e(zn,[["__scopeId","data-v-8a01dc56"]]),Fn={key:0,class:"modal fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4"},Bn={class:"modal-content relative mx-auto flex max-h-[90vh] w-[95%] max-w-5xl flex-col p-4 sm:w-full sm:p-6 md:p-8"},Wn={class:"mb-4 flex items-center justify-between sm:mb-6"},Nn={class:"flex items-center gap-2 sm:gap-3"},Hn={class:"text-lg font-bold text-gray-900 dark:text-gray-100 sm:text-xl"},Yn={class:"modal-scroll-content custom-scrollbar flex-1 overflow-y-auto"},Qn={class:"mb-6 grid grid-cols-1 gap-4 md:grid-cols-2"},Jn={class:"rounded-lg border border-blue-200 bg-gradient-to-br from-blue-50 to-blue-100 p-4 dark:border-blue-700 dark:from-blue-900/20 dark:to-blue-800/20"},Xn={class:"text-2xl font-bold text-gray-900 dark:text-gray-100"},Zn={class:"mt-1 text-xs text-gray-600 dark:text-gray-400"},ed={class:"rounded-lg border border-green-200 bg-gradient-to-br from-green-50 to-green-100 p-4 dark:border-green-700 dark:from-green-900/20 dark:to-green-800/20"},td={class:"text-2xl font-bold text-gray-900 dark:text-gray-100"},sd={class:"mt-1 text-xs text-gray-600 dark:text-gray-400"},ad={class:"rounded-lg border border-yellow-200 bg-gradient-to-br from-yellow-50 to-yellow-100 p-4 dark:border-yellow-700 dark:from-yellow-900/20 dark:to-yellow-800/20"},rd={class:"text-2xl font-bold text-gray-900 dark:text-gray-100"},od={class:"mt-1 text-xs text-gray-600 dark:text-gray-400"},ld={class:"rounded-lg border border-purple-200 bg-gradient-to-br from-purple-50 to-purple-100 p-4 dark:border-purple-700 dark:from-purple-900/20 dark:to-purple-800/20"},id={class:"space-y-1 text-sm"},nd={class:"flex justify-between"},dd={class:"font-semibold text-gray-900 dark:text-gray-100"},ud={class:"flex justify-between"},cd={class:"font-semibold text-gray-900 dark:text-gray-100"},gd={class:"mb-6"},pd={class:"space-y-3 rounded-lg bg-gray-50 p-4 dark:bg-gray-700/50"},md={class:"flex items-center justify-between"},xd={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},yd={class:"flex items-center justify-between"},fd={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},bd={key:0,class:"flex items-center justify-between"},vd={class:"text-sm font-semibold text-purple-600"},kd={key:1,class:"flex items-center justify-between"},wd={class:"text-sm font-semibold text-purple-600"},hd={key:0,class:"mb-6"},Ad={class:"space-y-3 rounded-lg bg-gray-50 p-4 dark:bg-gray-700/50"},$d={key:0,class:"space-y-1.5"},Cd={class:"text-right text-xs text-gray-500 dark:text-gray-400"},Id={key:1,class:"space-y-1.5"},Kd={class:"text-right text-xs text-gray-500 dark:text-gray-400"},Ld={key:2,class:"space-y-1.5"},Dd={class:"text-right text-xs text-gray-500 dark:text-gray-400"},_d={key:3,class:"flex items-center justify-between rounded-lg border border-purple-200/70 bg-white/60 px-3 py-2 text-sm shadow-sm dark:border-purple-500/40 dark:bg-purple-950/20"},Sd={class:"font-semibold text-purple-600 dark:text-purple-300"},Td={key:4,class:"space-y-2"},Pd={__name:"UsageDetailModal",props:{show:{type:Boolean,required:!0},apiKey:{type:Object,required:!0}},emits:["close"],setup(v,{emit:H}){const c=v,M=H,N=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.total)==null?void 0:o.requests)||0}),$=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.daily)==null?void 0:o.requests)||0}),U=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.total)==null?void 0:o.tokens)||0}),B=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.daily)==null?void 0:o.tokens)||0}),T=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.total)==null?void 0:o.cost)||0}),J=R(()=>c.apiKey.dailyCost||0),Y=R(()=>c.apiKey.totalCostLimit||0),f=R(()=>c.apiKey.weeklyOpusCost||0),L=R(()=>c.apiKey.weeklyOpusCostLimit||0),p=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.total)==null?void 0:o.inputTokens)||0}),s=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.total)==null?void 0:o.outputTokens)||0}),V=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.total)==null?void 0:o.cacheCreateTokens)||0}),S=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.total)==null?void 0:o.cacheReadTokens)||0}),W=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.averages)==null?void 0:o.rpm)||0}),I=R(()=>{var k,o;return((o=(k=c.apiKey.usage)==null?void 0:k.averages)==null?void 0:o.tpm)||0}),K=R(()=>c.apiKey.dailyCostLimit>0||c.apiKey.totalCostLimit>0||c.apiKey.concurrencyLimit>0||c.apiKey.weeklyOpusCostLimit>0||c.apiKey.rateLimitWindow>0||c.apiKey.tokenLimit>0),se=R(()=>!c.apiKey.dailyCostLimit||c.apiKey.dailyCostLimit===0?0:J.value/c.apiKey.dailyCostLimit*100),ie=R(()=>!Y.value||Y.value===0?0:T.value/Y.value*100),de=R(()=>!L.value||L.value===0?0:f.value/L.value*100),pe=k=>!k&&k!==0?"0":k.toLocaleString("zh-CN"),X=k=>k>=1e6?(k/1e6).toFixed(1)+"M":k>=1e3?(k/1e3).toFixed(1)+"K":k.toString(),be=()=>{M("close")};return(k,o)=>(i(),ye(Ue,{to:"body"},[v.show?(i(),d("div",Fn,[e("div",{class:"fixed inset-0 bg-gray-900 bg-opacity-50 backdrop-blur-sm",onClick:be}),e("div",Bn,[e("div",Wn,[e("div",Nn,[o[0]||(o[0]=e("div",{class:"flex h-8 w-8 items-center justify-center rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 sm:h-10 sm:w-10 sm:rounded-xl"},[e("i",{class:"fas fa-chart-line text-sm text-white sm:text-base"})],-1)),e("h3",Hn," 使用统计详情 - "+u(v.apiKey.name),1)]),e("button",{class:"p-1 text-gray-400 transition-colors hover:text-gray-600",onClick:be},o[1]||(o[1]=[e("i",{class:"fas fa-times text-lg sm:text-xl"},null,-1)]))]),e("div",Yn,[e("div",Qn,[e("div",Jn,[o[2]||(o[2]=e("div",{class:"mb-3 flex items-center justify-between"},[e("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"总请求数"),e("i",{class:"fas fa-paper-plane text-blue-500"})],-1)),e("div",Xn,u(pe(N.value)),1),e("div",Zn," 今日: "+u(pe($.value))+" 次 ",1)]),e("div",ed,[o[3]||(o[3]=e("div",{class:"mb-3 flex items-center justify-between"},[e("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"总Token数"),e("i",{class:"fas fa-coins text-green-500"})],-1)),e("div",td,u(X(U.value)),1),e("div",sd," 今日: "+u(X(B.value)),1)]),e("div",ad,[o[4]||(o[4]=e("div",{class:"mb-3 flex items-center justify-between"},[e("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"总费用"),e("i",{class:"fas fa-dollar-sign text-yellow-600"})],-1)),e("div",rd," $"+u(T.value.toFixed(4)),1),e("div",od," 今日: $"+u(J.value.toFixed(4)),1)]),e("div",ld,[o[7]||(o[7]=e("div",{class:"mb-3 flex items-center justify-between"},[e("span",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},"平均速率"),e("i",{class:"fas fa-tachometer-alt text-purple-500"})],-1)),e("div",id,[e("div",nd,[o[5]||(o[5]=e("span",{class:"text-gray-600 dark:text-gray-400"},"RPM:",-1)),e("span",dd,u(W.value),1)]),e("div",ud,[o[6]||(o[6]=e("span",{class:"text-gray-600 dark:text-gray-400"},"TPM:",-1)),e("span",cd,u(I.value),1)])])])]),e("div",gd,[o[12]||(o[12]=e("h4",{class:"mb-3 flex items-center text-sm font-semibold text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-chart-pie mr-2 text-indigo-500"}),A(" Token 使用分布 ")],-1)),e("div",pd,[e("div",md,[o[8]||(o[8]=e("div",{class:"flex items-center"},[e("i",{class:"fas fa-arrow-down mr-2 text-green-500"}),e("span",{class:"text-sm text-gray-600 dark:text-gray-400"},"输入 Token")],-1)),e("span",xd,u(X(p.value)),1)]),e("div",yd,[o[9]||(o[9]=e("div",{class:"flex items-center"},[e("i",{class:"fas fa-arrow-up mr-2 text-blue-500"}),e("span",{class:"text-sm text-gray-600 dark:text-gray-400"},"输出 Token")],-1)),e("span",fd,u(X(s.value)),1)]),V.value>0?(i(),d("div",bd,[o[10]||(o[10]=e("div",{class:"flex items-center"},[e("i",{class:"fas fa-save mr-2 text-purple-500"}),e("span",{class:"text-sm text-gray-600 dark:text-gray-400"},"缓存创建 Token")],-1)),e("span",vd,u(X(V.value)),1)])):h("",!0),S.value>0?(i(),d("div",kd,[o[11]||(o[11]=e("div",{class:"flex items-center"},[e("i",{class:"fas fa-download mr-2 text-purple-500"}),e("span",{class:"text-sm text-gray-600 dark:text-gray-400"},"缓存读取 Token")],-1)),e("span",wd,u(X(S.value)),1)])):h("",!0)])]),K.value?(i(),d("div",hd,[o[15]||(o[15]=e("h4",{class:"mb-3 flex items-center text-sm font-semibold text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-shield-alt mr-2 text-red-500"}),A(" 限制设置 ")],-1)),e("div",Ad,[v.apiKey.dailyCostLimit>0?(i(),d("div",$d,[le(Pe,{current:J.value,label:"每日费用限制",limit:v.apiKey.dailyCostLimit,"show-shine":!0,type:"daily"},null,8,["current","limit"]),e("div",Cd," 已使用 "+u(Math.min(se.value,100).toFixed(1))+"% ",1)])):h("",!0),v.apiKey.weeklyOpusCostLimit>0?(i(),d("div",Id,[le(Pe,{current:f.value,label:"Opus 周费用限制",limit:v.apiKey.weeklyOpusCostLimit,"show-shine":!0,type:"opus"},null,8,["current","limit"]),e("div",Kd," 已使用 "+u(Math.min(de.value,100).toFixed(1))+"% ",1)])):h("",!0),v.apiKey.totalCostLimit>0?(i(),d("div",Ld,[le(Pe,{current:T.value,label:"总费用限制",limit:v.apiKey.totalCostLimit,"show-shine":!0,type:"total"},null,8,["current","limit"]),e("div",Dd," 已使用 "+u(Math.min(ie.value,100).toFixed(1))+"% ",1)])):h("",!0),v.apiKey.concurrencyLimit>0?(i(),d("div",_d,[o[13]||(o[13]=e("span",{class:"text-gray-600 dark:text-gray-300"},"并发限制",-1)),e("span",Sd,u(v.apiKey.currentConcurrency||0)+" / "+u(v.apiKey.concurrencyLimit),1)])):h("",!0),v.apiKey.rateLimitWindow>0?(i(),d("div",Td,[o[14]||(o[14]=e("h5",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-clock mr-1 text-blue-500"}),A(" 时间窗口限制 ")],-1)),le(Ys,{"cost-limit":v.apiKey.rateLimitCost,"current-cost":v.apiKey.currentWindowCost,"current-requests":v.apiKey.currentWindowRequests,"current-tokens":v.apiKey.currentWindowTokens,label:"窗口状态","rate-limit-window":v.apiKey.rateLimitWindow,"request-limit":v.apiKey.rateLimitRequests,"show-progress":!0,"show-tooltip":!0,"token-limit":v.apiKey.tokenLimit,"window-end-time":v.apiKey.windowEndTime,"window-remaining-seconds":v.apiKey.windowRemainingSeconds,"window-start-time":v.apiKey.windowStartTime},null,8,["cost-limit","current-cost","current-requests","current-tokens","rate-limit-window","request-limit","token-limit","window-end-time","window-remaining-seconds","window-start-time"])])):h("",!0)])])):h("",!0)]),e("div",{class:"mt-4 flex justify-end gap-2 sm:mt-6 sm:gap-3"},[e("button",{class:"btn btn-secondary px-4 py-2 text-sm",type:"button",onClick:be}," 关闭 ")])])])):h("",!0)]))}},Ud=_e(Pd,[["__scopeId","data-v-da99842f"]]),Md={class:"tab-content"},Vd={class:"card p-4 sm:p-6"},Rd={class:"mb-4 flex flex-col gap-4 sm:mb-6"},Ed={class:"border-b border-gray-200 dark:border-gray-700"},Od={"aria-label":"Tabs",class:"-mb-px flex space-x-8"},jd={key:0,class:"ml-2 rounded-full bg-gray-100 px-2.5 py-0.5 text-xs font-medium text-gray-900 dark:bg-gray-700 dark:text-gray-100"},Gd={key:0,class:"ml-2 rounded-full bg-gray-100 px-2.5 py-0.5 text-xs font-medium text-gray-900 dark:bg-gray-700 dark:text-gray-100"},qd={key:0,class:"tab-panel"},zd={class:"mb-4 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between"},Fd={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-3"},Bd={class:"group relative min-w-[140px]"},Wd={key:0,class:"flex items-center"},Nd={class:"group relative min-w-[140px]"},Hd={class:"relative"},Yd={key:0,class:"absolute -right-2 -top-2 z-10 flex h-5 w-5 items-center justify-center rounded-full bg-purple-500 text-xs text-white shadow-sm"},Qd={class:"flex min-w-[240px] flex-col gap-2 sm:flex-row sm:items-center"},Jd={class:"sm:w-44"},Xd={class:"group relative flex-1"},Zd={class:"relative flex items-center"},e0=["placeholder"],t0={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:gap-3"},s0=["disabled"],a0={class:"relative"},r0={class:"relative"},o0={key:0,class:"py-12 text-center"},l0={key:1,class:"py-12 text-center"},i0={key:2,class:"table-wrapper hidden md:block"},n0={class:"table-container"},d0={class:"w-full table-fixed"},u0={class:"sticky top-0 z-10 bg-gradient-to-b from-gray-50 to-gray-100/90 backdrop-blur-sm dark:from-gray-700 dark:to-gray-800/90"},c0={key:0,class:"w-[50px] px-3 py-4 text-left"},g0={class:"flex items-center"},p0=["indeterminate"],m0={key:1,class:"fas fa-sort ml-1 text-gray-400"},x0={key:1,class:"fas fa-sort ml-1 text-gray-400"},y0={key:1,class:"fas fa-sort ml-1 text-gray-400"},f0={key:1,class:"fas fa-sort ml-1 text-gray-400"},b0={key:1,class:"fas fa-sort ml-1 text-gray-400"},v0={key:0,class:"px-3 py-3"},k0={class:"flex items-center"},w0=["value"],h0={class:"px-3 py-3"},A0={class:"min-w-0"},$0=["title"],C0={key:0,class:"mt-1 text-xs text-red-600"},I0={class:"px-3 py-3"},K0={class:"space-y-1"},L0={key:0,class:"flex items-center gap-1 text-xs"},D0={class:"truncate text-gray-600 dark:text-gray-400"},_0={key:1,class:"flex items-center gap-1 text-xs"},S0={class:"truncate text-gray-600 dark:text-gray-400"},T0={key:2,class:"flex items-center gap-1 text-xs"},P0={class:"truncate text-gray-600 dark:text-gray-400"},U0={key:3,class:"flex items-center gap-1 text-xs"},M0={class:"truncate text-gray-600 dark:text-gray-400"},V0={key:4,class:"flex items-center gap-1 text-xs"},R0={class:"truncate text-gray-600 dark:text-gray-400"},E0={key:5,class:"text-xs text-gray-500 dark:text-gray-400"},O0={class:"px-3 py-3"},j0={class:"flex flex-wrap gap-1"},G0={key:0,class:"text-xs text-gray-400"},q0={class:"whitespace-nowrap px-3 py-3"},z0={class:"whitespace-nowrap px-3 py-3 text-right",style:{"font-size":"13px"}},F0={key:0,class:"flex items-center justify-end"},B0={key:1,class:"font-semibold text-blue-600 dark:text-blue-400",style:{"font-size":"14px"}},W0={key:2,class:"text-gray-400"},N0={class:"px-2 py-2",style:{"font-size":"12px"}},H0={class:"flex flex-col gap-2"},Y0={key:2,class:"space-y-1.5"},Q0={class:"flex items-center justify-between text-[10px]"},J0={class:"flex items-center gap-1 text-sky-600 dark:text-sky-300"},X0={class:"font-medium"},Z0={key:3,class:"flex items-center justify-center gap-1.5 py-2 text-gray-500 dark:text-gray-400"},eu={class:"whitespace-nowrap px-3 py-3 text-right",style:{"font-size":"13px"}},tu={key:0,class:"flex items-center justify-end"},su={key:1,class:"flex items-center justify-end gap-1"},au={class:"font-medium text-purple-600 dark:text-purple-400",style:{"font-size":"13px"}},ru={key:2,class:"text-gray-400"},ou={class:"whitespace-nowrap px-3 py-3 text-right",style:{"font-size":"13px"}},lu={key:0,class:"flex items-center justify-end"},iu={key:1,class:"flex items-center justify-end gap-1"},nu={class:"font-medium text-gray-900 dark:text-gray-100",style:{"font-size":"13px"}},du={key:2,class:"text-gray-400"},uu={class:"whitespace-nowrap px-3 py-3 text-gray-700 dark:text-gray-300",style:{"font-size":"13px"}},cu={class:"flex flex-col leading-tight"},gu=["title"],pu={key:1,class:"text-gray-400",style:{"font-size":"13px"}},mu=["title"],xu={key:0,class:"ml-1 text-gray-400 dark:text-gray-500"},yu={key:3,class:"mt-1 text-xs text-gray-400 dark:text-gray-500"},fu={class:"whitespace-nowrap px-3 py-3 text-gray-700 dark:text-gray-300",style:{"font-size":"13px"}},bu={class:"whitespace-nowrap px-3 py-3 text-sm text-gray-700 dark:text-gray-300"},vu={class:"inline-flex items-center gap-1.5"},ku={key:0,class:"inline-flex items-center text-blue-600 dark:text-blue-400",style:{"font-size":"13px"}},wu={key:1},hu=["onClick"],Au=["onClick"],$u=["onClick"],Cu=["onClick"],Iu={class:"operations-column operations-cell whitespace-nowrap px-3 py-3",style:{"font-size":"13px"}},Ku={class:"flex gap-1"},Lu=["onClick"],Du=["onClick"],_u=["onClick"],Su=["onClick"],Tu=["title","onClick"],Pu={class:"ml-1 hidden xl:inline"},Uu=["onClick"],Mu={key:0},Vu={class:"bg-gray-50 px-3 py-3 dark:bg-gray-700",colspan:"13"},Ru={key:0,class:"py-4 text-center"},Eu={class:"space-y-4"},Ou={class:"mb-4 flex items-center justify-between"},ju={class:"flex items-center gap-2"},Gu={key:0,class:"rounded-full bg-gray-100 px-2 py-1 text-xs text-gray-500 dark:bg-gray-700 dark:text-gray-400"},qu={class:"flex items-center gap-1"},zu={class:"flex gap-1 rounded bg-gray-100 p-1 dark:bg-gray-700"},Fu=["onClick"],Bu={key:0,class:"py-8 text-center"},Wu={class:"mb-3 flex items-center justify-center gap-2"},Nu=["onClick"],Hu={key:1,class:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3"},Yu={class:"mb-3 flex items-start justify-between"},Qu={class:"flex-1"},Ju={class:"mb-1 block text-sm font-semibold text-gray-800 dark:text-gray-200"},Xu={class:"rounded-full bg-blue-50 px-2 py-1 text-xs text-gray-500 dark:bg-blue-900/30 dark:text-gray-400"},Zu={class:"mb-3 space-y-2"},ec={class:"flex items-center justify-between text-sm"},tc={class:"font-semibold text-gray-900 dark:text-gray-100"},sc={class:"flex items-center justify-between text-sm"},ac={class:"font-semibold text-green-600"},rc={class:"mt-2 border-t border-gray-100 pt-2 dark:border-gray-600"},oc={class:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400"},lc={class:"font-medium"},ic={class:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400"},nc={class:"font-medium"},dc={key:0,class:"flex items-center justify-between text-xs text-purple-600"},uc={class:"font-medium"},cc={key:1,class:"flex items-center justify-between text-xs text-purple-600"},gc={class:"font-medium"},pc={class:"mt-3 h-2 w-full rounded-full bg-gray-200 dark:bg-gray-700"},mc={class:"mt-1 text-right"},xc={class:"text-xs font-medium text-indigo-600"},yc={key:2,class:"mt-4 rounded-lg border border-indigo-100 bg-gradient-to-r from-indigo-50 to-purple-50 p-3 dark:border-indigo-700 dark:from-indigo-900/20 dark:to-purple-900/20"},fc={class:"flex items-center justify-between text-sm"},bc={class:"flex gap-4 text-xs"},vc={class:"text-gray-600 dark:text-gray-400"},kc={class:"font-semibold text-gray-800 dark:text-gray-200"},wc={class:"text-gray-600 dark:text-gray-400"},hc={class:"font-semibold text-gray-800 dark:text-gray-200"},Ac={key:3,class:"space-y-3 md:hidden"},$c={class:"mb-3 flex items-start justify-between"},Cc={class:"flex items-center gap-3"},Ic=["value"],Kc={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Lc={class:"mt-0.5 text-xs text-gray-500 dark:text-gray-400"},Dc={class:"mb-3 space-y-1.5"},_c={key:0,class:"flex flex-wrap items-center gap-1 text-xs"},Sc={class:"text-gray-600 dark:text-gray-400"},Tc={key:1,class:"flex flex-wrap items-center gap-1 text-xs"},Pc={class:"text-gray-600 dark:text-gray-400"},Uc={key:2,class:"flex flex-wrap items-center gap-1 text-xs"},Mc={class:"text-gray-600 dark:text-gray-400"},Vc={key:3,class:"flex flex-wrap items-center gap-1 text-xs"},Rc={class:"text-gray-600 dark:text-gray-400"},Ec={key:4,class:"flex flex-wrap items-center gap-1 text-xs"},Oc={class:"text-gray-600 dark:text-gray-400"},jc={key:5,class:"text-xs text-gray-500 dark:text-gray-400"},Gc={key:6,class:"text-xs text-red-600"},qc={class:"mb-3 space-y-2"},zc={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-700"},Fc={class:"mb-2 flex items-center justify-between"},Bc={class:"text-xs text-gray-600 dark:text-gray-400"},Wc=["onClick"],Nc={class:"grid grid-cols-2 gap-3"},Hc={key:0,class:"text-sm font-semibold text-gray-400"},Yc={key:1,class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Qc={key:2,class:"text-sm font-semibold text-gray-400"},Jc={key:0,class:"text-sm font-semibold text-gray-400"},Xc={key:1,class:"text-sm font-semibold text-green-600"},Zc={key:2,class:"text-sm font-semibold text-gray-400"},eg={class:"mt-2 text-xs text-gray-600 dark:text-gray-400"},tg={class:"flex items-center justify-between"},sg={class:"font-medium text-gray-700 dark:text-gray-300"},ag={class:"mt-1 flex items-center justify-between"},rg=["title"],og={key:0,class:"ml-1 text-gray-400 dark:text-gray-500"},lg={key:1,class:"text-gray-400 dark:text-gray-500"},ig={class:"space-y-2"},ng={key:2,class:"space-y-2"},dg={class:"flex items-center justify-between text-xs"},ug={class:"flex items-center gap-1.5 text-sky-600 dark:text-sky-300"},cg={class:"font-medium"},gg={key:3,class:"flex items-center justify-center gap-1.5 py-2 text-gray-500 dark:text-gray-400"},pg={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},mg={class:"mb-1 flex justify-between"},xg={class:"flex items-center justify-between"},yg={class:"flex items-center gap-1"},fg=["onClick"],bg={key:0,class:"mb-3 flex flex-wrap gap-1"},vg={class:"mt-3 flex gap-2 border-t border-gray-100 pt-3 dark:border-gray-600"},kg=["onClick"],wg=["onClick"],hg=["onClick"],Ag=["onClick"],$g=["onClick"],Cg={key:4,class:"mt-4 flex flex-col items-center justify-between gap-4 sm:mt-6 sm:flex-row"},Ig={class:"flex w-full flex-col items-center gap-3 sm:w-auto sm:flex-row"},Kg={class:"text-xs text-gray-600 dark:text-gray-400 sm:text-sm"},Lg={class:"flex items-center gap-2"},Dg=["value"],_g={class:"flex items-center gap-2"},Sg=["disabled"],Tg={class:"flex items-center gap-1"},Pg={key:1,class:"hidden px-2 text-gray-500 dark:text-gray-400 sm:inline"},Ug=["onClick"],Mg={key:2,class:"hidden px-2 text-gray-500 dark:text-gray-400 sm:inline"},Vg=["disabled"],Rg={key:1,class:"tab-panel"},Eg={key:0,class:"py-12 text-center"},Og={key:1,class:"py-12 text-center"},jg={key:2},Gg={class:"mb-4 flex justify-end"},qg={class:"table-wrapper"},zg={class:"table-container"},Fg={class:"w-full table-fixed"},Bg={class:"bg-gray-50/80 backdrop-blur-sm dark:bg-gray-700/80"},Wg={key:0,class:"w-[15%] min-w-[120px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"},Ng={class:"divide-y divide-gray-200/50 dark:divide-gray-600/50"},Hg={class:"px-3 py-3"},Yg={class:"flex items-center"},Qg={class:"min-w-0"},Jg=["title"],Xg={class:"px-3 py-3"},Zg={class:"space-y-1"},ep={key:0,class:"flex items-center gap-1 text-xs"},tp={key:1,class:"flex items-center gap-1 text-xs"},sp={key:2,class:"flex items-center gap-1 text-xs"},ap={key:3,class:"text-xs text-gray-500 dark:text-gray-400"},rp={key:0,class:"px-3 py-3"},op={class:"text-xs"},lp={key:0,class:"text-blue-600"},ip={key:1,class:"text-green-600"},np={key:2,class:"text-gray-500 dark:text-gray-400"},dp={class:"whitespace-nowrap px-3 py-3 text-gray-700 dark:text-gray-300",style:{"font-size":"13px"}},up={class:"px-3 py-3"},cp={class:"text-xs"},gp={key:0,class:"text-blue-600"},pp={key:1,class:"text-green-600"},mp={key:2,class:"text-gray-500 dark:text-gray-400"},xp={class:"whitespace-nowrap px-3 py-3 text-gray-700 dark:text-gray-300",style:{"font-size":"13px"}},yp={class:"whitespace-nowrap px-3 py-3 text-right",style:{"font-size":"13px"}},fp={class:"font-medium text-blue-600 dark:text-blue-400",style:{"font-size":"13px"}},bp={class:"whitespace-nowrap px-3 py-3 text-right",style:{"font-size":"13px"}},vp={class:"font-medium text-purple-600 dark:text-purple-400",style:{"font-size":"13px"}},kp={class:"whitespace-nowrap px-3 py-3 text-right",style:{"font-size":"13px"}},wp={class:"flex items-center justify-end gap-1"},hp={class:"font-medium text-gray-900 dark:text-gray-100",style:{"font-size":"13px"}},Ap={class:"whitespace-nowrap px-3 py-3 text-gray-700 dark:text-gray-300",style:{"font-size":"13px"}},$p={class:"flex flex-col leading-tight"},Cp=["title"],Ip={key:1,class:"text-gray-400",style:{"font-size":"13px"}},Kp=["title"],Lp={key:0,class:"ml-1 text-gray-400 dark:text-gray-500"},Dp={key:3,class:"mt-1 text-xs text-gray-400 dark:text-gray-500"},_p={class:"operations-column operations-cell px-3 py-3"},Sp={class:"flex items-center gap-2"},Tp=["onClick"],Pp=["onClick"],ns=16,Up={__name:"ApiKeysView",setup(v){const H=Lt(),c=Hs(),M=D([]),N=R(()=>{var a;return((a=c.oemSettings)==null?void 0:a.ldapEnabled)||!1}),$=D([]),U=D(!1),B=D(!1),T=D(!1),J=D(!1),Y=D("today"),f=ze({type:"preset",preset:"today",customStart:"",customEnd:"",customRange:null}),L=R(()=>T.value),p=()=>{T.value=!T.value,T.value||($.value=[],U.value=!1,B.value=!1)},s=R(()=>[{value:"today",label:"今日",icon:"fa-calendar-day"},{value:"7days",label:"最近7天",icon:"fa-calendar-week"},{value:"30days",label:"最近30天",icon:"fa-calendar-alt"},{value:"all",label:"全部时间",icon:"fa-infinity"},{value:"custom",label:"自定义范围",icon:"fa-calendar-check"}]),V=D("active"),S=D([]),W=D(!1),I=D("createdAt"),K=D("desc"),se=D({}),ie=D({page:1,pageSize:20,total:0,totalPages:0}),de=D(new Map),pe=D(new Set),X=D({}),be=D({}),k=D([new Date(2e3,1,1,0,0,0),new Date(2e3,2,1,23,59,59)]),o=D({claude:[],gemini:[],openai:[],openaiResponses:[],bedrock:[],droid:[],claudeGroups:[],geminiGroups:[],openaiGroups:[],droidGroups:[]}),n=D(null),m=D(null),C=D(!1),g=D(null),l=D(""),y=D([]),ae=D(""),ue=D("apiKey"),ge=R(()=>[{value:"apiKey",label:"按Key名称",icon:"fa-key"},{value:"bindingAccount",label:"按所属账号",icon:"fa-id-badge"}]),ve=R(()=>{const a=[{value:"",label:"所有标签",icon:"fa-asterisk"}];return y.value.forEach(t=>{a.push({value:t,label:t,icon:"fa-tag"})}),a}),fe=R(()=>l.value?M.value.filter(a=>a.tags&&a.tags.includes(l.value)).length:0),F=D(1),me=D((()=>{const a=localStorage.getItem("apiKeysPageSize");if(a){const t=parseInt(a,10);if([10,20,50,100].includes(t))return t}return 10})()),Fe=[10,20,50,100],re=D(!1),Ie=D(!1),at=D(!1),mt=D(!1),xt=D(!1),rt=D(!1),_t=D(null),St=D(null),Tt=D(null),Pt=D([]),ot=R(()=>M.value),Ee=R(()=>ie.value.totalPages||0),Be=R(()=>{const a=[],t=F.value,x=Ee.value;if(x<=7)for(let r=1;r<=x;r++)a.push(r);else{let r=Math.max(1,t-2),b=Math.min(x,t+2);t<=3?b=5:t>=x-2&&(r=x-4);for(let G=r;G<=b;G++)a.push(G)}return a}),Ut=R(()=>{const a=Be.value;return a.length===0?!1:a[0]>1}),Mt=R(()=>{const a=Be.value;return a.length===0?!1:a[a.length-1]<Ee.value}),us=R(()=>{const a=Be.value;return a.length===0?!1:Ut.value&&a[0]>2}),cs=R(()=>{const a=Be.value;return a.length===0?!1:Mt.value&&a[a.length-1]<Ee.value-1}),je=R(()=>M.value),lt=async()=>{var a,t;try{const[x,r,b,G,j,P,E,ce,w]=await Promise.all([q.get("/admin/claude-accounts"),q.get("/admin/claude-console-accounts"),q.get("/admin/gemini-accounts"),q.get("/admin/gemini-api-accounts"),q.get("/admin/openai-accounts"),q.get("/admin/openai-responses-accounts"),q.get("/admin/bedrock-accounts"),q.get("/admin/droid-accounts"),q.get("/admin/account-groups")]),we=[];x.success&&((a=x.data)==null||a.forEach(Z=>{we.push({...Z,platform:"claude-oauth",isDedicated:Z.accountType==="dedicated"})})),r.success&&((t=r.data)==null||t.forEach(Z=>{we.push({...Z,platform:"claude-console",isDedicated:Z.accountType==="dedicated"})})),o.value.claude=we;const xe=[];if(b.success&&(b.data||[]).forEach(Z=>{xe.push({...Z,platform:"gemini",isDedicated:Z.accountType==="dedicated"})}),G.success&&(G.data||[]).forEach(Z=>{xe.push({...Z,platform:"gemini-api",isDedicated:Z.accountType==="dedicated"})}),o.value.gemini=xe,j.success&&(o.value.openai=(j.data||[]).map(Z=>({...Z,isDedicated:Z.accountType==="dedicated"}))),P.success&&(o.value.openaiResponses=(P.data||[]).map(Z=>({...Z,isDedicated:Z.accountType==="dedicated"}))),E.success&&(o.value.bedrock=(E.data||[]).map(Z=>({...Z,isDedicated:Z.accountType==="dedicated"}))),ce.success&&(o.value.droid=(ce.data||[]).map(Z=>({...Z,platform:"droid",isDedicated:Z.accountType==="dedicated"}))),w.success){const Z=w.data||[];o.value.claudeGroups=Z.filter(Le=>Le.platform==="claude"),o.value.geminiGroups=Z.filter(Le=>Le.platform==="gemini"),o.value.openaiGroups=Z.filter(Le=>Le.platform==="openai"),o.value.droidGroups=Z.filter(Le=>Le.platform==="droid")}}catch{}},ke=async(a=!0)=>{var t,x,r;J.value=!0;try{a&&de.value.clear();const b=new URLSearchParams;b.set("page",F.value.toString()),b.set("pageSize",me.value.toString()),b.set("searchMode",ue.value),ae.value&&b.set("search",ae.value),l.value&&b.set("tag",l.value);const j=["name","createdAt","expiresAt","lastUsedAt","isActive","status"].includes(I.value)?I.value:"createdAt";b.set("sortBy",j),b.set("sortOrder",K.value),f.type==="custom"&&f.customStart&&f.customEnd?(b.set("startDate",f.customStart),b.set("endDate",f.customEnd),b.set("timeRange","custom")):f.preset==="all"?b.set("timeRange","all"):b.set("timeRange",f.preset);const P=await q.get(`/admin/api-keys?${b.toString()}`);P.success&&(M.value=((t=P.data)==null?void 0:t.items)||[],(x=P.data)!=null&&x.pagination&&(ie.value=P.data.pagination,F.value>ie.value.totalPages&&ie.value.totalPages>0&&(F.value=ie.value.totalPages)),(r=P.data)!=null&&r.availableTags&&(y.value=P.data.availableTags),await gs())}catch(b){console.error("加载 API Keys 失败:",b),O("加载 API Keys 失败","error")}finally{J.value=!1}},gs=async()=>{const a=M.value;if(!a||a.length===0)return;let t=f.preset,x=null,r=null;f.type==="custom"&&f.customStart&&f.customEnd&&(t="custom",x=f.customStart,r=f.customEnd);const b=a.filter(j=>{const P=de.value.get(j.id);return!P||P.timeRange!==t||t==="custom"&&(P.startDate!==x||P.endDate!==r)});if(b.length===0)return;const G=b.map(j=>j.id);G.forEach(j=>pe.value.add(j));try{const j={keyIds:G,timeRange:t};t==="custom"&&(j.startDate=x,j.endDate=r);const P=await q.post("/admin/api-keys/batch-stats",j);if(P.success&&P.data)for(const[E,ce]of Object.entries(P.data))de.value.set(E,{stats:ce,timeRange:t,startDate:x,endDate:r,timestamp:Date.now()})}catch(j){console.error("加载统计数据失败:",j)}finally{G.forEach(j=>pe.value.delete(j))}},Ke=a=>{const t=de.value.get(a);return(t==null?void 0:t.stats)||null},We=a=>pe.value.has(a),it=async()=>{V.value="deleted",W.value=!0;try{const a=await q.get("/admin/api-keys/deleted");a.success&&(S.value=a.apiKeys||[])}catch{O("加载已删除的 API Keys 失败","error")}finally{W.value=!1}},Ne=a=>{I.value===a?K.value=K.value==="asc"?"desc":"asc":(I.value=a,K.value="asc")},yt=a=>!a&&a!==0?"0":a.toLocaleString("zh-CN"),$e=a=>!a&&a!==0?"0":a>=1e6?(a/1e6).toFixed(1)+"M":a>=1e3?(a/1e3).toFixed(1)+"K":a.toString(),He=a=>{if(!a)return"未知账户";if(a.startsWith("group:")){const P=a.substring(6),E=o.value.claudeGroups.find(xe=>xe.id===P);if(E)return`分组-${E.name}`;const ce=o.value.geminiGroups.find(xe=>xe.id===P);if(ce)return`分组-${ce.name}`;const w=o.value.openaiGroups.find(xe=>xe.id===P);if(w)return`分组-${w.name}`;const we=o.value.droidGroups.find(xe=>xe.id===P);return we?`分组-${we.name}`:`分组-${P.substring(0,8)}`}const t=o.value.claude.find(P=>P.id===a);if(t)return`${t.name}`;if(a.startsWith("api:")){const P=a.replace("api:",""),E=o.value.gemini.find(ce=>ce.id===P&&ce.platform==="gemini-api");return E?`${E.name}`:`${P.substring(0,8)}`}const x=o.value.gemini.find(P=>P.id===a);if(x)return`${x.name}`;if(a.startsWith("responses:")){const P=a.replace("responses:",""),E=o.value.openaiResponses.find(ce=>ce.id===P);return E?`${E.name}`:`${P.substring(0,8)}`}const r=o.value.openai.find(P=>P.id===a);if(r)return`${r.name}`;const b=o.value.openaiResponses.find(P=>P.id===a);if(b)return`${b.name}`;const G=o.value.bedrock.find(P=>P.id===a);if(G)return`${G.name}`;const j=o.value.droid.find(P=>P.id===a);return j?`${j.name}`:`${a.substring(0,8)}`},Vt=a=>{if(a.claudeAccountId){const t=He(a.claudeAccountId);if(a.claudeAccountId.startsWith("group:"))return t;const x=o.value.claude.find(r=>r.id===a.claudeAccountId);return x?x.accountType==="dedicated"?`🔒 专属-${t}`:t:`⚠️ ${t} (账户不存在)`}if(a.claudeConsoleAccountId){const t=o.value.claude.find(x=>x.id===a.claudeConsoleAccountId&&x.platform==="claude-console");return t?`Console-${t.name}`:"⚠️ Console账户不存在"}return""},Rt=a=>{if(a.geminiAccountId){const t=He(a.geminiAccountId);if(a.geminiAccountId.startsWith("group:"))return t;if(a.geminiAccountId.startsWith("api:")){const r=a.geminiAccountId.replace("api:",""),b=o.value.gemini.find(G=>G.id===r&&G.platform==="gemini-api");return b?b.accountType==="dedicated"?`🔒 API专属-${t}`:`API-${t}`:`⚠️ ${t} (账户不存在)`}const x=o.value.gemini.find(r=>r.id===a.geminiAccountId);return x?x.accountType==="dedicated"?`🔒 专属-${t}`:t:`⚠️ ${t} (账户不存在)`}return""},Et=a=>{if(a.openaiAccountId){const t=He(a.openaiAccountId);if(a.openaiAccountId.startsWith("group:"))return t;let x=null;if(a.openaiAccountId.startsWith("responses:")){const r=a.openaiAccountId.replace("responses:","");x=o.value.openaiResponses.find(b=>b.id===r)}else x=o.value.openai.find(r=>r.id===a.openaiAccountId);return x?x.accountType==="dedicated"?`🔒 专属-${t}`:t:`⚠️ ${t} (账户不存在)`}return""},Ot=a=>{if(a.bedrockAccountId){const t=He(a.bedrockAccountId);if(a.bedrockAccountId.startsWith("group:"))return t;const x=o.value.bedrock.find(r=>r.id===a.bedrockAccountId);return x?x.accountType==="dedicated"?`🔒 专属-${t}`:t:`⚠️ ${t} (账户不存在)`}return""},jt=a=>{if(a.droidAccountId){const t=He(a.droidAccountId);if(a.droidAccountId.startsWith("group:"))return t;const x=o.value.droid.find(r=>r.id===a.droidAccountId);return x?x.accountType==="dedicated"?`🔒 专属-${t}`:t:`⚠️ ${t} (账户不存在)`}return""},nt=a=>a?new Date(a)<new Date:!1,dt=a=>!a||nt(a)?!1:(new Date(a)-new Date)/(1e3*60*60*24)<=7,Gt=a=>a?new Date(a).toLocaleDateString("zh-CN"):"",ps=async a=>{se.value[a]?se.value[a]=!1:(se.value[a]=!0,be.value[a]||Ft(a),await ut(a,!0))},ut=async(a,t=!1)=>{if(!t&&X.value[a]&&X.value[a].length>0)return;const x=Me(a);try{let r=`/admin/api-keys/${a}/model-stats`;const b=new URLSearchParams;if(x.customStart&&x.customEnd)b.append("startDate",x.customStart),b.append("endDate",x.customEnd),b.append("period","custom");else{const j=x.preset==="today"||x.preset==="7days"?"daily":"monthly";b.append("period",j)}r+="?"+b.toString();const G=await q.get(r);G.success&&(X.value[a]=G.data||[])}catch{O("加载模型统计失败","error"),X.value[a]=[]}},qt=(a,t)=>{const x=t.reduce((r,b)=>r+(b.allTokens||0),0);return x===0?0:Math.round(a/x*100)},ms=a=>a.formatted&&a.formatted.total?a.formatted.total:a.cost!==void 0?`$${a.cost.toFixed(6)}`:"$0.000000",xs=a=>{var t,x,r,b,G,j;if(f.type==="custom"){if(a.usage){if(a.usage.custom&&a.usage.custom.requests!==void 0)return a.usage.custom.requests;if(a.usage.total&&a.usage.total.requests!==void 0)return a.usage.total.requests}return 0}else{if(f.preset==="today")return((x=(t=a.usage)==null?void 0:t.daily)==null?void 0:x.requests)||0;if(f.preset==="7days")return a.usage&&a.usage["7days"]&&a.usage["7days"].requests!==void 0?a.usage["7days"].requests:0;if(f.preset==="30days"){if(a.usage){if(a.usage["30days"]&&a.usage["30days"].requests!==void 0)return a.usage["30days"].requests;if(a.usage.monthly&&a.usage.monthly.requests!==void 0)return a.usage.monthly.requests}return 0}else return f.preset==="all"?a.usage&&a.usage.all&&a.usage.all.requests!==void 0?a.usage.all.requests:((b=(r=a.usage)==null?void 0:r.total)==null?void 0:b.requests)||0:((j=(G=a.usage)==null?void 0:G.total)==null?void 0:j.requests)||0}},ys=a=>{if(f.type==="custom"){if(a.usage){if(a.usage.custom&&a.usage.custom.cost!==void 0)return a.usage.custom.cost;if(a.usage.total&&a.usage.total.cost!==void 0)return a.usage.total.cost}return 0}else{if(f.preset==="today")return a.dailyCost||0;if(f.preset==="7days")return a.usage&&a.usage["7days"]&&a.usage["7days"].cost!==void 0?a.usage["7days"].cost:a.weeklyCost||a.periodCost||0;if(f.preset==="30days"){if(a.usage){if(a.usage["30days"]&&a.usage["30days"].cost!==void 0)return a.usage["30days"].cost;if(a.usage.monthly&&a.usage.monthly.cost!==void 0)return a.usage.monthly.cost;if(a.usage.total&&a.usage.total.cost!==void 0)return a.usage.total.cost}return a.monthlyCost||a.periodCost||0}else return f.preset==="all"?a.usage&&a.usage.all&&a.usage.all.cost!==void 0?a.usage.all.cost:a.totalCost||0:a.periodCost||a.totalCost||0}},fs=a=>{var t,x,r,b,G,j;if(f.type==="custom"){if(a.usage){if(a.usage.custom&&a.usage.custom.tokens!==void 0)return a.usage.custom.tokens;if(a.usage.total&&a.usage.total.tokens!==void 0)return a.usage.total.tokens}return 0}else{if(f.preset==="today")return((x=(t=a.usage)==null?void 0:t.daily)==null?void 0:x.tokens)||0;if(f.preset==="7days")return a.usage&&a.usage["7days"]&&a.usage["7days"].tokens!==void 0?a.usage["7days"].tokens:0;if(f.preset==="30days"){if(a.usage){if(a.usage["30days"]&&a.usage["30days"].tokens!==void 0)return a.usage["30days"].tokens;if(a.usage.monthly&&a.usage.monthly.tokens!==void 0)return a.usage.monthly.tokens;if(a.usage.total&&a.usage.total.tokens!==void 0)return a.usage.total.tokens}return 0}else return f.preset==="all"?a.usage&&a.usage.all&&a.usage.all.tokens!==void 0?a.usage.all.tokens:((b=(r=a.usage)==null?void 0:r.total)==null?void 0:b.tokens)||0:((j=(G=a.usage)==null?void 0:G.total)==null?void 0:j.tokens)||0}},bs=a=>{var t,x,r,b,G,j;if(f.type==="custom"){if(a.usage){if(a.usage.custom&&a.usage.custom.inputTokens!==void 0)return a.usage.custom.inputTokens;if(a.usage.total&&a.usage.total.inputTokens!==void 0)return a.usage.total.inputTokens}return 0}else{if(f.preset==="today")return((x=(t=a.usage)==null?void 0:t.daily)==null?void 0:x.inputTokens)||0;if(f.preset==="7days")return a.usage&&a.usage["7days"]&&a.usage["7days"].inputTokens!==void 0?a.usage["7days"].inputTokens:0;if(f.preset==="30days"){if(a.usage){if(a.usage["30days"]&&a.usage["30days"].inputTokens!==void 0)return a.usage["30days"].inputTokens;if(a.usage.monthly&&a.usage.monthly.inputTokens!==void 0)return a.usage.monthly.inputTokens;if(a.usage.total&&a.usage.total.inputTokens!==void 0)return a.usage.total.inputTokens}return 0}else return f.preset==="all"?a.usage&&a.usage.all&&a.usage.all.inputTokens!==void 0?a.usage.all.inputTokens:((b=(r=a.usage)==null?void 0:r.total)==null?void 0:b.inputTokens)||0:((j=(G=a.usage)==null?void 0:G.total)==null?void 0:j.inputTokens)||0}},vs=a=>{var t,x,r,b,G,j;if(f.type==="custom"){if(a.usage){if(a.usage.custom&&a.usage.custom.outputTokens!==void 0)return a.usage.custom.outputTokens;if(a.usage.total&&a.usage.total.outputTokens!==void 0)return a.usage.total.outputTokens}return 0}else{if(f.preset==="today")return((x=(t=a.usage)==null?void 0:t.daily)==null?void 0:x.outputTokens)||0;if(f.preset==="7days")return a.usage&&a.usage["7days"]&&a.usage["7days"].outputTokens!==void 0?a.usage["7days"].outputTokens:0;if(f.preset==="30days"){if(a.usage){if(a.usage["30days"]&&a.usage["30days"].outputTokens!==void 0)return a.usage["30days"].outputTokens;if(a.usage.monthly&&a.usage.monthly.outputTokens!==void 0)return a.usage.monthly.outputTokens;if(a.usage.total&&a.usage.total.outputTokens!==void 0)return a.usage.total.outputTokens}return 0}else return f.preset==="all"?a.usage&&a.usage.all&&a.usage.all.outputTokens!==void 0?a.usage.all.outputTokens:((b=(r=a.usage)==null?void 0:r.total)==null?void 0:b.outputTokens)||0:((j=(G=a.usage)==null?void 0:G.total)==null?void 0:j.outputTokens)||0}},ks=a=>{if(!X.value[a.id])return ys(a);const t=X.value[a.id]||[];let x=0;return t.forEach(r=>{if(r.cost!==void 0)x+=r.cost;else if(r.formatted&&r.formatted.total){const b=r.formatted.total.replace("$","").replace(",",""),G=parseFloat(b);isNaN(G)||(x+=G)}}),x},ws=a=>{zt(a)},zt=a=>{if(f.preset=a,a==="custom"){if(f.type="custom",!f.customRange){const t=new Date,x=new Date(t);x.setDate(t.getDate()-6);const r=b=>b.getFullYear()+"-"+String(b.getMonth()+1).padStart(2,"0")+"-"+String(b.getDate()).padStart(2,"0")+" 00:00:00";f.customRange=[r(x),r(t)],f.customStart=x.toISOString().split("T")[0],f.customEnd=t.toISOString().split("T")[0]}}else if(a==="all")f.type="preset",f.customStart=null,f.customEnd=null;else{f.type="preset";const t=new Date,x=new Date(t);a==="today"?x.setHours(0,0,0,0):a==="7days"?x.setDate(t.getDate()-6):a==="30days"&&x.setDate(t.getDate()-29),f.customStart=x.toISOString().split("T")[0],f.customEnd=t.toISOString().split("T")[0]}ke()},hs=a=>{a&&a.length===2?(f.type="custom",f.preset="custom",f.customRange=a,f.customStart=a[0].split(" ")[0],f.customEnd=a[1].split(" ")[0],ke()):a===null&&zt("today")},Ft=a=>{const t=new Date;new Date(t).setHours(0,0,0,0),be.value[a]={type:"preset",preset:"today",customStart:t.toISOString().split("T")[0],customEnd:t.toISOString().split("T")[0],customRange:null,presetOptions:[{value:"today",label:"今日",days:1},{value:"7days",label:"7天",days:7},{value:"30days",label:"30天",days:30},{value:"custom",label:"自定义",days:-1}]}},Me=a=>(be.value[a]||Ft(a),be.value[a]),Bt=(a,t)=>{const x=Me(t);x.type="preset",x.preset=a;const r=x.presetOptions.find(b=>b.value===a);if(r)if(a==="custom"){if(x.type="custom",!x.customRange){const b=new Date,G=new Date(b);G.setDate(b.getDate()-6);const j=P=>P.getFullYear()+"-"+String(P.getMonth()+1).padStart(2,"0")+"-"+String(P.getDate()).padStart(2,"0")+" 00:00:00";x.customRange=[j(G),j(b)],x.customStart=G.toISOString().split("T")[0],x.customEnd=b.toISOString().split("T")[0]}}else{const b=new Date,G=new Date(b);G.setDate(b.getDate()-(r.days-1)),x.customStart=G.toISOString().split("T")[0],x.customEnd=b.toISOString().split("T")[0];const j=P=>P.getFullYear()+"-"+String(P.getMonth()+1).padStart(2,"0")+"-"+String(P.getDate()).padStart(2,"0")+" 00:00:00";x.customRange=[j(G),j(b)]}ut(t,!0)},As=(a,t)=>{const x=Me(a);t&&t.length===2?(x.type="custom",x.preset="custom",x.customRange=t,x.customStart=t[0].split(" ")[0],x.customEnd=t[1].split(" ")[0],ut(a,!0)):t===null&&Bt("7days",a)},Wt=a=>a>new Date,$s=a=>{const t=Me(a);t.type="preset",t.preset="today";const x=new Date;new Date(x).setHours(0,0,0,0),t.customStart=x.toISOString().split("T")[0],t.customEnd=x.toISOString().split("T")[0],t.customRange=null,ut(a,!0),O("已重置筛选条件并刷新数据","info")},Cs=async()=>{await lt(),re.value=!0},Nt=async a=>{await lt(),_t.value=a,Ie.value=!0},Ht=a=>{St.value=a,at.value=!0},Is=a=>{re.value=!1,Tt.value=a,mt.value=!0,ke()},Ks=a=>{re.value=!1,Pt.value=a,xt.value=!0,ke()},Ls=async()=>{if($.value.length===0){O("请先选择要编辑的 API Keys","warning");return}await lt(),rt.value=!0},Ds=()=>{rt.value=!1,$.value=[],Se(),ke()},_s=()=>{Ie.value=!1,O("API Key 更新成功","success"),ke()},Ss=()=>{at.value=!1,O("API Key 续期成功","success"),ke()},Yt=async a=>{let t=!0;if(a.isActive&&(window.showConfirm?t=await window.showConfirm("禁用 API Key",`确定要禁用 API Key "${a.name}" 吗?禁用后所有使用此 Key 的请求将返回 401 错误。`,"确定禁用","取消"):t=confirm(`确定要禁用 API Key "${a.name}" 吗?禁用后所有使用此 Key 的请求将返回 401 错误。`)),!!t)try{const x=await q.put(`/admin/api-keys/${a.id}`,{isActive:!a.isActive});if(x.success){O(`API Key 已${a.isActive?"禁用":"激活"}`,"success");const r=M.value.find(b=>b.id===a.id);r&&(r.isActive=!a.isActive)}else O(x.message||"操作失败","error")}catch{O("操作失败","error")}},Qt=async a=>{let t=!1;if(window.showConfirm?t=await window.showConfirm("删除 API Key","确定要删除这个 API Key 吗?此操作不可恢复。","确定删除","取消"):t=confirm("确定要删除这个 API Key 吗?此操作不可恢复。"),!!t)try{const x=await q.delete(`/admin/api-keys/${a}`);if(x.success){O("API Key 已删除","success");const r=$.value.indexOf(a);r>-1&&$.value.splice(r,1),Se(),ke()}else O(x.message||"删除失败","error")}catch{O("删除失败","error")}},Ts=async a=>{var x,r;let t=!1;if(window.showConfirm?t=await window.showConfirm("恢复 API Key","确定要恢复这个 API Key 吗?恢复后可以重新使用。","确定恢复","取消"):t=confirm("确定要恢复这个 API Key 吗?恢复后可以重新使用。"),!!t)try{const b=await q.post(`/admin/api-keys/${a}/restore`);b.success?(O("API Key 已成功恢复","success"),await it(),await ke()):O(b.error||"恢复失败","error")}catch(b){O(((r=(x=b.response)==null?void 0:x.data)==null?void 0:r.error)||"恢复失败","error")}},Ps=async a=>{var x,r;let t=!1;if(window.showConfirm?t=await window.showConfirm("彻底删除 API Key","确定要彻底删除这个 API Key 吗?此操作不可恢复,所有相关数据将被永久删除。","确定彻底删除","取消"):t=confirm("确定要彻底删除这个 API Key 吗?此操作不可恢复,所有相关数据将被永久删除。"),!!t)try{const b=await q.delete(`/admin/api-keys/${a}/permanent`);b.success?(O("API Key 已彻底删除","success"),it()):O(b.error||"彻底删除失败","error")}catch(b){O(((r=(x=b.response)==null?void 0:x.data)==null?void 0:r.error)||"彻底删除失败","error")}},Us=async()=>{var x,r;const a=S.value.length;if(a===0){O("没有需要清空的 API Keys","info");return}let t=!1;if(window.showConfirm?t=await window.showConfirm("清空所有已删除的 API Keys",`确定要彻底删除全部 ${a} 个已删除的 API Keys 吗?此操作不可恢复,所有相关数据将被永久删除。`,"确定清空全部","取消"):t=confirm(`确定要彻底删除全部 ${a} 个已删除的 API Keys 吗?此操作不可恢复。`),!!t)try{const b=await q.delete("/admin/api-keys/deleted/clear-all");b.success?(O(b.message||"已清空所有已删除的 API Keys","success"),b.details&&b.details.failedCount>0&&O(`${b.details.failedCount} 个清空失败`,"warning"),it()):O(b.error||"清空失败","error")}catch(b){O(((r=(x=b.response)==null?void 0:x.data)==null?void 0:r.error)||"清空失败","error")}},Ms=async()=>{const a=$.value.length;if(a===0){O("请先选择要删除的 API Keys","warning");return}let t=!1;const x=`确定要删除选中的 ${a} 个 API Key 吗?此操作不可恢复。`;if(window.showConfirm?t=await window.showConfirm("批量删除 API Keys",x,"确定删除","取消"):t=confirm(x),!t)return;const r=[...$.value];try{const b=await q.delete("/admin/api-keys/batch",{data:{keyIds:r}});if(b.success){const{successCount:G,failedCount:j,errors:P}=b.data;if(G>0){if(O(`成功删除 ${G} 个 API Keys`,"success"),j>0){const E=P.map(ce=>`${ce.keyId}: ${ce.error}`).join(`
|
||
`);O(`${j} 个删除失败:
|
||
${E}`,"warning")}}else O("所有 API Keys 删除失败","error");$.value=[],Se(),ke()}else O(b.message||"批量删除失败","error")}catch{O("批量删除失败","error")}},Vs=()=>{if(U.value)je.value.forEach(a=>{$.value.includes(a.id)||$.value.push(a.id)});else{const a=new Set(je.value.map(t=>t.id));$.value=$.value.filter(t=>!a.has(t))}Se()},Se=()=>{const a=je.value.length,t=je.value.filter(x=>$.value.includes(x.id)).length;t===0?(U.value=!1,B.value=!1):t===a?(U.value=!0,B.value=!1):(U.value=!1,B.value=!0)},Ye=a=>{n.value=a},Jt=()=>{n.value=null},Rs=async({keyId:a,expiresAt:t,activateNow:x})=>{try{const r=await q.patch(`/admin/api-keys/${a}/expiration`,{expiresAt:t||null,activateNow:x||!1});if(r.success){O(x?"API Key已激活":"过期时间已更新","success");const b=M.value.find(G=>G.id===a);b&&(x&&r.updates?(b.isActivated=!0,b.activatedAt=r.updates.activatedAt,b.expiresAt=r.updates.expiresAt):(b.expiresAt=t||null,t&&!b.isActivated&&(b.isActivated=!0))),Jt()}else O(r.message||"更新失败","error"),m.value&&m.value.resetSaving()}catch{O("更新失败","error"),m.value&&m.value.resetSaving()}},Ve=a=>a?new Date(a).toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).replace(/\//g,"-"):"",Xt=a=>{if(a==null)return"--:--";const t=Math.floor(a/3600),x=Math.floor(a%3600/60),r=a%60;return t>0?`${t}h${x}m`:x>0?`${x}m${r}s`:`${r}s`},ft=a=>{g.value=a,C.value=!0},bt=a=>{if(!a)return"从未使用";const t=new Date(a),r=new Date-t;return r<6e4?"刚刚":r<36e5?`${Math.floor(r/6e4)} 分钟前`:r<864e5?`${Math.floor(r/36e5)} 小时前`:r<6048e5?`${Math.floor(r/864e5)} 天前`:t.toLocaleDateString("zh-CN")},vt={claude:"Claude",openai:"OpenAI",gemini:"Gemini",droid:"Droid",deleted:"已删除",other:"其他"},Es=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Zt=a=>{if(!a)return"other";const t=String(a).toLowerCase();return t==="claude-console"||t==="claude_console"||t==="claude"?"claude":t==="openai"||t==="openai-responses"||t==="openai_responses"||t==="azure-openai"||t==="azure_openai"?"openai":t==="gemini"||t==="gemini-api"||t==="gemini_api"?"gemini":t==="droid"?"droid":"other"},ct=a=>(a==null?void 0:a.lastUsage)||null,kt=a=>{const t=ct(a);return!!(t&&(t.accountName||t.accountId||t.rawAccountId))},wt=a=>{if(!a)return!1;if(a.accountCategory==="deleted")return!0;const t=typeof a.rawAccountId=="string"?a.rawAccountId.trim():"",x=typeof a.accountName=="string"?a.accountName.trim():"",r=typeof a.accountType=="string"?a.accountType.trim().toLowerCase():"";if(!t)return!1;const b=Es.test(t),G=!x||x===t,j=Zt(r);return b&&G&&(!r||r==="unknown"||j==="other")},Os=a=>a?wt(a)?"已删除":a.accountName||a.accountId||a.rawAccountId||"未知账号":"未知账号",Qe=a=>Os(ct(a)),ht=a=>{const t=Qe(a);return t.length>ns?`${t.slice(0,ns)}...`:t},gt=a=>{const t=ct(a);if(wt(t))return vt.deleted;const x=(t==null?void 0:t.accountCategory)||Zt(t==null?void 0:t.accountType);return vt[x]||vt.other},At=a=>{const t=ct(a);return wt(t)},js=()=>{ae.value="",F.value=1},Gs=()=>{try{const a=ot.value.map(w=>{var es,ts,ss,as,rs,os,ls,is;const we=xs(w),xe=ks(w),Z=fs(w),Le=bs(w),he=vs(w),qs={ID:w.id||"",名称:w.name||"",描述:w.description||"",状态:w.isActive?"启用":"禁用",API密钥:w.apiKey||"",过期模式:w.expirationMode==="activation"?"首次使用后激活":w.expirationMode==="fixed"?"固定时间":"无",激活期限:w.activationDays||"",激活单位:w.activationUnit==="hours"?"小时":w.activationUnit==="days"?"天":"",已激活:w.isActivated?"是":"否",激活时间:w.activatedAt?Ve(w.activatedAt):"",过期时间:w.expiresAt?Ve(w.expiresAt):"",服务权限:w.permissions==="all"?"全部服务":w.permissions==="claude"?"仅Claude":w.permissions==="gemini"?"仅Gemini":w.permissions==="openai"?"仅OpenAI":w.permissions==="droid"?"仅Droid":w.permissions||"",令牌限制:w.tokenLimit==="0"||w.tokenLimit===0?"无限制":w.tokenLimit||"",并发限制:w.concurrencyLimit==="0"||w.concurrencyLimit===0?"无限制":w.concurrencyLimit||"","速率窗口(分钟)":w.rateLimitWindow==="0"||w.rateLimitWindow===0?"无限制":w.rateLimitWindow||"",速率请求限制:w.rateLimitRequests==="0"||w.rateLimitRequests===0?"无限制":w.rateLimitRequests||"","日费用限制($)":w.dailyCostLimit==="0"||w.dailyCostLimit===0?"无限制":`$${w.dailyCostLimit}`||"","总费用限制($)":w.totalCostLimit==="0"||w.totalCostLimit===0?"无限制":`$${w.totalCostLimit}`||"",Claude专属账户:w.claudeAccountId||"",Claude控制台账户:w.claudeConsoleAccountId||"",Gemini专属账户:w.geminiAccountId||"",OpenAI专属账户:w.openaiAccountId||"","Azure OpenAI专属账户":w.azureOpenaiAccountId||"",Bedrock专属账户:w.bedrockAccountId||"",Droid专属账户:w.droidAccountId||"",启用模型限制:w.enableModelRestriction?"是":"否",限制的模型:w.restrictedModels&&w.restrictedModels.length>0?w.restrictedModels.join("; "):"",启用客户端限制:w.enableClientRestriction?"是":"否",允许的客户端:w.allowedClients&&w.allowedClients.length>0?w.allowedClients.join("; "):"",创建时间:w.createdAt?Ve(w.createdAt):"",创建者:w.createdBy||"",用户ID:w.userId||"",用户名:w.userUsername||"",标签:w.tags&&w.tags.length>0?w.tags.join(", "):"无",请求总数:we,"总费用($)":xe.toFixed(2),Token数:$e(Z),输入Token:$e(Le),输出Token:$e(he),最后使用时间:w.lastUsedAt?Ve(w.lastUsedAt):"从未使用",最后使用账号:Qe(w),最后使用类型:gt(w)},Ge={};let qe=null;return f.preset==="today"?qe=(ts=(es=w.usage)==null?void 0:es.daily)==null?void 0:ts.models:f.preset==="7days"?qe=(as=(ss=w.usage)==null?void 0:ss.weekly)==null?void 0:as.models:f.preset==="30days"?qe=(os=(rs=w.usage)==null?void 0:rs.monthly)==null?void 0:os.models:f.preset==="all"&&(qe=(is=(ls=w.usage)==null?void 0:ls.total)==null?void 0:is.models),qe&&Object.entries(qe).forEach(([Ct,Je])=>{let Re=Ct;Ct.includes(":")&&(Re=Ct.split(":").pop()),Re=Re.replace(/[:/]/g,"_"),Ge[`${Re}_请求数`]=Je.requests||0,Ge[`${Re}_费用($)`]=(Je.cost||0).toFixed(2),Ge[`${Re}_Token`]=$e(Je.totalTokens||0),Ge[`${Re}_输入Token`]=$e(Je.inputTokens||0),Ge[`${Re}_输出Token`]=$e(Je.outputTokens||0)}),{...qs,...Ge}}),t=Oe.utils.book_new(),x=Oe.utils.json_to_sheet(a),r=Oe.utils.decode_range(x["!ref"]),b=Object.keys(a[0]||{}),G=b.map(w=>w==="ID"?{wch:40}:w==="名称"?{wch:25}:w==="描述"?{wch:30}:w==="API密钥"?{wch:45}:w==="标签"?{wch:20}:w.includes("时间")?{wch:20}:w.includes("限制")?{wch:15}:w.includes("费用")?{wch:15}:w.includes("Token")?{wch:15}:w.includes("请求")?{wch:12}:w.includes("账户")?{wch:30}:w.includes("权限")||w.includes("模型")||w.includes("客户端")?{wch:20}:w.includes("激活")||w.includes("过期")?{wch:18}:{wch:15});x["!cols"]=G;for(let w=r.s.c;w<=r.e.c;++w){const we=Oe.utils.encode_cell({r:0,c:w});if(!x[we])continue;const xe=b[w],Z=xe&&xe.includes("_");x[we].s={fill:{fgColor:{rgb:Z?"70AD47":"4472C4"}},font:{color:{rgb:"FFFFFF"},bold:!0,sz:12},alignment:{horizontal:"center",vertical:"center"},border:{top:{style:"thin",color:{rgb:"2F5597"}},bottom:{style:"thin",color:{rgb:"2F5597"}},left:{style:"thin",color:{rgb:"2F5597"}},right:{style:"thin",color:{rgb:"2F5597"}}}}}for(let w=1;w<=r.e.r;++w)for(let we=r.s.c;we<=r.e.c;++we){const xe=Oe.utils.encode_cell({r:w,c:we});if(!x[xe])continue;const Z=b[we],Le=x[xe].v,he={font:{sz:11},border:{top:{style:"thin",color:{rgb:"D3D3D3"}},bottom:{style:"thin",color:{rgb:"D3D3D3"}},left:{style:"thin",color:{rgb:"D3D3D3"}},right:{style:"thin",color:{rgb:"D3D3D3"}}}};w%2===0&&(he.fill={fgColor:{rgb:"F2F2F2"}}),Z==="名称"?he.alignment={horizontal:"left",vertical:"center"}:Z==="标签"?(he.alignment={horizontal:"left",vertical:"center"},Le==="无"&&(he.font={...he.font,color:{rgb:"999999"},italic:!0})):Z==="最后使用时间"?(he.alignment={horizontal:"right",vertical:"center"},Le==="从未使用"&&(he.font={...he.font,color:{rgb:"999999"},italic:!0})):Z&&Z.includes("费用")?(he.alignment={horizontal:"right",vertical:"center"},he.font={...he.font,color:{rgb:"0066CC"},bold:!0}):Z&&(Z.includes("Token")||Z.includes("请求"))&&(he.alignment={horizontal:"right",vertical:"center"}),x[xe].s=he}Oe.utils.book_append_sheet(t,x,"用量统计");const j=new Date,P=j.getFullYear()+String(j.getMonth()+1).padStart(2,"0")+String(j.getDate()).padStart(2,"0")+"_"+String(j.getHours()).padStart(2,"0")+String(j.getMinutes()).padStart(2,"0")+String(j.getSeconds()).padStart(2,"0");let E="";f.type==="preset"?E={today:"今日","7days":"最近7天","30days":"最近30天",all:"全部时间"}[f.preset]||f.preset:E="自定义时间";const ce=`API_Keys_用量统计_${E}_${P}.xlsx`;Oe.writeFile(t,ce),O(`成功导出 ${a.length} 条API Key用量数据`,"success")}catch{O("导出失败,请重试","error")}};De([l,Y],()=>{F.value=1,$.value=[],Se()});let $t=null;return De(ae,()=>{$t&&clearTimeout($t),$t=setTimeout(()=>{F.value=1,ke(!1)},300)}),De(ue,()=>{F.value=1,ke(!1)}),De(l,()=>{F.value=1,ke(!1)}),De([I,K],()=>{ke(!1)}),De([F,me],([a,t],[x,r])=>{(a!==x||t!==r)&&ke(!1),Se()}),De(me,a=>{localStorage.setItem("apiKeysPageSize",a.toString())}),De(M,()=>{const a=new Set(M.value.map(t=>t.id));$.value=$.value.filter(t=>a.has(t)),Se()}),st(async()=>{await Promise.all([H.loadSupportedClients(),lt(),ke()]),Se()}),(a,t)=>{const x=zs;return i(),d("div",Md,[e("div",Vd,[e("div",Rd,[t[148]||(t[148]=e("div",null,[e("h3",{class:"mb-1 text-lg font-bold text-gray-900 dark:text-gray-100 sm:mb-2 sm:text-xl"}," API Keys 管理 "),e("p",{class:"text-sm text-gray-600 dark:text-gray-400 sm:text-base"}," 管理和监控您的 API 密钥 ")],-1)),e("div",Ed,[e("nav",Od,[e("button",{class:z(["whitespace-nowrap border-b-2 px-1 py-2 text-sm font-medium",V.value==="active"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 dark:text-gray-400 dark:hover:border-gray-500 dark:hover:text-gray-300"]),onClick:t[0]||(t[0]=r=>V.value="active")},[t[28]||(t[28]=A(" 活跃 API Keys ",-1)),M.value.length>0?(i(),d("span",jd,u(M.value.length),1)):h("",!0)],2),e("button",{class:z(["whitespace-nowrap border-b-2 px-1 py-2 text-sm font-medium",V.value==="deleted"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 dark:text-gray-400 dark:hover:border-gray-500 dark:hover:text-gray-300"]),onClick:it},[t[29]||(t[29]=A(" 已删除 API Keys ",-1)),S.value.length>0?(i(),d("span",Gd,u(S.value.length),1)):h("",!0)],2)])]),V.value==="active"?(i(),d("div",qd,[e("div",zd,[e("div",Fd,[e("div",Bd,[t[30]||(t[30]=e("div",{class:"absolute -inset-0.5 rounded-lg bg-gradient-to-r from-blue-500 to-purple-500 opacity-0 blur transition duration-300 group-hover:opacity-20"},null,-1)),le(It,{modelValue:f.preset,"onUpdate:modelValue":t[1]||(t[1]=r=>f.preset=r),icon:"fa-calendar-alt","icon-color":"text-blue-500",options:s.value,placeholder:"选择时间范围",onChange:ws},null,8,["modelValue","options"])]),f.type==="custom"?(i(),d("div",Wd,[le(x,{class:"api-key-date-picker custom-date-range-picker",clearable:!0,"default-time":k.value,"disabled-date":Wt,"end-placeholder":"结束日期",format:"YYYY-MM-DD HH:mm:ss","model-value":f.customRange,"range-separator":"至",size:"small","start-placeholder":"开始日期",style:{width:"320px",height:"38px"},type:"datetimerange","unlink-panels":!1,"value-format":"YYYY-MM-DD HH:mm:ss","onUpdate:modelValue":hs},null,8,["default-time","model-value"])])):h("",!0),e("div",Nd,[t[31]||(t[31]=e("div",{class:"absolute -inset-0.5 rounded-lg bg-gradient-to-r from-purple-500 to-pink-500 opacity-0 blur transition duration-300 group-hover:opacity-20"},null,-1)),e("div",Hd,[le(It,{modelValue:l.value,"onUpdate:modelValue":t[2]||(t[2]=r=>l.value=r),icon:"fa-tags","icon-color":"text-purple-500",options:ve.value,placeholder:"所有标签"},null,8,["modelValue","options"]),l.value?(i(),d("span",Yd,u(fe.value),1)):h("",!0)])]),e("div",Qd,[e("div",Jd,[le(It,{modelValue:ue.value,"onUpdate:modelValue":t[3]||(t[3]=r=>ue.value=r),icon:"fa-filter","icon-color":"text-cyan-500",options:ge.value,placeholder:"选择搜索类型"},null,8,["modelValue","options"])]),e("div",Xd,[t[34]||(t[34]=e("div",{class:"pointer-events-none absolute -inset-0.5 rounded-lg bg-gradient-to-r from-cyan-500 to-teal-500 opacity-0 blur transition duration-300 group-hover:opacity-20"},null,-1)),e("div",Zd,[_(e("input",{"onUpdate:modelValue":t[4]||(t[4]=r=>ae.value=r),class:"h-10 w-full rounded-lg border border-gray-200 bg-white px-3 pl-9 text-sm text-gray-700 placeholder-gray-400 shadow-sm transition-all duration-200 hover:border-gray-300 focus:border-cyan-500 focus:outline-none focus:ring-2 focus:ring-cyan-500/20 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:placeholder-gray-500 dark:hover:border-gray-500",placeholder:ue.value==="bindingAccount"?"搜索所属账号...":N.value?"搜索名称或所有者...":"搜索名称...",type:"text"},null,8,e0),[[ee,ae.value]]),t[33]||(t[33]=e("i",{class:"fas fa-search absolute left-3 text-sm text-cyan-500"},null,-1)),ae.value?(i(),d("button",{key:0,class:"absolute right-2 flex h-5 w-5 items-center justify-center rounded-full text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",onClick:js},t[32]||(t[32]=[e("i",{class:"fas fa-times text-xs"},null,-1)]))):h("",!0)])])])]),e("div",t0,[e("button",{class:"group relative flex items-center justify-center gap-2 rounded-lg border border-gray-200 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm transition-all duration-200 hover:border-gray-300 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:border-gray-500 sm:w-auto",disabled:J.value,onClick:t[5]||(t[5]=r=>ke())},[t[35]||(t[35]=e("div",{class:"absolute -inset-0.5 rounded-lg bg-gradient-to-r from-green-500 to-teal-500 opacity-0 blur transition duration-300 group-hover:opacity-20"},null,-1)),e("i",{class:z(["fas relative text-green-500",J.value?"fa-spinner fa-spin":"fa-sync-alt"])},null,2),t[36]||(t[36]=e("span",{class:"relative"},"刷新",-1))],8,s0),e("button",{class:"flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm transition-all duration-200 hover:border-gray-300 hover:bg-gray-50 hover:shadow-md dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700",onClick:p},[e("i",{class:z(T.value?"fas fa-times":"fas fa-check-square")},null,2),e("span",null,u(T.value?"取消选择":"选择"),1)]),e("button",{class:"group relative flex items-center justify-center gap-2 rounded-lg border border-gray-200 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm transition-all duration-200 hover:border-gray-300 hover:shadow-md dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:border-gray-500 sm:w-auto",onClick:Gs},t[37]||(t[37]=[e("div",{class:"absolute -inset-0.5 rounded-lg bg-gradient-to-r from-emerald-500 to-green-500 opacity-0 blur transition duration-300 group-hover:opacity-20"},null,-1),e("i",{class:"fas fa-file-excel relative text-emerald-500"},null,-1),e("span",{class:"relative"},"导出数据",-1)])),$.value.length>0?(i(),d("button",{key:0,class:"group relative flex items-center justify-center gap-2 rounded-lg border border-blue-200 bg-blue-50 px-4 py-2 text-sm font-medium text-blue-700 shadow-sm transition-all duration-200 hover:border-blue-300 hover:bg-blue-100 hover:shadow-md dark:border-blue-700 dark:bg-blue-900/30 dark:text-blue-300 dark:hover:bg-blue-900/50 sm:w-auto",onClick:t[6]||(t[6]=r=>Ls())},[t[38]||(t[38]=e("div",{class:"absolute -inset-0.5 rounded-lg bg-gradient-to-r from-blue-500 to-indigo-500 opacity-0 blur transition duration-300 group-hover:opacity-20"},null,-1)),t[39]||(t[39]=e("i",{class:"fas fa-edit relative text-blue-600 dark:text-blue-400"},null,-1)),e("span",a0,"编辑选中 ("+u($.value.length)+")",1)])):h("",!0),$.value.length>0?(i(),d("button",{key:1,class:"group relative flex items-center justify-center gap-2 rounded-lg border border-red-200 bg-red-50 px-4 py-2 text-sm font-medium text-red-700 shadow-sm transition-all duration-200 hover:border-red-300 hover:bg-red-100 hover:shadow-md dark:border-red-700 dark:bg-red-900/30 dark:text-red-300 dark:hover:bg-red-900/50 sm:w-auto",onClick:t[7]||(t[7]=r=>Ms())},[t[40]||(t[40]=e("div",{class:"absolute -inset-0.5 rounded-lg bg-gradient-to-r from-red-500 to-pink-500 opacity-0 blur transition duration-300 group-hover:opacity-20"},null,-1)),t[41]||(t[41]=e("i",{class:"fas fa-trash relative text-red-600 dark:text-red-400"},null,-1)),e("span",r0,"删除选中 ("+u($.value.length)+")",1)])):h("",!0),e("button",{class:"flex w-full items-center justify-center gap-2 rounded-lg bg-gradient-to-r from-blue-500 to-blue-600 px-5 py-2 text-sm font-medium text-white shadow-md transition-all duration-200 hover:from-blue-600 hover:to-blue-700 hover:shadow-lg sm:w-auto",onClick:Ce(Cs,["stop"])},t[42]||(t[42]=[e("i",{class:"fas fa-plus"},null,-1),e("span",null,"创建新 Key",-1)]))])]),J.value?(i(),d("div",o0,t[43]||(t[43]=[e("div",{class:"loading-spinner mx-auto mb-4"},null,-1),e("p",{class:"text-gray-500 dark:text-gray-400"},"正在加载 API Keys...",-1)]))):M.value.length===0?(i(),d("div",l0,t[44]||(t[44]=[e("div",{class:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-700"},[e("i",{class:"fas fa-key text-xl text-gray-400"})],-1),e("p",{class:"text-lg text-gray-500 dark:text-gray-400"},"暂无 API Keys",-1),e("p",{class:"mt-2 text-sm text-gray-400"},"点击上方按钮创建您的第一个 API Key",-1)]))):(i(),d("div",i0,[e("div",n0,[e("table",d0,[e("thead",u0,[e("tr",null,[L.value?(i(),d("th",c0,[e("div",g0,[_(e("input",{"onUpdate:modelValue":t[8]||(t[8]=r=>U.value=r),class:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500",indeterminate:B.value,type:"checkbox",onChange:Vs},null,40,p0),[[Te,U.value]])])])):h("",!0),e("th",{class:"w-[14%] min-w-[120px] cursor-pointer px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600",onClick:t[9]||(t[9]=r=>Ne("name"))},[t[45]||(t[45]=A(" 名称 ",-1)),I.value==="name"?(i(),d("i",{key:0,class:z(["fas",K.value==="asc"?"fa-sort-up":"fa-sort-down","ml-1"])},null,2)):(i(),d("i",m0))]),t[50]||(t[50]=e("th",{class:"w-[15%] min-w-[120px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 所属账号 ",-1)),t[51]||(t[51]=e("th",{class:"w-[10%] min-w-[80px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 标签 ",-1)),e("th",{class:"w-[6%] min-w-[60px] cursor-pointer px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600",onClick:t[10]||(t[10]=r=>Ne("status"))},[t[46]||(t[46]=A(" 状态 ",-1)),I.value==="status"?(i(),d("i",{key:0,class:z(["fas",K.value==="asc"?"fa-sort-up":"fa-sort-down","ml-1"])},null,2)):(i(),d("i",x0))]),t[52]||(t[52]=e("th",{class:"w-[4%] min-w-[40px] px-3 py-4 text-right text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 费用 ",-1)),t[53]||(t[53]=e("th",{class:"w-[14%] min-w-[120px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 限制 ",-1)),t[54]||(t[54]=e("th",{class:"w-[5%] min-w-[45px] px-3 py-4 text-right text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," Token ",-1)),t[55]||(t[55]=e("th",{class:"w-[5%] min-w-[45px] px-3 py-4 text-right text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 请求数 ",-1)),e("th",{class:"w-[8%] min-w-[70px] cursor-pointer px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600",onClick:t[11]||(t[11]=r=>Ne("lastUsedAt"))},[t[47]||(t[47]=A(" 最后使用 ",-1)),I.value==="lastUsedAt"?(i(),d("i",{key:0,class:z(["fas",K.value==="asc"?"fa-sort-up":"fa-sort-down","ml-1"])},null,2)):(i(),d("i",y0))]),e("th",{class:"w-[8%] min-w-[70px] cursor-pointer px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600",onClick:t[12]||(t[12]=r=>Ne("createdAt"))},[t[48]||(t[48]=A(" 创建时间 ",-1)),I.value==="createdAt"?(i(),d("i",{key:0,class:z(["fas",K.value==="asc"?"fa-sort-up":"fa-sort-down","ml-1"])},null,2)):(i(),d("i",f0))]),e("th",{class:"w-[8%] min-w-[70px] cursor-pointer px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-600",onClick:t[13]||(t[13]=r=>Ne("expiresAt"))},[t[49]||(t[49]=A(" 过期时间 ",-1)),I.value==="expiresAt"?(i(),d("i",{key:0,class:z(["fas",K.value==="asc"?"fa-sort-up":"fa-sort-down","ml-1"])},null,2)):(i(),d("i",b0))]),t[56]||(t[56]=e("th",{class:"operations-column sticky right-0 w-[23%] min-w-[200px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 操作 ",-1))])]),e("tbody",null,[(i(!0),d(te,null,oe(je.value,(r,b)=>{var G,j,P;return i(),d(te,{key:r.id},[e("tr",{class:z(["table-row transition-all duration-150",b%2===0?"bg-white dark:bg-gray-800/40":"bg-gray-50/70 dark:bg-gray-700/30","border-b-2 border-gray-200/80 dark:border-gray-700/50","hover:bg-blue-50/60 hover:shadow-sm dark:hover:bg-blue-900/20"])},[L.value?(i(),d("td",v0,[e("div",k0,[_(e("input",{"onUpdate:modelValue":t[14]||(t[14]=E=>$.value=E),class:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500",type:"checkbox",value:r.id,onChange:Se},null,40,w0),[[Te,$.value]])])])):h("",!0),e("td",h0,[e("div",A0,[e("div",{class:"truncate text-sm font-semibold text-gray-900 dark:text-gray-100",title:r.name},u(r.name),9,$0),N.value&&r.ownerDisplayName?(i(),d("div",C0,[t[57]||(t[57]=e("i",{class:"fas fa-user mr-1"},null,-1)),A(" "+u(r.ownerDisplayName),1)])):h("",!0)])]),e("td",I0,[e("div",K0,[r.claudeAccountId||r.claudeConsoleAccountId?(i(),d("div",L0,[t[58]||(t[58]=e("span",{class:"inline-flex items-center rounded bg-indigo-100 px-1.5 py-0.5 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-300"},[e("i",{class:"fas fa-brain mr-1 text-[10px]"}),A(" Claude ")],-1)),e("span",D0,u(Vt(r)),1)])):h("",!0),r.geminiAccountId?(i(),d("div",_0,[t[59]||(t[59]=e("span",{class:"inline-flex items-center rounded bg-yellow-100 px-1.5 py-0.5 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},[e("i",{class:"fas fa-robot mr-1 text-[10px]"}),A(" Gemini ")],-1)),e("span",S0,u(Rt(r)),1)])):h("",!0),r.openaiAccountId?(i(),d("div",T0,[t[60]||(t[60]=e("span",{class:"inline-flex items-center rounded bg-gray-100 px-1.5 py-0.5 text-gray-700 dark:bg-gray-700 dark:text-gray-300"},[e("i",{class:"fa-openai mr-1 text-[10px]"}),A(" OpenAI ")],-1)),e("span",P0,u(Et(r)),1)])):h("",!0),r.bedrockAccountId?(i(),d("div",U0,[t[61]||(t[61]=e("span",{class:"inline-flex items-center rounded bg-orange-100 px-1.5 py-0.5 text-orange-700 dark:bg-orange-900/30 dark:text-orange-300"},[e("i",{class:"fas fa-cloud mr-1 text-[10px]"}),A(" Bedrock ")],-1)),e("span",M0,u(Ot(r)),1)])):h("",!0),r.droidAccountId?(i(),d("div",V0,[t[62]||(t[62]=e("span",{class:"inline-flex items-center rounded bg-cyan-100 px-1.5 py-0.5 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"},[e("i",{class:"fas fa-robot mr-1 text-[10px]"}),A(" Droid ")],-1)),e("span",R0,u(jt(r)),1)])):h("",!0),!r.claudeAccountId&&!r.claudeConsoleAccountId&&!r.geminiAccountId&&!r.openaiAccountId&&!r.bedrockAccountId&&!r.droidAccountId?(i(),d("div",E0,t[63]||(t[63]=[e("i",{class:"fas fa-share-alt mr-1"},null,-1),A(" 共享池 ",-1)]))):h("",!0)])]),e("td",O0,[e("div",j0,[(i(!0),d(te,null,oe(r.tags||[],E=>(i(),d("span",{key:E,class:"inline-flex items-center rounded-full bg-blue-100 px-2 py-0.5 text-xs text-blue-800 dark:bg-blue-900/30 dark:text-blue-300"},u(E),1))),128)),!r.tags||r.tags.length===0?(i(),d("span",G0,"无标签")):h("",!0)])]),e("td",q0,[e("span",{class:z(["inline-flex items-center rounded-full px-3 py-1 text-xs font-semibold",r.isActive?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300":"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300"])},[e("div",{class:z(["mr-2 h-2 w-2 rounded-full",r.isActive?"bg-green-500":"bg-red-500"])},null,2),A(" "+u(r.isActive?"活跃":"禁用"),1)],2)]),e("td",z0,[We(r.id)?(i(),d("div",F0,t[64]||(t[64]=[e("i",{class:"fas fa-spinner fa-spin text-gray-400"},null,-1)]))):Ke(r.id)?(i(),d("span",B0,u(Ke(r.id).formattedCost||"$0.00"),1)):(i(),d("span",W0,"-"))]),e("td",N0,[e("div",H0,[r.dailyCostLimit>0?(i(),ye(Pe,{key:0,current:r.dailyCost||0,label:"每日限制",limit:r.dailyCostLimit,type:"daily",variant:"compact"},null,8,["current","limit"])):r.totalCostLimit>0?(i(),ye(Pe,{key:1,current:((G=Ke(r.id))==null?void 0:G.cost)||((P=(j=r.usage)==null?void 0:j.total)==null?void 0:P.cost)||0,label:"总费用限制",limit:r.totalCostLimit,type:"total",variant:"compact"},null,8,["current","limit"])):r.rateLimitWindow>0&&r.rateLimitCost>0&&(!r.dailyCostLimit||r.dailyCostLimit===0)&&(!r.totalCostLimit||r.totalCostLimit===0)?(i(),d("div",Y0,[le(Pe,{current:r.currentWindowCost||0,label:"窗口费用",limit:r.rateLimitCost,type:"window",variant:"compact"},null,8,["current","limit"]),e("div",Q0,[e("div",J0,[t[65]||(t[65]=e("i",{class:"fas fa-clock text-[10px]"},null,-1)),e("span",X0,u(r.rateLimitWindow)+"分钟窗口",1)]),e("span",{class:z(["font-bold",r.windowRemainingSeconds>0?"text-sky-700 dark:text-sky-300":"text-gray-400 dark:text-gray-500"])},u(r.windowRemainingSeconds>0?Xt(r.windowRemainingSeconds):"未激活"),3)])])):(i(),d("div",Z0,t[66]||(t[66]=[e("i",{class:"fas fa-infinity text-base"},null,-1),e("span",{class:"text-xs font-medium"},"无限制",-1)])))])]),e("td",eu,[We(r.id)?(i(),d("div",tu,t[67]||(t[67]=[e("i",{class:"fas fa-spinner fa-spin text-gray-400"},null,-1)]))):Ke(r.id)?(i(),d("div",su,[e("span",au,u($e(Ke(r.id).tokens||0)),1)])):(i(),d("span",ru,"-"))]),e("td",ou,[We(r.id)?(i(),d("div",lu,t[68]||(t[68]=[e("i",{class:"fas fa-spinner fa-spin text-gray-400"},null,-1)]))):Ke(r.id)?(i(),d("div",iu,[e("span",nu,u(yt(Ke(r.id).requests||0)),1),t[69]||(t[69]=e("span",{class:"text-xs text-gray-500"},"次",-1))])):(i(),d("span",du,"-"))]),e("td",uu,[e("div",cu,[r.lastUsedAt?(i(),d("span",{key:0,class:"cursor-help",style:{"font-size":"13px"},title:new Date(r.lastUsedAt).toLocaleString("zh-CN")},u(bt(r.lastUsedAt)),9,gu)):(i(),d("span",pu,"从未使用")),kt(r)?(i(),d("span",{key:2,class:"mt-1 text-xs text-gray-500 dark:text-gray-400",title:Qe(r)},[A(u(ht(r))+" ",1),At(r)?h("",!0):(i(),d("span",xu," ("+u(gt(r))+") ",1))],8,mu)):(i(),d("span",yu," 暂无使用账号 "))])]),e("td",fu,u(new Date(r.createdAt).toLocaleDateString()),1),e("td",bu,[e("div",vu,[r.expirationMode==="activation"&&!r.isActivated?(i(),d("span",ku,[t[70]||(t[70]=e("i",{class:"fas fa-pause-circle mr-1 text-xs"},null,-1)),A(" 未激活 ( "+u(r.activationDays||(r.activationUnit==="hours"?24:30))+u(r.activationUnit==="hours"?"小时":"天")+") ",1)])):r.expiresAt?(i(),d("span",wu,[nt(r.expiresAt)?(i(),d("span",{key:0,class:"inline-flex cursor-pointer items-center text-red-600 hover:underline",style:{"font-size":"13px"},onClick:Ce(E=>Ye(r),["stop"])},t[71]||(t[71]=[e("i",{class:"fas fa-exclamation-circle mr-1 text-xs"},null,-1),A(" 已过期 ",-1)]),8,hu)):dt(r.expiresAt)?(i(),d("span",{key:1,class:"inline-flex cursor-pointer items-center text-orange-600 hover:underline",style:{"font-size":"13px"},onClick:Ce(E=>Ye(r),["stop"])},[t[72]||(t[72]=e("i",{class:"fas fa-clock mr-1 text-xs"},null,-1)),A(" "+u(Gt(r.expiresAt)),1)],8,Au)):(i(),d("span",{key:2,class:"cursor-pointer text-gray-600 hover:underline dark:text-gray-400",style:{"font-size":"13px"},onClick:Ce(E=>Ye(r),["stop"])},u(Gt(r.expiresAt)),9,$u))])):(i(),d("span",{key:2,class:"inline-flex cursor-pointer items-center text-gray-400 hover:underline dark:text-gray-500",style:{"font-size":"13px"},onClick:Ce(E=>Ye(r),["stop"])},t[73]||(t[73]=[e("i",{class:"fas fa-infinity mr-1 text-xs"},null,-1),A(" 永不过期 ",-1)]),8,Cu))])]),e("td",Iu,[e("div",Ku,[e("button",{class:"rounded px-2 py-1 text-xs font-medium text-purple-600 transition-colors hover:bg-purple-50 hover:text-purple-900 dark:hover:bg-purple-900/20",title:"查看详细统计",onClick:E=>ft(r)},t[74]||(t[74]=[e("i",{class:"fas fa-chart-line"},null,-1),e("span",{class:"ml-1 hidden xl:inline"},"详情",-1)]),8,Lu),r&&r.id?(i(),d("button",{key:0,class:"rounded px-2 py-1 text-xs font-medium text-indigo-600 transition-colors hover:bg-indigo-50 hover:text-indigo-900 dark:hover:bg-indigo-900/20",title:"模型使用分布",onClick:E=>ps(r.id)},[e("i",{class:z(["fas",se.value[r.id]?"fa-chevron-up":"fa-chevron-down"])},null,2),t[75]||(t[75]=e("span",{class:"ml-1 hidden xl:inline"},"模型",-1))],8,Du)):h("",!0),e("button",{class:"rounded px-2 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-50 hover:text-blue-900 dark:hover:bg-blue-900/20",title:"编辑",onClick:E=>Nt(r)},t[76]||(t[76]=[e("i",{class:"fas fa-edit"},null,-1),e("span",{class:"ml-1 hidden xl:inline"},"编辑",-1)]),8,_u),r.expiresAt&&(nt(r.expiresAt)||dt(r.expiresAt))?(i(),d("button",{key:1,class:"rounded px-2 py-1 text-xs font-medium text-green-600 transition-colors hover:bg-green-50 hover:text-green-900 dark:hover:bg-green-900/20",title:"续期",onClick:E=>Ht(r)},t[77]||(t[77]=[e("i",{class:"fas fa-clock"},null,-1),e("span",{class:"ml-1 hidden xl:inline"},"续期",-1)]),8,Su)):h("",!0),e("button",{class:z([r.isActive?"text-orange-600 hover:bg-orange-50 hover:text-orange-900 dark:hover:bg-orange-900/20":"text-green-600 hover:bg-green-50 hover:text-green-900 dark:hover:bg-green-900/20","rounded px-2 py-1 text-xs font-medium transition-colors"]),title:r.isActive?"禁用":"激活",onClick:E=>Yt(r)},[e("i",{class:z(["fas",r.isActive?"fa-ban":"fa-check-circle"])},null,2),e("span",Pu,u(r.isActive?"禁用":"激活"),1)],10,Tu),e("button",{class:"rounded px-2 py-1 text-xs font-medium text-red-600 transition-colors hover:bg-red-50 hover:text-red-900 dark:hover:bg-red-900/20",title:"删除",onClick:E=>Qt(r.id)},t[78]||(t[78]=[e("i",{class:"fas fa-trash"},null,-1),e("span",{class:"ml-1 hidden xl:inline"},"删除",-1)]),8,Uu)])])],2),r&&r.id&&se.value[r.id]?(i(),d("tr",Mu,[e("td",Vu,[X.value[r.id]?h("",!0):(i(),d("div",Ru,t[79]||(t[79]=[e("div",{class:"loading-spinner mx-auto"},null,-1),e("p",{class:"mt-2 text-sm text-gray-500 dark:text-gray-400"}," 加载模型统计... ",-1)]))),e("div",Eu,[e("div",Ou,[t[80]||(t[80]=e("h5",{class:"flex items-center text-sm font-semibold text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-chart-pie mr-2 text-indigo-500"}),A(" 模型使用分布 ")],-1)),e("div",ju,[X.value[r.id]&&X.value[r.id].length>0?(i(),d("span",Gu,u(X.value[r.id].length)+" 个模型 ",1)):h("",!0),e("div",qu,[e("div",zu,[(i(!0),d(te,null,oe(Me(r.id).presetOptions,E=>(i(),d("button",{key:E.value,class:z(["rounded px-2 py-1 text-xs font-medium transition-colors",Me(r.id).preset===E.value&&Me(r.id).type==="preset"?"bg-white text-blue-600 shadow-sm dark:bg-gray-800":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200"]),onClick:ce=>Bt(E.value,r.id)},u(E.label),11,Fu))),128))]),le(x,{class:"api-key-date-picker",clearable:!0,"default-time":k.value,"disabled-date":Wt,"end-placeholder":"结束日期",format:"YYYY-MM-DD HH:mm:ss","model-value":Me(r.id).customRange,"range-separator":"至",size:"small","start-placeholder":"开始日期",style:{width:"280px"},type:"datetimerange","unlink-panels":!1,"value-format":"YYYY-MM-DD HH:mm:ss","onUpdate:modelValue":E=>As(r.id,E)},null,8,["default-time","model-value","onUpdate:modelValue"])])])]),X.value[r.id]&&X.value[r.id].length===0?(i(),d("div",Bu,[e("div",Wu,[t[82]||(t[82]=e("i",{class:"fas fa-chart-line text-lg text-gray-400"},null,-1)),t[83]||(t[83]=e("p",{class:"text-sm text-gray-500 dark:text-gray-400"}," 暂无模型使用数据 ",-1)),e("button",{class:"ml-2 flex items-center gap-1 text-sm text-blue-500 transition-colors hover:text-blue-700",title:"重置筛选条件并刷新",onClick:E=>$s(r.id)},t[81]||(t[81]=[e("i",{class:"fas fa-sync-alt text-xs"},null,-1),e("span",{class:"text-xs"},"刷新",-1)]),8,Nu)]),t[84]||(t[84]=e("p",{class:"text-xs text-gray-400"}," 尝试调整时间范围或点击刷新重新加载数据 ",-1))])):X.value[r.id]&&X.value[r.id].length>0?(i(),d("div",Hu,[(i(!0),d(te,null,oe(X.value[r.id],E=>(i(),d("div",{key:E.model,class:"rounded-xl border border-gray-200 bg-gradient-to-br from-white to-gray-50 p-4 transition-all duration-200 hover:border-indigo-300 hover:shadow-lg dark:border-gray-600 dark:from-gray-800 dark:to-gray-700 dark:hover:border-indigo-500"},[e("div",Yu,[e("div",Qu,[e("span",Ju,u(E.model),1),e("span",Xu,u(E.requests)+" 次请求",1)])]),e("div",Zu,[e("div",ec,[t[85]||(t[85]=e("span",{class:"flex items-center text-gray-600 dark:text-gray-400"},[e("i",{class:"fas fa-coins mr-1 text-xs text-yellow-500"}),A(" 总Token: ")],-1)),e("span",tc,u($e(E.allTokens)),1)]),e("div",sc,[t[86]||(t[86]=e("span",{class:"flex items-center text-gray-600 dark:text-gray-400"},[e("i",{class:"fas fa-dollar-sign mr-1 text-xs text-green-500"}),A(" 费用: ")],-1)),e("span",ac,u(ms(E)),1)]),e("div",rc,[e("div",oc,[t[87]||(t[87]=e("span",{class:"flex items-center"},[e("i",{class:"fas fa-arrow-down mr-1 text-green-500"}),A(" 输入: ")],-1)),e("span",lc,u($e(E.inputTokens)),1)]),e("div",ic,[t[88]||(t[88]=e("span",{class:"flex items-center"},[e("i",{class:"fas fa-arrow-up mr-1 text-blue-500"}),A(" 输出: ")],-1)),e("span",nc,u($e(E.outputTokens)),1)]),E.cacheCreateTokens>0?(i(),d("div",dc,[t[89]||(t[89]=e("span",{class:"flex items-center"},[e("i",{class:"fas fa-save mr-1"}),A(" 缓存创建: ")],-1)),e("span",uc,u($e(E.cacheCreateTokens)),1)])):h("",!0),E.cacheReadTokens>0?(i(),d("div",cc,[t[90]||(t[90]=e("span",{class:"flex items-center"},[e("i",{class:"fas fa-download mr-1"}),A(" 缓存读取: ")],-1)),e("span",gc,u($e(E.cacheReadTokens)),1)])):h("",!0)])]),e("div",pc,[e("div",{class:"h-2 rounded-full bg-gradient-to-r from-indigo-500 to-purple-600 transition-all duration-500",style:pt({width:qt(E.allTokens,X.value[r.id])+"%"})},null,4)]),e("div",mc,[e("span",xc,u(qt(E.allTokens,X.value[r.id]))+"% ",1)])]))),128))])):h("",!0),X.value[r.id]&&X.value[r.id].length>0?(i(),d("div",yc,[e("div",fc,[t[93]||(t[93]=e("span",{class:"flex items-center font-semibold text-gray-700 dark:text-gray-300"},[e("i",{class:"fas fa-calculator mr-2 text-indigo-500"}),A(" 总计统计 ")],-1)),e("div",bc,[e("span",vc,[t[91]||(t[91]=A(" 总请求: ",-1)),e("span",kc,u(X.value[r.id].reduce((E,ce)=>E+ce.requests,0)),1)]),e("span",wc,[t[92]||(t[92]=A(" 总Token: ",-1)),e("span",hc,u($e(X.value[r.id].reduce((E,ce)=>E+ce.allTokens,0))),1)])])])])):h("",!0)])])])):h("",!0)],64)}),128))])])])])),!J.value&&ot.value.length>0?(i(),d("div",Ac,[(i(!0),d(te,null,oe(je.value,r=>{var b,G,j;return i(),d("div",{key:r.id,class:"card p-4 transition-shadow hover:shadow-lg"},[e("div",$c,[e("div",Cc,[L.value?_((i(),d("input",{key:0,"onUpdate:modelValue":t[15]||(t[15]=P=>$.value=P),class:"mt-1 h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500",type:"checkbox",value:r.id,onChange:Se},null,40,Ic)),[[Te,$.value]]):h("",!0),e("div",null,[e("h4",Kc,u(r.name),1),e("p",Lc,u(r.id),1)])]),e("span",{class:z(["inline-flex items-center rounded-full px-2 py-1 text-xs font-semibold",r.isActive?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300":"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300"])},[e("div",{class:z(["mr-1.5 h-1.5 w-1.5 rounded-full",r.isActive?"bg-green-500":"bg-red-500"])},null,2),A(" "+u(r.isActive?"活跃":"已停用"),1)],2)]),e("div",Dc,[r.claudeAccountId||r.claudeConsoleAccountId?(i(),d("div",_c,[t[94]||(t[94]=e("span",{class:"inline-flex items-center rounded bg-indigo-100 px-2 py-0.5 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-300"},[e("i",{class:"fas fa-brain mr-1"}),A(" Claude ")],-1)),e("span",Sc,u(Vt(r)),1)])):h("",!0),r.geminiAccountId?(i(),d("div",Tc,[t[95]||(t[95]=e("span",{class:"inline-flex items-center rounded bg-yellow-100 px-2 py-0.5 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},[e("i",{class:"fas fa-robot mr-1"}),A(" Gemini ")],-1)),e("span",Pc,u(Rt(r)),1)])):h("",!0),r.openaiAccountId?(i(),d("div",Uc,[t[96]||(t[96]=e("span",{class:"inline-flex items-center rounded bg-gray-100 px-2 py-0.5 text-gray-700 dark:bg-gray-700 dark:text-gray-300"},[e("i",{class:"fa-openai mr-1"}),A(" OpenAI ")],-1)),e("span",Mc,u(Et(r)),1)])):h("",!0),r.bedrockAccountId?(i(),d("div",Vc,[t[97]||(t[97]=e("span",{class:"inline-flex items-center rounded bg-orange-100 px-2 py-0.5 text-orange-700 dark:bg-orange-900/30 dark:text-orange-300"},[e("i",{class:"fas fa-cloud mr-1"}),A(" Bedrock ")],-1)),e("span",Rc,u(Ot(r)),1)])):h("",!0),r.droidAccountId?(i(),d("div",Ec,[t[98]||(t[98]=e("span",{class:"inline-flex items-center rounded bg-cyan-100 px-2 py-0.5 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"},[e("i",{class:"fas fa-robot mr-1"}),A(" Droid ")],-1)),e("span",Oc,u(jt(r)),1)])):h("",!0),!r.claudeAccountId&&!r.claudeConsoleAccountId&&!r.geminiAccountId&&!r.openaiAccountId&&!r.bedrockAccountId&&!r.droidAccountId?(i(),d("div",jc,t[99]||(t[99]=[e("i",{class:"fas fa-share-alt mr-1"},null,-1),A(" 使用共享池 ",-1)]))):h("",!0),N.value&&r.ownerDisplayName?(i(),d("div",Gc,[t[100]||(t[100]=e("i",{class:"fas fa-user mr-1"},null,-1)),A(" "+u(r.ownerDisplayName),1)])):h("",!0)]),e("div",qc,[e("div",zc,[e("div",Fc,[e("span",Bc,u(f.type==="custom"?"累计统计":"今日使用"),1),e("button",{class:"text-xs text-blue-600 hover:text-blue-800",onClick:P=>ft(r)},t[101]||(t[101]=[e("i",{class:"fas fa-chart-line mr-1"},null,-1),A("详情 ",-1)]),8,Wc)]),e("div",Nc,[e("div",null,[We(r.id)?(i(),d("p",Hc,t[102]||(t[102]=[e("i",{class:"fas fa-spinner fa-spin"},null,-1)]))):Ke(r.id)?(i(),d("p",Yc,u(yt(Ke(r.id).requests||0))+" 次 ",1)):(i(),d("p",Qc,"-")),t[103]||(t[103]=e("p",{class:"text-xs text-gray-500 dark:text-gray-400"},"请求",-1))]),e("div",null,[We(r.id)?(i(),d("p",Jc,t[104]||(t[104]=[e("i",{class:"fas fa-spinner fa-spin"},null,-1)]))):Ke(r.id)?(i(),d("p",Xc,u(Ke(r.id).formattedCost||"$0.00"),1)):(i(),d("p",Zc,"-")),t[105]||(t[105]=e("p",{class:"text-xs text-gray-500 dark:text-gray-400"},"费用",-1))])]),e("div",eg,[e("div",tg,[t[106]||(t[106]=e("span",null,"最后使用",-1)),e("span",sg,u(r.lastUsedAt?bt(r.lastUsedAt):"从未使用"),1)]),e("div",ag,[t[107]||(t[107]=e("span",null,"账号",-1)),kt(r)?(i(),d("span",{key:0,class:"truncate text-gray-500 dark:text-gray-400",style:{"max-width":"180px"},title:Qe(r)},[A(u(ht(r))+" ",1),At(r)?h("",!0):(i(),d("span",og," ("+u(gt(r))+") ",1))],8,rg)):(i(),d("span",lg,"暂无使用账号"))])])]),e("div",ig,[r.dailyCostLimit>0?(i(),ye(Pe,{key:0,current:r.dailyCost||0,label:"每日限制",limit:r.dailyCostLimit,type:"daily",variant:"compact"},null,8,["current","limit"])):r.totalCostLimit>0?(i(),ye(Pe,{key:1,current:((b=Ke(r.id))==null?void 0:b.cost)||((j=(G=r.usage)==null?void 0:G.total)==null?void 0:j.cost)||0,label:"总费用限制",limit:r.totalCostLimit,type:"total",variant:"compact"},null,8,["current","limit"])):r.rateLimitWindow>0&&r.rateLimitCost>0&&(!r.dailyCostLimit||r.dailyCostLimit===0)&&(!r.totalCostLimit||r.totalCostLimit===0)?(i(),d("div",ng,[le(Pe,{current:r.currentWindowCost||0,label:"窗口费用",limit:r.rateLimitCost,type:"window",variant:"compact"},null,8,["current","limit"]),e("div",dg,[e("div",ug,[t[108]||(t[108]=e("i",{class:"fas fa-clock text-xs"},null,-1)),e("span",cg,u(r.rateLimitWindow)+"分钟窗口",1)]),e("span",{class:z(["font-bold",r.windowRemainingSeconds>0?"text-sky-700 dark:text-sky-300":"text-gray-400 dark:text-gray-500"])},u(r.windowRemainingSeconds>0?Xt(r.windowRemainingSeconds):"未激活"),3)])])):(i(),d("div",gg,t[109]||(t[109]=[e("i",{class:"fas fa-infinity text-base"},null,-1),e("span",{class:"text-xs font-medium"},"无限制",-1)])))])]),e("div",pg,[e("div",mg,[t[110]||(t[110]=e("span",null,"创建时间",-1)),e("span",null,u(Ve(r.createdAt)),1)]),e("div",xg,[t[112]||(t[112]=e("span",null,"过期时间",-1)),e("div",yg,[e("span",{class:z(dt(r.expiresAt)?"font-semibold text-orange-600":"")},u(r.expiresAt?Ve(r.expiresAt):"永不过期"),3),e("button",{class:"inline-flex h-5 w-5 items-center justify-center rounded text-gray-300 transition-all duration-200 hover:bg-blue-50 hover:text-blue-500 dark:hover:bg-blue-900/20",title:"编辑过期时间",onClick:Ce(P=>Ye(r),["stop"])},t[111]||(t[111]=[e("svg",{class:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"})],-1)]),8,fg)])])]),r.tags&&r.tags.length>0?(i(),d("div",bg,[(i(!0),d(te,null,oe(r.tags,P=>(i(),d("span",{key:P,class:"inline-flex items-center rounded-full bg-blue-100 px-2 py-0.5 text-xs text-blue-800 dark:bg-blue-900/30 dark:text-blue-300"},u(P),1))),128))])):h("",!0),e("div",vg,[e("button",{class:"flex flex-1 items-center justify-center gap-1 rounded-lg bg-blue-50 px-3 py-1.5 text-xs text-blue-600 transition-colors hover:bg-blue-100 dark:bg-blue-900/30 dark:hover:bg-blue-900/50",onClick:P=>ft(r)},t[113]||(t[113]=[e("i",{class:"fas fa-chart-line"},null,-1),A(" 查看详情 ",-1)]),8,kg),e("button",{class:"flex-1 rounded-lg bg-gray-50 px-3 py-1.5 text-xs text-gray-600 transition-colors hover:bg-gray-100 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600",onClick:P=>Nt(r)},t[114]||(t[114]=[e("i",{class:"fas fa-edit mr-1"},null,-1),A(" 编辑 ",-1)]),8,wg),r.expiresAt&&(nt(r.expiresAt)||dt(r.expiresAt))?(i(),d("button",{key:0,class:"flex-1 rounded-lg bg-orange-50 px-3 py-1.5 text-xs text-orange-600 transition-colors hover:bg-orange-100 dark:bg-orange-900/30 dark:hover:bg-orange-900/50",onClick:P=>Ht(r)},t[115]||(t[115]=[e("i",{class:"fas fa-clock mr-1"},null,-1),A(" 续期 ",-1)]),8,hg)):h("",!0),e("button",{class:z([r.isActive?"bg-orange-50 text-orange-600 hover:bg-orange-100 dark:bg-orange-900/30 dark:hover:bg-orange-900/50":"bg-green-50 text-green-600 hover:bg-green-100 dark:bg-green-900/30 dark:hover:bg-green-900/50","rounded-lg px-3 py-1.5 text-xs transition-colors"]),onClick:P=>Yt(r)},[e("i",{class:z(["fas",r.isActive?"fa-ban":"fa-check-circle","mr-1"])},null,2),A(" "+u(r.isActive?"禁用":"激活"),1)],10,Ag),e("button",{class:"rounded-lg bg-red-50 px-3 py-1.5 text-xs text-red-600 transition-colors hover:bg-red-100 dark:bg-red-900/30 dark:hover:bg-red-900/50",onClick:P=>Qt(r.id)},t[116]||(t[116]=[e("i",{class:"fas fa-trash"},null,-1)]),8,$g)])])}),128))])):h("",!0),ot.value.length>0?(i(),d("div",Cg,[e("div",Ig,[e("span",Kg," 共 "+u(ot.value.length)+" 条记录 ",1),e("div",Lg,[t[117]||(t[117]=e("span",{class:"text-xs text-gray-600 dark:text-gray-400 sm:text-sm"},"每页显示",-1)),_(e("select",{"onUpdate:modelValue":t[16]||(t[16]=r=>me.value=r),class:"rounded-md border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700 transition-colors hover:border-gray-300 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:border-gray-500 sm:text-sm"},[(i(),d(te,null,oe(Fe,r=>e("option",{key:r,value:r},u(r),9,Dg)),64))],512),[[tt,me.value]]),t[118]||(t[118]=e("span",{class:"text-xs text-gray-600 dark:text-gray-400 sm:text-sm"},"条",-1))])]),e("div",_g,[e("button",{class:"rounded-md border border-gray-300 bg-white px-3 py-1.5 text-xs font-medium text-gray-700 hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 sm:py-1 sm:text-sm",disabled:F.value===1,onClick:t[17]||(t[17]=r=>F.value--)},t[119]||(t[119]=[e("i",{class:"fas fa-chevron-left"},null,-1)]),8,Sg),e("div",Tg,[Ut.value?(i(),d("button",{key:0,class:"hidden rounded-md border border-gray-300 bg-white px-3 py-1 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 sm:block",onClick:t[18]||(t[18]=r=>F.value=1)}," 1 ")):h("",!0),us.value?(i(),d("span",Pg,"...")):h("",!0),(i(!0),d(te,null,oe(Be.value,r=>(i(),d("button",{key:r,class:z(["rounded-md px-2 py-1 text-xs font-medium sm:px-3 sm:text-sm",r===F.value?"bg-blue-600 text-white":"border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"]),onClick:b=>F.value=r},u(r),11,Ug))),128)),cs.value?(i(),d("span",Mg,"...")):h("",!0),Mt.value?(i(),d("button",{key:3,class:"hidden rounded-md border border-gray-300 bg-white px-3 py-1 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 sm:block",onClick:t[19]||(t[19]=r=>F.value=Ee.value)},u(Ee.value),1)):h("",!0)]),e("button",{class:"rounded-md border border-gray-300 bg-white px-3 py-1.5 text-xs font-medium text-gray-700 hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 sm:py-1 sm:text-sm",disabled:F.value===Ee.value||Ee.value===0,onClick:t[20]||(t[20]=r=>F.value++)},t[120]||(t[120]=[e("i",{class:"fas fa-chevron-right"},null,-1)]),8,Vg)])])):h("",!0)])):V.value==="deleted"?(i(),d("div",Rg,[W.value?(i(),d("div",Eg,t[121]||(t[121]=[e("div",{class:"loading-spinner mx-auto mb-4"},null,-1),e("p",{class:"text-gray-500 dark:text-gray-400"},"正在加载已删除的 API Keys...",-1)]))):S.value.length===0?(i(),d("div",Og,t[122]||(t[122]=[e("div",{class:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-700"},[e("i",{class:"fas fa-trash text-xl text-gray-400"})],-1),e("p",{class:"text-lg text-gray-500 dark:text-gray-400"},"暂无已删除的 API Keys",-1),e("p",{class:"mt-2 text-sm text-gray-400"},"已删除的 API Keys 会出现在这里",-1)]))):(i(),d("div",jg,[e("div",Gg,[S.value.length>0?(i(),d("button",{key:0,class:"rounded-lg bg-red-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-red-700 dark:bg-red-600 dark:hover:bg-red-700",onClick:Us},[t[123]||(t[123]=e("i",{class:"fas fa-trash-alt mr-2"},null,-1)),A(" 清空所有已删除 ("+u(S.value.length)+") ",1)])):h("",!0)]),e("div",qg,[e("div",zg,[e("table",Fg,[e("thead",Bg,[e("tr",null,[t[124]||(t[124]=e("th",{class:"w-[14%] min-w-[120px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 名称 ",-1)),t[125]||(t[125]=e("th",{class:"w-[15%] min-w-[120px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 所属账号 ",-1)),N.value?(i(),d("th",Wg," 创建者 ")):h("",!0),t[126]||(t[126]=e("th",{class:"w-[15%] min-w-[120px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 创建时间 ",-1)),t[127]||(t[127]=e("th",{class:"w-[10%] min-w-[90px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 删除者 ",-1)),t[128]||(t[128]=e("th",{class:"w-[10%] min-w-[90px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 删除时间 ",-1)),t[129]||(t[129]=e("th",{class:"w-[8%] min-w-[60px] px-3 py-4 text-right text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 费用 ",-1)),t[130]||(t[130]=e("th",{class:"w-[8%] min-w-[60px] px-3 py-4 text-right text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," Token ",-1)),t[131]||(t[131]=e("th",{class:"w-[8%] min-w-[60px] px-3 py-4 text-right text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 请求数 ",-1)),t[132]||(t[132]=e("th",{class:"w-[9%] min-w-[80px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 最后使用 ",-1)),t[133]||(t[133]=e("th",{class:"operations-column sticky right-0 w-[15%] min-w-[160px] px-3 py-4 text-left text-xs font-bold uppercase tracking-wider text-gray-700 dark:text-gray-300"}," 操作 ",-1))])]),e("tbody",Ng,[(i(!0),d(te,null,oe(S.value,r=>{var b,G,j,P,E,ce;return i(),d("tr",{key:r.id,class:"table-row"},[e("td",Hg,[e("div",Yg,[t[134]||(t[134]=e("div",{class:"mr-2 flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-red-500 to-red-600"},[e("i",{class:"fas fa-trash text-[10px] text-white"})],-1)),e("div",Qg,[e("div",{class:"truncate text-sm font-semibold text-gray-900 dark:text-gray-100",title:r.name},u(r.name),9,Jg)])])]),e("td",Xg,[e("div",Zg,[r.claudeAccountId?(i(),d("div",ep,t[135]||(t[135]=[e("span",{class:"inline-flex items-center rounded bg-blue-100 px-1.5 py-0.5 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},[e("i",{class:"fas fa-robot mr-1 text-[10px]"}),A(" Claude OAuth ")],-1)]))):r.claudeConsoleAccountId?(i(),d("div",tp,t[136]||(t[136]=[e("span",{class:"inline-flex items-center rounded bg-green-100 px-1.5 py-0.5 text-green-700 dark:bg-green-900/30 dark:text-green-300"},[e("i",{class:"fas fa-terminal mr-1 text-[10px]"}),A(" Claude Console ")],-1)]))):r.geminiAccountId?(i(),d("div",sp,t[137]||(t[137]=[e("span",{class:"inline-flex items-center rounded bg-purple-100 px-1.5 py-0.5 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300"},[e("i",{class:"fa-google mr-1 text-[10px]"}),A(" Gemini ")],-1)]))):(i(),d("div",ap,t[138]||(t[138]=[e("i",{class:"fas fa-share-alt mr-1"},null,-1),A(" 共享池 ",-1)])))])]),N.value?(i(),d("td",rp,[e("div",op,[r.createdBy==="admin"?(i(),d("span",lp,t[139]||(t[139]=[e("i",{class:"fas fa-user-shield mr-1 text-xs"},null,-1),A(" 管理员 ",-1)]))):r.userUsername?(i(),d("span",ip,[t[140]||(t[140]=e("i",{class:"fas fa-user mr-1 text-xs"},null,-1)),A(" "+u(r.userUsername),1)])):(i(),d("span",np,t[141]||(t[141]=[e("i",{class:"fas fa-question-circle mr-1 text-xs"},null,-1),A(" 未知 ",-1)])))])])):h("",!0),e("td",dp,u(Ve(r.createdAt)),1),e("td",up,[e("div",cp,[r.deletedByType==="admin"?(i(),d("span",gp,[t[142]||(t[142]=e("i",{class:"fas fa-user-shield mr-1 text-xs"},null,-1)),A(" "+u(r.deletedBy),1)])):r.deletedByType==="user"?(i(),d("span",pp,[t[143]||(t[143]=e("i",{class:"fas fa-user mr-1 text-xs"},null,-1)),A(" "+u(r.deletedBy),1)])):(i(),d("span",mp,[t[144]||(t[144]=e("i",{class:"fas fa-cog mr-1 text-xs"},null,-1)),A(" "+u(r.deletedBy),1)]))])]),e("td",xp,u(Ve(r.deletedAt)),1),e("td",yp,[e("span",fp," $"+u((((G=(b=r.usage)==null?void 0:b.total)==null?void 0:G.cost)||0).toFixed(2)),1)]),e("td",bp,[e("span",vp,u($e(((P=(j=r.usage)==null?void 0:j.total)==null?void 0:P.tokens)||0)),1)]),e("td",kp,[e("div",wp,[e("span",hp,u(yt(((ce=(E=r.usage)==null?void 0:E.total)==null?void 0:ce.requests)||0)),1),t[145]||(t[145]=e("span",{class:"text-xs text-gray-500"},"次",-1))])]),e("td",Ap,[e("div",$p,[r.lastUsedAt?(i(),d("span",{key:0,class:"cursor-help",style:{"font-size":"13px"},title:new Date(r.lastUsedAt).toLocaleString("zh-CN")},u(bt(r.lastUsedAt)),9,Cp)):(i(),d("span",Ip,"从未使用")),kt(r)?(i(),d("span",{key:2,class:"mt-1 text-xs text-gray-500 dark:text-gray-400",title:Qe(r)},[A(u(ht(r))+" ",1),At(r)?h("",!0):(i(),d("span",Lp," ("+u(gt(r))+") ",1))],8,Kp)):(i(),d("span",Dp," 暂无使用账号 "))])]),e("td",_p,[e("div",Sp,[r.canRestore?(i(),d("button",{key:0,class:"rounded-lg bg-green-50 px-3 py-1.5 text-xs font-medium text-green-600 transition-colors hover:bg-green-100 dark:bg-green-900/30 dark:text-green-400 dark:hover:bg-green-900/50",title:"恢复 API Key",onClick:w=>Ts(r.id)},t[146]||(t[146]=[e("i",{class:"fas fa-undo mr-1"},null,-1),A(" 恢复 ",-1)]),8,Tp)):h("",!0),e("button",{class:"rounded-lg bg-red-50 px-3 py-1.5 text-xs font-medium text-red-600 transition-colors hover:bg-red-100 dark:bg-red-900/30 dark:text-red-400 dark:hover:bg-red-900/50",title:"彻底删除 API Key",onClick:w=>Ps(r.id)},t[147]||(t[147]=[e("i",{class:"fas fa-times mr-1"},null,-1),A(" 彻底删除 ",-1)]),8,Pp)])])])}),128))])])])])]))])):h("",!0)])]),re.value?(i(),ye(oo,{key:0,accounts:o.value,onBatchSuccess:Ks,onClose:t[21]||(t[21]=r=>re.value=!1),onSuccess:Is},null,8,["accounts"])):h("",!0),Ie.value?(i(),ye(dl,{key:1,accounts:o.value,"api-key":_t.value,onClose:t[22]||(t[22]=r=>Ie.value=!1),onSuccess:_s},null,8,["accounts","api-key"])):h("",!0),at.value?(i(),ye(Il,{key:2,"api-key":St.value,onClose:t[23]||(t[23]=r=>at.value=!1),onSuccess:Ss},null,8,["api-key"])):h("",!0),mt.value?(i(),ye(jl,{key:3,"api-key":Tt.value,onClose:t[24]||(t[24]=r=>mt.value=!1)},null,8,["api-key"])):h("",!0),xt.value?(i(),ye(ci,{key:4,"api-keys":Pt.value,onClose:t[25]||(t[25]=r=>xt.value=!1)},null,8,["api-keys"])):h("",!0),rt.value?(i(),ye(on,{key:5,accounts:o.value,"selected-keys":$.value,onClose:t[26]||(t[26]=r=>rt.value=!1),onSuccess:Ds},null,8,["accounts","selected-keys"])):h("",!0),le(Tn,{ref_key:"expiryEditModalRef",ref:m,"api-key":n.value||{id:null,expiresAt:null,name:""},show:!!n.value,onClose:Jt,onSave:Rs},null,8,["api-key","show"]),le(Ud,{"api-key":g.value||{},show:C.value,onClose:t[27]||(t[27]=r=>C.value=!1)},null,8,["api-key","show"])])}}},Gp=_e(Up,[["__scopeId","data-v-b2ae0761"]]);export{Gp as default};
|