Files
claude-relay-service/web/admin-spa/dist/assets/index-BOKTkHbB.js
2025-09-01 03:45:29 +00:00

3 lines
14 KiB
JavaScript

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