Files
claude-relay-service/web/admin-spa/dist/assets/index-D3bIJLrk.js

3 lines
12 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LoginView-BccX9MEv.js","assets/vue-vendor-CKToUHZx.js","assets/element-plus-B8Fs_0jW.js","assets/vendor-BDiMbLwQ.js","assets/element-plus-CPnoEkWW.css","assets/LoginView-tn0RQdqM.css","assets/LogoTitle-BiOf3Vkp.css","assets/MainLayout-VM3pfyce.js","assets/toast-BvwA7Mwb.js","assets/LogoTitle-BIy_PC38.js","assets/MainLayout-CXiJ2-1D.css","assets/DashboardView-C1WGP7UM.js","assets/chart-Cor9iTVD.js","assets/DashboardView-R6dMwgzw.css","assets/ApiKeysView-H8g1IO_M.js","assets/ApiKeysView-CID1mfnM.css","assets/AccountsView-tVq-jcj7.js","assets/AccountsView-DwS76LKN.css","assets/TutorialView-Bj1w0Zae.js","assets/TutorialView-B16hEjh7.css","assets/SettingsView-s66COg9q.js","assets/SettingsView-CY0posDI.css","assets/ApiStatsView-Bw7MZuTj.js","assets/ApiStatsView-BP2davUr.css"])))=>i.map(i=>d[i]);
import{aP as K,aQ as W,aR as M,r as _,c as S,q as V,V as D,I as q,z as h,x as b,ac as F,Q as G,a5 as N,y,C as R,L as x,P as T,Y as U,B as H,R as k,J,T as Q,O as X,av as Y,aM as Z,aS as ee}from"./vue-vendor-CKToUHZx.js";import{i as te,z as oe}from"./element-plus-B8Fs_0jW.js";import"./vendor-BDiMbLwQ.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&o(a)}).observe(document,{childList:!0,subtree:!0});function e(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(n){if(n.ep)return;n.ep=!0;const r=e(n);fetch(n.href,r)}})();const se="modulepreload",ne=function(s){return"/admin-next/"+s},$={},w=function(t,e,o){let n=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),p=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));n=Promise.allSettled(e.map(c=>{if(c=ne(c),c in $)return;$[c]=!0;const l=c.endsWith(".css"),d=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const i=document.createElement("link");if(i.rel=l?"stylesheet":se,l||(i.as="script"),i.crossOrigin="",i.href=c,p&&i.setAttribute("nonce",p),document.head.appendChild(i),l)return new Promise((m,f)=>{i.addEventListener("load",m),i.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=a,window.dispatchEvent(p),!p.defaultPrevented)throw a}return n.then(a=>{for(const p of a||[])p.status==="rejected"&&r(p.reason);return t().catch(r)})},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-BccX9MEv.js"),__vite__mapDeps([0,1,2,3,4,5,6])),E=()=>w(()=>import("./MainLayout-VM3pfyce.js"),__vite__mapDeps([7,1,8,9,6,2,3,4,10])),ce=()=>w(()=>import("./DashboardView-C1WGP7UM.js"),__vite__mapDeps([11,2,1,3,4,8,12,13])),le=()=>w(()=>import("./ApiKeysView-H8g1IO_M.js"),__vite__mapDeps([14,2,1,3,4,8,15])),ue=()=>w(()=>import("./AccountsView-tVq-jcj7.js"),__vite__mapDeps([16,1,8,2,3,4,17])),de=()=>w(()=>import("./TutorialView-Bj1w0Zae.js"),__vite__mapDeps([18,1,2,3,4,19])),fe=()=>w(()=>import("./SettingsView-s66COg9q.js"),__vite__mapDeps([20,1,8,2,3,4,21])),he=()=>w(()=>import("./ApiStatsView-Bw7MZuTj.js"),__vite__mapDeps([22,1,9,6,3,18,2,4,19,23])),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),n=this.buildConfig({...e,method:"GET"});try{const r=await fetch(o,n);return await this.handleResponse(r)}catch(r){throw console.error("API GET Error:",r),r}}async post(t,e=null,o={}){const n=P(t),r=this.buildConfig({...o,method:"POST",body:e?JSON.stringify(e):void 0});try{const a=await fetch(n,r);return await this.handleResponse(a)}catch(a){throw console.error("API POST Error:",a),a}}async put(t,e=null,o={}){const n=P(t),r=this.buildConfig({...o,method:"PUT",body:e?JSON.stringify(e):void 0});try{const a=await fetch(n,r);return await this.handleResponse(a)}catch(a){throw console.error("API PUT Error:",a),a}}async delete(t,e={}){const o=P(t),n=this.buildConfig({...e,method:"DELETE"});try{const r=await fetch(o,n);return await this.handleResponse(r)}catch(r){throw console.error("API DELETE Error:",r),r}}}const A=new pe,B=M("auth",()=>{const s=_(!1),t=_(localStorage.getItem("authToken")||""),e=_(""),o=_(""),n=_(!1),r=_({siteName:"Claude Relay Service",siteIcon:"",siteIconData:"",faviconData:""}),a=_(!0),p=S(()=>!!t.value&&s.value),c=S(()=>t.value),l=S(()=>({username:e.value}));async function d(u){n.value=!0,o.value="";try{const g=await A.post("/web/auth/login",u);g.success?(t.value=g.token,e.value=g.username||u.username,s.value=!0,localStorage.setItem("authToken",g.token),await C.push("/dashboard")):o.value=g.message||"登录失败"}catch(g){o.value=g.message||"登录失败,请检查用户名和密码"}finally{n.value=!1}}function i(){s.value=!1,t.value="",e.value="",localStorage.removeItem("authToken"),C.push("/login")}function m(){t.value&&(s.value=!0,f())}async function f(){try{const u=await A.get("/web/auth/user");u.success&&u.user&&(e.value=u.user.username),(await A.get("/admin/dashboard")).success||i()}catch{i()}}async function v(){a.value=!0;try{const u=await A.get("/admin/oem-settings");if(u.success&&u.data){if(r.value={...r.value,...u.data},u.data.siteIconData||u.data.siteIcon){const g=document.querySelector("link[rel*='icon']")||document.createElement("link");g.type="image/x-icon",g.rel="shortcut icon",g.href=u.data.siteIconData||u.data.siteIcon,document.getElementsByTagName("head")[0].appendChild(g)}u.data.siteName&&(document.title=`${u.data.siteName} - 管理后台`)}}catch(u){console.error("加载OEM设置失败:",u)}finally{a.value=!1}}return{isLoggedIn:s,authToken:t,username:e,loginError:o,loginLoading:n,oemSettings:r,oemLoading:a,isAuthenticated:p,token:c,user:l,login:d,logout:i,checkAuth:m,loadOemSettings:v}}),O=(s,t)=>{const e=s.__vccOpts||s;for(const[o,n]of t)e[o]=n;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 n=l=>{const d={success:"fas fa-check-circle",error:"fas fa-exclamation-circle",warning:"fas fa-exclamation-triangle",info:"fas fa-info-circle"};return d[l]||d.info},r=(l,d="info",i=null,m=5e3)=>{const f=++o,v={id:f,message:l,type:d,title:i,duration:m,isVisible:!1};return e.value.push(v),setTimeout(()=>{v.isVisible=!0},10),m>0&&setTimeout(()=>{a(f)},m),f},a=l=>{const d=e.value.findIndex(i=>i.id===l);if(d>-1){const i=e.value[d];i.isVisible=!1,setTimeout(()=>{const m=e.value.findIndex(f=>f.id===l);m>-1&&e.value.splice(m,1)},300)}},p=()=>{e.value.forEach(l=>{l.isVisible=!1}),setTimeout(()=>{e.value.length=0},300)},c=(l,d="info",i=null,m=5e3)=>r(l,d,i,m);return V(()=>{window.showToast=c}),D(()=>{window.showToast===c&&delete window.showToast}),t({showToast:c,removeToast:a,clearAllToasts:p}),(l,d)=>(y(),q(N,{to:"body"},[h("div",_e,[(y(!0),b(G,null,F(e.value,i=>(y(),b("div",{key:i.id,class:R(["toast",`toast-${i.type}`,i.isVisible?"toast-show":"toast-hide"]),onClick:m=>a(i.id)},[h("div",ve,[h("div",ye,[h("i",{class:R(n(i.type))},null,2)]),h("div",we,[i.title?(y(),b("div",be,T(i.title),1)):x("",!0),h("div",Te,T(i.message),1)]),h("button",{class:"toast-close",onClick:U(m=>a(i.id),["stop"])},d[0]||(d[0]=[h("i",{class:"fas fa-times"},null,-1)]),8,Ee)]),i.duration>0?(y(),b("div",{key:0,class:"toast-progress",style:H({animationDuration:`${i.duration}ms`})},null,4)):x("",!0)],10,ge))),128))])]))}},Ae=O(Pe,[["__scopeId","data-v-1a3ab19b"]]),ke={class:"modal-content w-full max-w-md p-6 mx-auto"},xe={class:"flex items-start gap-4 mb-6"},Ce={class:"flex-1"},Ie={class:"text-lg font-semibold text-gray-900 mb-2"},Le={class:"text-gray-600 leading-relaxed whitespace-pre-line"},Se={class:"flex items-center justify-end gap-3"},Re=["disabled"],Ve=["disabled"],Oe={key:0,class:"loading-spinner mr-2"},$e={__name:"ConfirmDialog",setup(s,{expose:t}){const e=_(!1),o=_(!1),n=_(""),r=_(""),a=_("确认"),p=_("取消");let c=null;const l=(f,v,u="确认",g="取消")=>new Promise(j=>{n.value=f,r.value=v,a.value=u,p.value=g,e.value=!0,o.value=!1,c=j}),d=()=>{o.value||(o.value=!0,setTimeout(()=>{e.value=!1,o.value=!1,c&&(c(!0),c=null)},200))},i=()=>{o.value||(e.value=!1,c&&(c(!1),c=null))},m=f=>{e.value&&(f.key==="Escape"?i():f.key==="Enter"&&!f.shiftKey&&!f.ctrlKey&&!f.altKey&&d())};return V(()=>{window.showConfirm=l,document.addEventListener("keydown",m)}),D(()=>{window.showConfirm===l&&delete window.showConfirm,document.removeEventListener("keydown",m)}),t({showConfirm:l}),(f,v)=>(y(),q(N,{to:"body"},[k(Q,{name:"modal",appear:""},{default:J(()=>[e.value?(y(),b("div",{key:0,class:"fixed inset-0 modal z-[100] flex items-center justify-center p-4",onClick:U(i,["self"])},[h("div",ke,[h("div",xe,[v[0]||(v[0]=h("div",{class:"flex-shrink-0 w-12 h-12 bg-gradient-to-br from-amber-500 to-amber-600 rounded-xl flex items-center justify-center"},[h("i",{class:"fas fa-exclamation-triangle text-white text-lg"})],-1)),h("div",Ce,[h("h3",Ie,T(n.value),1),h("div",Le,T(r.value),1)])]),h("div",Se,[h("button",{class:"btn bg-gray-100 text-gray-700 hover:bg-gray-200 px-6 py-3",disabled:o.value,onClick:i},T(p.value),9,Re),h("button",{class:R(["btn btn-warning px-6 py-3",{"opacity-50 cursor-not-allowed":o.value}]),disabled:o.value,onClick:d},[o.value?(y(),b("div",Oe)):x("",!0),X(" "+T(a.value),1)],10,Ve)])])])):x("",!0)]),_:1})]))}},De=O($e,[["__scopeId","data-v-bdb20ffd"]]),qe={id:"app"},Ne={__name:"App",setup(s){const t=B(),e=_(),o=_();return V(()=>{t.checkAuth(),t.loadOemSettings()}),(n,r)=>{const a=Y("router-view");return y(),b("div",qe,[k(a),k(Ae,{ref_key:"toastRef",ref:e},null,512),k(De,{ref_key:"confirmRef",ref:o},null,512)])}}},Ue=O(Ne,[["__scopeId","data-v-5cba45f5"]]),L=Z(Ue),ze=ee();L.use(ze);L.use(C);L.use(te,{locale:oe});L.mount("#app");export{O as _,A as a,B as u};