Files
claude-relay-service/assets/index-NpFg0ijv.js
2025-08-21 03:09:16 +00:00

3 lines
12 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LoginView-DLffy4WU.js","assets/vue-vendor-DfnFpxGJ.js","assets/element-plus-BaMaLFJp.js","assets/vendor-BDiMbLwQ.js","assets/element-plus-CPnoEkWW.css","assets/LoginView-tn0RQdqM.css","assets/MainLayout-IHY8q317.js","assets/toast-BvwA7Mwb.js","assets/LogoTitle-DTE_Y2ZC.js","assets/LogoTitle-Bv46QP3i.css","assets/MainLayout-Bduen41e.css","assets/DashboardView-D0L9LJxp.js","assets/chart-Cor9iTVD.js","assets/DashboardView-ipuzMVyP.css","assets/ApiKeysView-87pX_vxa.js","assets/WindowCountdown-RaAYa1A3.js","assets/CustomDropdown-BtCeu-sX.js","assets/CustomDropdown-lYzmkVRt.css","assets/ApiKeysView-NFUpEvXz.css","assets/AccountsView-CAD0O125.js","assets/AccountsView-yTaT2xCI.css","assets/TutorialView-Dfi5XMr9.js","assets/TutorialView-DWpA32mF.css","assets/SettingsView-B9e2oQWY.js","assets/SettingsView-D91yuoIv.css","assets/ApiStatsView-DNx5e_Uq.js","assets/ApiStatsView-C_Qn0Wqn.css"])))=>i.map(i=>d[i]);
import{aP as K,aQ as W,aR as M,r as _,c as L,q as R,V as D,I as N,z as m,x as b,ac as F,Q as J,a5 as q,y,C as O,L as x,P as T,Y as U,B as G,R as k,J as H,T as Q,O as X,av as Y,aM as Z,aS as ee}from"./vue-vendor-DfnFpxGJ.js";import{i as te,z as oe}from"./element-plus-BaMaLFJp.js";import"./vendor-BDiMbLwQ.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const n of i.addedNodes)n.tagName==="LINK"&&n.rel==="modulepreload"&&o(n)}).observe(document,{childList:!0,subtree:!0});function e(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(a){if(a.ep)return;a.ep=!0;const i=e(a);fetch(a.href,i)}})();const se="modulepreload",ne=function(s){return"/admin-next/"+s},$={},w=function(t,e,o){let a=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const n=document.querySelector("meta[property=csp-nonce]"),u=(n==null?void 0:n.nonce)||(n==null?void 0:n.getAttribute("nonce"));a=Promise.allSettled(e.map(c=>{if(c=ne(c),c in $)return;$[c]=!0;const l=c.endsWith(".css"),f=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const r=document.createElement("link");if(r.rel=l?"stylesheet":se,l||(r.as="script"),r.crossOrigin="",r.href=c,u&&r.setAttribute("nonce",u),document.head.appendChild(r),l)return new Promise((p,h)=>{r.addEventListener("load",p),r.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(n){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=n,window.dispatchEvent(u),!u.defaultPrevented)throw n}return a.then(n=>{for(const u of n||[])u.status==="rejected"&&i(u.reason);return t().catch(i)})},I={basePath:"/admin-next/",apiPrefix:""};function ae(s=""){return s&&!s.startsWith("/")&&(s="/"+s),I.basePath+(s.startsWith("#")?s:"#"+s)}function re(){return ae("/login")}const ie=()=>w(()=>import("./LoginView-DLffy4WU.js"),__vite__mapDeps([0,1,2,3,4,5])),E=()=>w(()=>import("./MainLayout-IHY8q317.js"),__vite__mapDeps([6,1,7,8,9,2,3,4,10])),ce=()=>w(()=>import("./DashboardView-D0L9LJxp.js"),__vite__mapDeps([11,2,1,3,4,7,12,13])),le=()=>w(()=>import("./ApiKeysView-87pX_vxa.js"),__vite__mapDeps([14,2,1,3,4,7,15,16,17,18])),ue=()=>w(()=>import("./AccountsView-CAD0O125.js"),__vite__mapDeps([19,2,1,3,4,7,16,17,20])),de=()=>w(()=>import("./TutorialView-Dfi5XMr9.js"),__vite__mapDeps([21,1,2,3,4,22])),fe=()=>w(()=>import("./SettingsView-B9e2oQWY.js"),__vite__mapDeps([23,1,7,2,3,4,24])),he=()=>w(()=>import("./ApiStatsView-DNx5e_Uq.js"),__vite__mapDeps([25,1,8,9,3,15,21,2,4,22,26])),me=[{path:"/",redirect:()=>{const s=window.location.pathname,t=I.basePath.replace(/\/$/,"");return s===t||s===t+"/","/api-stats"}},{path:"/login",name:"Login",component:ie,meta:{requiresAuth:!1}},{path:"/api-stats",name:"ApiStats",component:he,meta:{requiresAuth:!1}},{path:"/dashboard",component:E,meta:{requiresAuth:!0},children:[{path:"",name:"Dashboard",component:ce}]},{path:"/api-keys",component:E,meta:{requiresAuth:!0},children:[{path:"",name:"ApiKeys",component:le}]},{path:"/accounts",component:E,meta:{requiresAuth:!0},children:[{path:"",name:"Accounts",component:ue}]},{path:"/tutorial",component:E,meta:{requiresAuth:!0},children:[{path:"",name:"Tutorial",component:de}]},{path:"/settings",component:E,meta:{requiresAuth:!0},children:[{path:"",name:"Settings",component:fe}]},{path:"/:pathMatch(.*)*",redirect:"/api-stats"}],C=K({history:W(I.basePath),routes:me});C.beforeEach((s,t,e)=>{const o=B();if(console.log("路由导航:",{to:s.path,from:t.path,fullPath:s.fullPath,requiresAuth:s.meta.requiresAuth,isAuthenticated:o.isAuthenticated}),s.path===t.path&&s.fullPath===t.fullPath)return e();s.path==="/api-stats"||s.path.startsWith("/api-stats")?e():s.meta.requiresAuth&&!o.isAuthenticated?e("/login"):s.path==="/login"&&o.isAuthenticated?e("/dashboard"):e()});const z=I.apiPrefix;function P(s){return s.startsWith("/")||(s="/"+s),z+s}class pe{constructor(){this.baseURL=z}getAuthToken(){return localStorage.getItem("authToken")||null}buildConfig(t={}){const e={headers:{"Content-Type":"application/json",...t.headers},...t},o=this.getAuthToken();return o&&(e.headers.Authorization=`Bearer ${o}`),e}async handleResponse(t){if(t.status===401){const o=window.location.pathname+window.location.hash;throw o.includes("/login")||o.endsWith("/")||(localStorage.removeItem("authToken"),window.location.href=re()),new Error("Unauthorized")}const e=t.headers.get("content-type");if(e&&e.includes("application/json")){const o=await t.json();if(!t.ok)throw new Error(o.message||`HTTP ${t.status}`);return o}if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);return t}async get(t,e={}){const o=P(t),a=this.buildConfig({...e,method:"GET"});try{const i=await fetch(o,a);return await this.handleResponse(i)}catch(i){throw console.error("API GET Error:",i),i}}async post(t,e=null,o={}){const a=P(t),i=this.buildConfig({...o,method:"POST",body:e?JSON.stringify(e):void 0});try{const n=await fetch(a,i);return await this.handleResponse(n)}catch(n){throw console.error("API POST Error:",n),n}}async put(t,e=null,o={}){const a=P(t),i=this.buildConfig({...o,method:"PUT",body:e?JSON.stringify(e):void 0});try{const n=await fetch(a,i);return await this.handleResponse(n)}catch(n){throw console.error("API PUT Error:",n),n}}async delete(t,e={}){const o=P(t),{data:a,...i}=e,n=this.buildConfig({...i,method:"DELETE",body:a?JSON.stringify(a):void 0});try{const u=await fetch(o,n);return await this.handleResponse(u)}catch(u){throw console.error("API DELETE Error:",u),u}}}const A=new pe,B=M("auth",()=>{const s=_(!1),t=_(localStorage.getItem("authToken")||""),e=_(""),o=_(""),a=_(!1),i=_({siteName:"Claude Relay Service",siteIcon:"",siteIconData:"",faviconData:""}),n=_(!0),u=L(()=>!!t.value&&s.value),c=L(()=>t.value),l=L(()=>({username:e.value}));async function f(d){a.value=!0,o.value="";try{const g=await A.post("/web/auth/login",d);g.success?(t.value=g.token,e.value=g.username||d.username,s.value=!0,localStorage.setItem("authToken",g.token),await C.push("/dashboard")):o.value=g.message||"登录失败"}catch(g){o.value=g.message||"登录失败,请检查用户名和密码"}finally{a.value=!1}}function r(){s.value=!1,t.value="",e.value="",localStorage.removeItem("authToken"),C.push("/login")}function p(){t.value&&(s.value=!0,h())}async function h(){try{const d=await A.get("/web/auth/user");d.success&&d.user&&(e.value=d.user.username),(await A.get("/admin/dashboard")).success||r()}catch{r()}}async function v(){n.value=!0;try{const d=await A.get("/admin/oem-settings");if(d.success&&d.data){if(i.value={...i.value,...d.data},d.data.siteIconData||d.data.siteIcon){const g=document.querySelector("link[rel*='icon']")||document.createElement("link");g.type="image/x-icon",g.rel="shortcut icon",g.href=d.data.siteIconData||d.data.siteIcon,document.getElementsByTagName("head")[0].appendChild(g)}d.data.siteName&&(document.title=`${d.data.siteName} - 管理后台`)}}catch(d){console.error("加载OEM设置失败:",d)}finally{n.value=!1}}return{isLoggedIn:s,authToken:t,username:e,loginError:o,loginLoading:a,oemSettings:i,oemLoading:n,isAuthenticated:u,token:c,user:l,login:f,logout:r,checkAuth:p,loadOemSettings:v}}),V=(s,t)=>{const e=s.__vccOpts||s;for(const[o,a]of t)e[o]=a;return e},_e={class:"toast-container"},ge=["onClick"],ve={class:"toast-content"},ye={class:"toast-icon"},we={class:"toast-body"},be={key:0,class:"toast-title"},Te={class:"toast-message"},Ee=["onClick"],Pe={__name:"ToastNotification",setup(s,{expose:t}){const e=_([]);let o=0;const a=l=>{const f={success:"fas fa-check-circle",error:"fas fa-exclamation-circle",warning:"fas fa-exclamation-triangle",info:"fas fa-info-circle"};return f[l]||f.info},i=(l,f="info",r=null,p=5e3)=>{const h=++o,v={id:h,message:l,type:f,title:r,duration:p,isVisible:!1};return e.value.push(v),setTimeout(()=>{v.isVisible=!0},10),p>0&&setTimeout(()=>{n(h)},p),h},n=l=>{const f=e.value.findIndex(r=>r.id===l);if(f>-1){const r=e.value[f];r.isVisible=!1,setTimeout(()=>{const p=e.value.findIndex(h=>h.id===l);p>-1&&e.value.splice(p,1)},300)}},u=()=>{e.value.forEach(l=>{l.isVisible=!1}),setTimeout(()=>{e.value.length=0},300)},c=(l,f="info",r=null,p=5e3)=>i(l,f,r,p);return R(()=>{window.showToast=c}),D(()=>{window.showToast===c&&delete window.showToast}),t({showToast:c,removeToast:n,clearAllToasts:u}),(l,f)=>(y(),N(q,{to:"body"},[m("div",_e,[(y(!0),b(J,null,F(e.value,r=>(y(),b("div",{key:r.id,class:O(["toast",`toast-${r.type}`,r.isVisible?"toast-show":"toast-hide"]),onClick:p=>n(r.id)},[m("div",ve,[m("div",ye,[m("i",{class:O(a(r.type))},null,2)]),m("div",we,[r.title?(y(),b("div",be,T(r.title),1)):x("",!0),m("div",Te,T(r.message),1)]),m("button",{class:"toast-close",onClick:U(p=>n(r.id),["stop"])},f[0]||(f[0]=[m("i",{class:"fas fa-times"},null,-1)]),8,Ee)]),r.duration>0?(y(),b("div",{key:0,class:"toast-progress",style:G({animationDuration:`${r.duration}ms`})},null,4)):x("",!0)],10,ge))),128))])]))}},Ae=V(Pe,[["__scopeId","data-v-595950cf"]]),ke={class:"modal-content mx-auto w-full max-w-md p-6"},xe={class:"mb-6 flex items-start gap-4"},Ce={class:"flex-1"},Ie={class:"mb-2 text-lg font-semibold text-gray-900"},Se={class:"whitespace-pre-line leading-relaxed text-gray-600"},Le={class:"flex items-center justify-end gap-3"},Oe=["disabled"],Re=["disabled"],Ve={key:0,class:"loading-spinner mr-2"},$e={__name:"ConfirmDialog",setup(s,{expose:t}){const e=_(!1),o=_(!1),a=_(""),i=_(""),n=_("确认"),u=_("取消");let c=null;const l=(h,v,d="确认",g="取消")=>new Promise(j=>{a.value=h,i.value=v,n.value=d,u.value=g,e.value=!0,o.value=!1,c=j}),f=()=>{o.value||(o.value=!0,setTimeout(()=>{e.value=!1,o.value=!1,c&&(c(!0),c=null)},200))},r=()=>{o.value||(e.value=!1,c&&(c(!1),c=null))},p=h=>{e.value&&(h.key==="Escape"?r():h.key==="Enter"&&!h.shiftKey&&!h.ctrlKey&&!h.altKey&&f())};return R(()=>{window.showConfirm=l,document.addEventListener("keydown",p)}),D(()=>{window.showConfirm===l&&delete window.showConfirm,document.removeEventListener("keydown",p)}),t({showConfirm:l}),(h,v)=>(y(),N(q,{to:"body"},[k(Q,{appear:"",name:"modal"},{default:H(()=>[e.value?(y(),b("div",{key:0,class:"modal fixed inset-0 z-[100] flex items-center justify-center p-4",onClick:U(r,["self"])},[m("div",ke,[m("div",xe,[v[0]||(v[0]=m("div",{class:"flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-xl bg-gradient-to-br from-amber-500 to-amber-600"},[m("i",{class:"fas fa-exclamation-triangle text-lg text-white"})],-1)),m("div",Ce,[m("h3",Ie,T(a.value),1),m("div",Se,T(i.value),1)])]),m("div",Le,[m("button",{class:"btn bg-gray-100 px-6 py-3 text-gray-700 hover:bg-gray-200",disabled:o.value,onClick:r},T(u.value),9,Oe),m("button",{class:O(["btn btn-warning px-6 py-3",{"cursor-not-allowed opacity-50":o.value}]),disabled:o.value,onClick:f},[o.value?(y(),b("div",Ve)):x("",!0),X(" "+T(n.value),1)],10,Re)])])])):x("",!0)]),_:1})]))}},De=V($e,[["__scopeId","data-v-fb5ac82d"]]),Ne={id:"app"},qe={__name:"App",setup(s){const t=B(),e=_(),o=_();return R(()=>{t.checkAuth(),t.loadOemSettings()}),(a,i)=>{const n=Y("router-view");return y(),b("div",Ne,[k(n),k(Ae,{ref_key:"toastRef",ref:e},null,512),k(De,{ref_key:"confirmRef",ref:o},null,512)])}}},Ue=V(qe,[["__scopeId","data-v-5cfdc9c1"]]),S=Z(Ue),ze=ee();S.use(ze);S.use(C);S.use(te,{locale:oe});S.mount("#app");export{V as _,A as a,B as u};