llm-simple-router 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/version.json +4 -0
- package/dist/admin/upgrade.js +8 -1
- package/dist/config/recommended.d.ts +6 -0
- package/dist/config/recommended.js +12 -0
- package/dist/upgrade/checker.js +9 -24
- package/frontend-dist/assets/{index-DPRxBo3N.js → index-C8DKlnvd.js} +1 -1
- package/frontend-dist/index.html +1 -1
- package/package.json +1 -1
package/dist/admin/upgrade.js
CHANGED
|
@@ -120,9 +120,10 @@ export const adminUpgradeRoutes = (app, options, done) => {
|
|
|
120
120
|
const configDir = path.resolve(process.cwd(), 'config');
|
|
121
121
|
try {
|
|
122
122
|
fs.mkdirSync(configDir, { recursive: true });
|
|
123
|
-
const [providersResult, rulesResult] = await Promise.allSettled([
|
|
123
|
+
const [providersResult, rulesResult, versionResult] = await Promise.allSettled([
|
|
124
124
|
fetchJson(`${base}/recommended-providers.json`),
|
|
125
125
|
fetchJson(`${base}/recommended-retry-rules.json`),
|
|
126
|
+
fetchJson(`${base}/version.json`),
|
|
126
127
|
]);
|
|
127
128
|
if (providersResult.status === 'fulfilled') {
|
|
128
129
|
fs.writeFileSync(path.join(configDir, 'recommended-providers.json'), JSON.stringify(providersResult.value, null, JSON_INDENT));
|
|
@@ -130,9 +131,15 @@ export const adminUpgradeRoutes = (app, options, done) => {
|
|
|
130
131
|
if (rulesResult.status === 'fulfilled') {
|
|
131
132
|
fs.writeFileSync(path.join(configDir, 'recommended-retry-rules.json'), JSON.stringify(rulesResult.value, null, JSON_INDENT));
|
|
132
133
|
}
|
|
134
|
+
if (versionResult.status === 'fulfilled') {
|
|
135
|
+
fs.writeFileSync(path.join(configDir, 'version.json'), JSON.stringify(versionResult.value, null, JSON_INDENT));
|
|
136
|
+
}
|
|
133
137
|
if (providersResult.status === 'rejected' && rulesResult.status === 'rejected') {
|
|
134
138
|
throw new Error('同步失败: 无法获取 providers 和 retry-rules 配置');
|
|
135
139
|
}
|
|
140
|
+
if (versionResult.status === 'rejected') {
|
|
141
|
+
process.stderr.write('[upgrade] warning: version.json sync failed, providers/rules synced without version\n');
|
|
142
|
+
}
|
|
136
143
|
reloadConfig();
|
|
137
144
|
if (checker)
|
|
138
145
|
await checker.check(getConfigBaseUrl(source));
|
|
@@ -19,7 +19,13 @@ export interface RecommendedRetryRule {
|
|
|
19
19
|
max_delay_ms: number;
|
|
20
20
|
providers?: string[];
|
|
21
21
|
}
|
|
22
|
+
export interface ConfigVersions {
|
|
23
|
+
providers: number;
|
|
24
|
+
retryRules: number;
|
|
25
|
+
}
|
|
22
26
|
export declare function loadRecommendedConfig(dir?: string): void;
|
|
23
27
|
export declare function getRecommendedProviders(): ProviderGroup[];
|
|
24
28
|
export declare function getRecommendedRetryRules(): RecommendedRetryRule[];
|
|
25
29
|
export declare function reloadConfig(): void;
|
|
30
|
+
/** 读取推荐配置的版本号(来自独立 version.json,历史版本代码不会读取此文件) */
|
|
31
|
+
export declare function getConfigVersions(): ConfigVersions;
|
|
@@ -13,6 +13,18 @@ export function getRecommendedRetryRules() {
|
|
|
13
13
|
// No-op: kept for backward compat (reload endpoint, upgrade flow)
|
|
14
14
|
// Config is now always read from disk, no caching.
|
|
15
15
|
export function reloadConfig() { }
|
|
16
|
+
/** 读取推荐配置的版本号(来自独立 version.json,历史版本代码不会读取此文件) */
|
|
17
|
+
export function getConfigVersions() {
|
|
18
|
+
const filePath = path.join(configDir, 'version.json');
|
|
19
|
+
try {
|
|
20
|
+
if (!fs.existsSync(filePath))
|
|
21
|
+
return { providers: 0, retryRules: 0 };
|
|
22
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return { providers: 0, retryRules: 0 };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
16
28
|
function loadJson(filename) {
|
|
17
29
|
const filePath = path.join(configDir, filename);
|
|
18
30
|
try {
|
package/dist/upgrade/checker.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
2
|
import https from 'node:https';
|
|
3
|
-
import fs from 'node:fs';
|
|
4
3
|
import path from 'node:path';
|
|
5
4
|
import { getInstalledVersion } from './version.js';
|
|
5
|
+
import { getConfigVersions } from '../config/recommended.js';
|
|
6
6
|
const DEFAULT_NPM_REGISTRY = 'https://registry.npmjs.org/llm-simple-router';
|
|
7
7
|
const DEFAULT_GITHUB_CONFIG_BASE = 'https://raw.githubusercontent.com/zhushanwen321/llm-simple-router/main/config';
|
|
8
8
|
const CHECK_TIMEOUT_MS = 5000;
|
|
@@ -61,17 +61,6 @@ export function createUpgradeChecker(options) {
|
|
|
61
61
|
retryRuleChanges: 0,
|
|
62
62
|
};
|
|
63
63
|
let lastCheckedAt = null;
|
|
64
|
-
function loadLocalJson(filename) {
|
|
65
|
-
const filePath = path.join(configDir, filename);
|
|
66
|
-
try {
|
|
67
|
-
if (!fs.existsSync(filePath))
|
|
68
|
-
return null;
|
|
69
|
-
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
64
|
async function checkNpm() {
|
|
76
65
|
try {
|
|
77
66
|
const data = await fetchJson(npmRegistryUrl);
|
|
@@ -89,19 +78,15 @@ export function createUpgradeChecker(options) {
|
|
|
89
78
|
async function checkConfig(sourceOverride) {
|
|
90
79
|
try {
|
|
91
80
|
const base = sourceOverride ?? configBaseUrl;
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const remoteRules = rulesResult.status === 'fulfilled' ? rulesResult.value : null;
|
|
98
|
-
if (!remoteProviders && !remoteRules) {
|
|
99
|
-
throw new Error('both providers and rules fetch failed');
|
|
81
|
+
const remote = await fetchJson(`${base}/version.json`);
|
|
82
|
+
// 远程无 version.json(老版本仓库)→ 视为无更新
|
|
83
|
+
if (remote === null) {
|
|
84
|
+
configStatus = { hasUpdate: false, providerChanges: 0, retryRuleChanges: 0 };
|
|
85
|
+
return;
|
|
100
86
|
}
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
const rulesChanged = remoteRules !== null && JSON.stringify(remoteRules) !== JSON.stringify(localRules);
|
|
87
|
+
const local = getConfigVersions();
|
|
88
|
+
const providersChanged = (remote.providers ?? 0) > local.providers;
|
|
89
|
+
const rulesChanged = (remote.retryRules ?? 0) > local.retryRules;
|
|
105
90
|
configStatus = {
|
|
106
91
|
hasUpdate: providersChanged || rulesChanged,
|
|
107
92
|
providerChanges: providersChanged ? 1 : 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,Bt as t,Ct as n,F as r,G as i,Ht as a,I as ee,J as o,K as s,L as c,M as l,Q as u,Rt as d,U as f,Ut as p,W as te,X as m,Y as h,Z as g,at as _,bt as ne,ct as re,ft as v,ht as y,j as b,jt as x,k as S,lt as ie,mt as C,n as w,q as T,r as ae,ut as E,z as oe}from"./button-D27ClX8J.js";import{n as D,r as O,t as k}from"./i18n-CwUfS0tE.js";import{a as se}from"./format-BhxQSgt6.js";import{a as ce}from"./PopperContent-6BXua_FZ.js";import{a as le,i as ue,n as de,r as A,t as fe}from"./SelectValue-CT2z_-6j.js";import{t as pe}from"./file-text-D33FJAPX.js";import{t as j}from"./loader-circle-EpKC006I.js";import{n as me,t as he}from"./sun-BylRZIWt.js";import{t as M}from"./x-DSgLgKC_.js";import{a as N,c as P,i as F,n as I,o as L,r as R,s as z,t as B}from"./alert-dialog-DzKCAoYJ.js";import{n as ge,r as _e,t as ve}from"./PopoverTrigger-C88SpJNZ.js";import{t as V}from"./badge-C-9zPTgw.js";import{n as H,t as U}from"./lib-D0Ek2pPZ.js";import{n as W,r as ye,t as G}from"./useTheme-CpTI547G.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function be(){let{locale:e}=r();async function t(t){e.value=t,localStorage.setItem(k,t),document.documentElement.setAttribute(`lang`,t),await O(t)}return{locale:e,setLocale:t,localeLabel:i(()=>e.value===`zh-CN`?`中文`:`EN`),toggleTarget:i(()=>e.value===`zh-CN`?`en`:`zh-CN`)}}var xe=l(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Se=l(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),Ce=l(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),we=l(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),K=l(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Te=l(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Ee=l(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),De=l(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Oe=l(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),ke=l(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Ae=l(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),je=l(`refresh-ccw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),Me=l(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Ne=l(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Pe=l(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Fe=l(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ie=l(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),Le={class:`w-56 h-full bg-sidebar text-sidebar-foreground flex-shrink-0 flex flex-col overflow-hidden`},Re={class:`p-4 border-b border-sidebar-border`},ze={class:`flex items-center gap-2`},Be={key:0,class:`p-3 border-b border-border`},Ve={class:`flex items-center gap-2 mb-2`},He={class:`w-4 h-4 rounded-full bg-primary flex items-center justify-center text-primary-foreground`},Ue={class:`text-sm font-medium`},We={class:`text-xs text-muted-foreground mb-2`},Ge={class:`text-primary font-medium`},Ke={key:1,class:`text-xs text-warning bg-warning-light p-2 rounded`},qe={key:1,class:`p-3 border-b border-border`},Je={class:`flex items-center gap-2 mb-2`},Ye={class:`w-4 h-4 rounded-full bg-primary flex items-center justify-center text-primary-foreground`},Xe={class:`text-sm font-medium`},Ze={class:`text-xs text-muted-foreground mb-2`},Qe={class:`flex items-center gap-2 mb-2`},$e={class:`text-xs text-muted-foreground`},et={key:2,class:`p-3`},tt={class:`text-xs text-muted-foreground`},nt={class:`px-3 py-2 flex justify-between items-center text-xs text-muted-foreground`},rt={class:`flex-1 p-2 space-y-0.5 overflow-y-auto`},it={key:0,class:`my-1.5 border-t border-sidebar-border`},at={key:1,class:`flex items-center justify-between px-3 py-1.5`},ot={class:`text-[11px] font-medium text-sidebar-foreground/50 uppercase tracking-wider`},st=[`onClick`],ct={class:`p-3 border-t border-sidebar-border space-y-1`},lt={class:`bg-muted px-1 py-0.5 rounded text-xs`},ut=300*1e3,dt=u({__name:`Sidebar`,setup(l){let{isDark:u,toggleTheme:te}=ye(),{t:_}=r(),{locale:b,setLocale:ae,toggleTarget:oe}=be();async function D(){await ae(oe.value)}let O=x(null),k=x(!1),j=x(!1),M=x(!1),U=x(!1),W=x(!1),G=null;async function K(){try{O.value=await S.getUpgradeStatus()}catch{O.value=null}}async function Ee(){try{await S.triggerUpgradeCheck(),await K()}catch(t){H.error(e(t,_(`sidebar.upgrade.checkFailed`)))}}async function Ae(){if(O.value?.npm.latestVersion){M.value=!0;try{await S.executeUpgrade(O.value.npm.latestVersion),H.success(_(`sidebar.upgrade.upgradeSuccess`)),k.value=!1,j.value=!0,await K()}catch(t){H.error(e(t,_(`sidebar.upgrade.upgradeFailed`)))}finally{M.value=!1}}}async function Fe(){let t=O.value?.syncSource??`github`;U.value=!0;try{await S.syncConfig(t),H.success(_(`sidebar.upgrade.configSyncSuccess`)),await K()}catch(t){H.error(e(t,_(`sidebar.upgrade.syncFailed`)))}finally{U.value=!1}}async function dt(t){if(typeof t==`string`)try{await S.setSyncSource(t),await K()}catch(t){H.error(e(t,_(`sidebar.upgrade.saveFailed`)))}}let q=i(()=>{if(!O.value)return 0;let e=0;return O.value.npm.hasUpdate&&e++,O.value.config.hasUpdate&&e++,e});re(()=>{K(),G=setInterval(K,ut)}),ie(()=>{G&&clearInterval(G)});let J=i(()=>[{items:[{path:`/`,label:_(`sidebar.nav.dashboard`),icon:Oe}]},{label:_(`sidebar.nav.agentConfig`),expandable:!0,items:[{path:`/quick-setup`,label:_(`sidebar.nav.quickSetup`),icon:Ie},{path:`/providers`,label:_(`sidebar.nav.providers`),icon:Ne},{path:`/mappings`,label:_(`sidebar.nav.modelMappings`),icon:Se},{path:`/router-keys`,label:_(`sidebar.nav.routerKeys`),icon:De},{path:`/retry-rules`,label:_(`sidebar.nav.retryRules`),icon:je},{path:`/schedules`,label:_(`sidebar.nav.schedules`),icon:we}]},{label:_(`sidebar.nav.monitoring`),items:[{path:`/monitor`,label:_(`sidebar.nav.monitor`),icon:xe},{path:`/logs`,label:_(`sidebar.nav.logs`),icon:pe}]},{items:[{path:`/settings`,label:_(`sidebar.nav.settings`),icon:Pe}]}]),Y=x(new Set([1]));function X(e){return Y.value.has(e)}function Z(e){let t=new Set(Y.value);t.has(e)?t.delete(e):t.add(e),Y.value=t}let Q=ee(),ft=c();function $(e){return e===`/`?Q.path===`/`:Q.path.startsWith(e)}ne(()=>Q.path,()=>{J.value.forEach((e,t)=>{e.expandable&&e.items.some(e=>$(e.path))&&Y.value.add(t)})},{immediate:!0});async function pt(){try{await S.restartServer(),H.success(_(`sidebar.upgrade.restartSent`)),j.value=!1,setTimeout(()=>{window.location.reload()},5e3)}catch(t){H.error(e(t,_(`sidebar.upgrade.restartFailed`)))}}async function mt(){try{await S.logout()}finally{ft.push(`/login`)}}return(e,r)=>{let i=C(`router-link`);return E(),h(`aside`,Le,[s(`div`,Re,[s(`div`,ze,[r[9]||=s(`div`,{class:`w-8 h-8 bg-sidebar-primary rounded-lg flex items-center justify-center`},[s(`svg`,{class:`w-5 h-5 text-sidebar-primary-foreground`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[s(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z`})])],-1),g(d(_e),{open:W.value,"onUpdate:open":r[1]||=e=>W.value=e},{default:n(()=>[g(d(ve),{"as-child":``},{default:n(()=>[g(d(w),{variant:`ghost`,class:`flex items-center gap-2 px-0 h-auto`},{default:n(()=>[r[5]||=s(`span`,{class:`font-semibold text-sm`},`LLM Router`,-1),g(d(V),{variant:`secondary`,class:`text-[10px] px-1.5 py-0 h-4 leading-none`},{default:n(()=>[m(`v`+p(d(`0.9.4`)),1)]),_:1}),q.value>0?(E(),T(d(V),{key:0,variant:`destructive`,class:`text-[10px] px-1.5 h-4 leading-none bg-destructive text-destructive-foreground font-semibold`},{default:n(()=>[m(p(q.value),1)]),_:1})):o(``,!0)]),_:1})]),_:1}),g(d(ge),{side:`right`,align:`start`,class:`w-80 p-0`},{default:n(()=>[O.value?.npm.hasUpdate?(E(),h(`div`,Be,[s(`div`,Ve,[s(`div`,He,[g(d(Ce),{class:`w-3 h-3`})]),s(`span`,Ue,p(d(_)(`sidebar.upgrade.newVersion`)),1)]),s(`p`,We,[m(p(O.value.npm.currentVersion)+` → `,1),s(`span`,Ge,p(O.value.npm.latestVersion),1)]),O.value.deployment===`npm`?(E(),T(d(w),{key:0,size:`sm`,class:`w-full text-xs`,disabled:M.value,onClick:r[0]||=e=>k.value=!0},{default:n(()=>[m(p(M.value?d(_)(`sidebar.upgrade.upgrading`):d(_)(`sidebar.upgrade.oneClickUpgrade`)),1)]),_:1},8,[`disabled`])):(E(),h(`div`,Ke,[m(p(d(_)(`sidebar.upgrade.dockerDeploy`,{type:O.value.deployment===`docker`?`Docker`:`Unknown`}))+` `,1),r[6]||=s(`code`,{class:`block mt-1 text-warning bg-warning-dark/10 p-1 rounded`},`docker pull ghcr.io/zhushanwen321/llm-simple-router:latest`,-1)]))])):o(``,!0),O.value?.config.hasUpdate?(E(),h(`div`,qe,[s(`div`,Je,[s(`div`,Ye,[g(d(Me),{class:`w-3 h-3`})]),s(`span`,Xe,p(d(_)(`sidebar.upgrade.configUpdated`)),1)]),s(`p`,Ze,p(d(_)(`sidebar.upgrade.configUpdatedDesc`)),1),s(`div`,Qe,[s(`span`,$e,p(d(_)(`sidebar.upgrade.source`)),1),g(d(le),{"model-value":O.value?.syncSource,"onUpdate:modelValue":dt},{default:n(()=>[g(d(de),{class:`h-7 text-xs flex-1`},{default:n(()=>[g(d(fe))]),_:1}),g(d(ue),null,{default:n(()=>[g(d(A),{value:`github`},{default:n(()=>[...r[7]||=[m(`GitHub`,-1)]]),_:1}),g(d(A),{value:`gitee`},{default:n(()=>[...r[8]||=[m(`Gitee`,-1)]]),_:1})]),_:1})]),_:1},8,[`model-value`])]),g(d(w),{size:`sm`,variant:`secondary`,class:`w-full text-xs`,disabled:U.value,onClick:Fe},{default:n(()=>[m(p(U.value?d(_)(`sidebar.upgrade.syncing`):d(_)(`sidebar.upgrade.syncConfig`)),1)]),_:1},8,[`disabled`])])):o(``,!0),!O.value?.npm.hasUpdate&&!O.value?.config.hasUpdate?(E(),h(`div`,et,[s(`p`,tt,p(d(_)(`sidebar.upgrade.upToDate`)),1)])):o(``,!0),s(`div`,nt,[s(`span`,null,p(O.value?.lastCheckedAt?d(_)(`sidebar.upgrade.checkedAt`,{time:d(se)(O.value.lastCheckedAt).toLocaleTimeString(d(b)===`zh-CN`?`zh-CN`:`en`,{timeZone:`Asia/Shanghai`})}):d(_)(`sidebar.upgrade.notChecked`)),1),g(d(w),{variant:`link`,class:`text-primary h-auto p-0`,onClick:Ee},{default:n(()=>[m(p(d(_)(`sidebar.upgrade.checkNow`)),1)]),_:1})])]),_:1})]),_:1},8,[`open`])])]),s(`nav`,rt,[(E(!0),h(f,null,v(J.value,(e,r)=>(E(),h(f,{key:r},[r>0?(E(),h(`div`,it)):o(``,!0),e.label?(E(),h(`div`,at,[s(`span`,ot,p(e.label),1),e.expandable?(E(),h(`button`,{key:0,type:`button`,class:`flex items-center justify-center w-5 h-5 rounded hover:bg-sidebar-accent text-sidebar-foreground/50 hover:text-sidebar-foreground transition-colors cursor-pointer select-none`,onClick:e=>Z(r)},[g(d(ce),{class:t([`w-3.5 h-3.5 transition-transform duration-200`,X(r)?`rotate-0`:`-rotate-90`])},null,8,[`class`])],8,st)):o(``,!0)])):o(``,!0),e.expandable?(E(),h(`div`,{key:2,class:`overflow-hidden transition-all duration-200 ease-in-out`,style:a({maxHeight:X(r)?e.items.length*44+`px`:`0px`,opacity:+!!X(r)})},[(E(!0),h(f,null,v(e.items,e=>(E(),T(i,{key:e.path,to:e.path,class:t([`flex items-center gap-3 px-3 py-2 ml-1 rounded-lg text-sm transition-colors`,$(e.path)?`bg-sidebar-accent text-sidebar-primary`:`text-sidebar-foreground hover:bg-sidebar-accent`])},{default:n(()=>[(E(),T(y(e.icon),{class:`w-4 h-4`})),m(` `+p(e.label),1)]),_:2},1032,[`to`,`class`]))),128))],4)):o(``,!0),e.expandable?o(``,!0):(E(!0),h(f,{key:3},v(e.items,e=>(E(),T(i,{key:e.path,to:e.path,class:t([`flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors`,$(e.path)?`bg-sidebar-accent text-sidebar-primary`:`text-sidebar-foreground hover:bg-sidebar-accent`])},{default:n(()=>[(E(),T(y(e.icon),{class:`w-4 h-4`})),m(` `+p(e.label),1)]),_:2},1032,[`to`,`class`]))),128))],64))),128))]),s(`div`,ct,[g(d(w),{variant:`ghost`,class:`w-full justify-start text-sidebar-foreground hover:text-sidebar-foreground hover:bg-sidebar-accent`,onClick:d(te)},{default:n(()=>[d(u)?(E(),T(d(he),{key:1,class:`w-4 h-4`})):(E(),T(d(me),{key:0,class:`w-4 h-4`})),m(` `+p(d(u)?d(_)(`sidebar.theme.light`):d(_)(`sidebar.theme.dark`)),1)]),_:1},8,[`onClick`]),g(d(w),{variant:`ghost`,class:`w-full justify-start text-sidebar-foreground hover:text-sidebar-foreground hover:bg-sidebar-accent`,onClick:D},{default:n(()=>[g(d(Te),{class:`w-4 h-4`}),m(` `+p(d(b)===`zh-CN`?d(_)(`sidebar.language.switchToEn`):d(_)(`sidebar.language.switchToZh`)),1)]),_:1}),g(d(w),{variant:`ghost`,class:`w-full justify-start text-sidebar-foreground hover:text-sidebar-foreground hover:bg-sidebar-accent`,onClick:mt},{default:n(()=>[g(d(ke),{class:`w-4 h-4`}),m(` `+p(d(_)(`sidebar.logout`)),1)]),_:1})]),g(d(P),{open:k.value,"onUpdate:open":r[2]||=e=>k.value=e},{default:n(()=>[g(d(N),null,{default:n(()=>[g(d(I),null,{default:n(()=>[g(d(B),null,{default:n(()=>[m(p(d(_)(`sidebar.upgrade.confirmUpgrade`,{version:O.value?.npm.latestVersion})),1)]),_:1}),g(d(F),null,{default:n(()=>[m(p(d(_)(`sidebar.upgrade.upgradeDescBefore`))+` `,1),s(`code`,lt,`npm install -g llm-simple-router@`+p(O.value?.npm.latestVersion),1),m(p(d(_)(`sidebar.upgrade.upgradeDescAfter`)),1)]),_:1})]),_:1}),g(d(R),null,{default:n(()=>[g(d(L),null,{default:n(()=>[m(p(d(_)(`common.cancel`)),1)]),_:1}),g(d(z),{onClick:Ae,disabled:M.value},{default:n(()=>[m(p(M.value?d(_)(`sidebar.upgrade.upgrading`):d(_)(`common.confirm`)),1)]),_:1},8,[`disabled`])]),_:1})]),_:1})]),_:1},8,[`open`]),g(d(P),{open:j.value,"onUpdate:open":r[4]||=e=>j.value=e},{default:n(()=>[g(d(N),null,{default:n(()=>[g(d(I),null,{default:n(()=>[g(d(B),null,{default:n(()=>[m(p(d(_)(`sidebar.upgrade.upgradeSuccess`)),1)]),_:1}),g(d(F),null,{default:n(()=>[m(p(d(_)(`sidebar.upgrade.restartNeeded`,{version:O.value?.npm.latestVersion})),1)]),_:1})]),_:1}),g(d(R),null,{default:n(()=>[g(d(L),{onClick:r[3]||=e=>j.value=!1},{default:n(()=>[m(p(d(_)(`sidebar.upgrade.laterRestart`)),1)]),_:1}),g(d(z),{onClick:pt},{default:n(()=>[m(p(d(_)(`sidebar.upgrade.restartNow`)),1)]),_:1})]),_:1})]),_:1})]),_:1},8,[`open`])])}}}),q=u({__name:`Sonner`,props:{id:{},invert:{type:Boolean},theme:{},position:{},closeButtonPosition:{},hotkey:{},richColors:{type:Boolean},expand:{type:Boolean},duration:{},gap:{},visibleToasts:{},closeButton:{type:Boolean},toastOptions:{},class:{},style:{},offset:{},mobileOffset:{},dir:{},swipeDirections:{},icons:{},containerAriaLabel:{}},setup(e){let t=e;return(e,r)=>(E(),T(d(U),_({class:d(ae)(`toaster group`,t.class),style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius)`}},t),{"success-icon":n(()=>[g(d(K),{class:`size-4`})]),"info-icon":n(()=>[g(d(Ee),{class:`size-4`})]),"warning-icon":n(()=>[g(d(Fe),{class:`size-4`})]),"error-icon":n(()=>[g(d(Ae),{class:`size-4`})]),"loading-icon":n(()=>[s(`div`,null,[g(d(j),{class:`size-4 animate-spin`})])]),"close-icon":n(()=>[g(d(M),{class:`size-4`})]),_:1},16,[`class`]))}}),J={key:0,class:`h-screen flex overflow-hidden`},Y={class:`flex-1 overflow-auto bg-muted`},X=u({__name:`App`,setup(e){let t=c(),n=ee(),r=x(!1),a=i(()=>W.value?`dark`:`light`),o=[`/login`,`/setup`];async function l(){if(o.includes(n.path)){r.value=!1;return}try{await S.getStats(),r.value=!0}catch{r.value=!1,t.push(`/login`)}}return l(),ne(()=>n.path,l),(e,t)=>{let n=C(`router-view`);return E(),h(f,null,[r.value?(E(),h(`div`,J,[g(dt),s(`main`,Y,[g(n)])])):(E(),T(n,{key:1})),(E(),T(te,{to:`body`},[g(d(q),{theme:a.value,richColors:``,position:`top-center`,toastOptions:{duration:4e3}},null,8,[`theme`])]))],64)}}});G();var Z=oe(X);Z.use(b),Z.use(D);var Q=D.global.locale.value;document.documentElement.setAttribute(`lang`,Q),O(Q).then(()=>{Z.mount(`#app`)});
|
|
1
|
+
import{A as e,Bt as t,Ct as n,F as r,G as i,Ht as a,I as ee,J as o,K as s,L as c,M as l,Q as u,Rt as d,U as f,Ut as p,W as te,X as m,Y as h,Z as g,at as _,bt as ne,ct as re,ft as v,ht as y,j as b,jt as x,k as S,lt as ie,mt as C,n as w,q as T,r as ae,ut as E,z as oe}from"./button-D27ClX8J.js";import{n as D,r as O,t as k}from"./i18n-CwUfS0tE.js";import{a as se}from"./format-BhxQSgt6.js";import{a as ce}from"./PopperContent-6BXua_FZ.js";import{a as le,i as ue,n as de,r as A,t as fe}from"./SelectValue-CT2z_-6j.js";import{t as pe}from"./file-text-D33FJAPX.js";import{t as j}from"./loader-circle-EpKC006I.js";import{n as me,t as he}from"./sun-BylRZIWt.js";import{t as M}from"./x-DSgLgKC_.js";import{a as N,c as P,i as F,n as I,o as L,r as R,s as z,t as B}from"./alert-dialog-DzKCAoYJ.js";import{n as ge,r as _e,t as ve}from"./PopoverTrigger-C88SpJNZ.js";import{t as V}from"./badge-C-9zPTgw.js";import{n as H,t as U}from"./lib-D0Ek2pPZ.js";import{n as W,r as ye,t as G}from"./useTheme-CpTI547G.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function be(){let{locale:e}=r();async function t(t){e.value=t,localStorage.setItem(k,t),document.documentElement.setAttribute(`lang`,t),await O(t)}return{locale:e,setLocale:t,localeLabel:i(()=>e.value===`zh-CN`?`中文`:`EN`),toggleTarget:i(()=>e.value===`zh-CN`?`en`:`zh-CN`)}}var xe=l(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Se=l(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),Ce=l(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),we=l(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),K=l(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Te=l(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Ee=l(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),De=l(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Oe=l(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),ke=l(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Ae=l(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),je=l(`refresh-ccw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),Me=l(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Ne=l(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Pe=l(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Fe=l(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ie=l(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),Le={class:`w-56 h-full bg-sidebar text-sidebar-foreground flex-shrink-0 flex flex-col overflow-hidden`},Re={class:`p-4 border-b border-sidebar-border`},ze={class:`flex items-center gap-2`},Be={key:0,class:`p-3 border-b border-border`},Ve={class:`flex items-center gap-2 mb-2`},He={class:`w-4 h-4 rounded-full bg-primary flex items-center justify-center text-primary-foreground`},Ue={class:`text-sm font-medium`},We={class:`text-xs text-muted-foreground mb-2`},Ge={class:`text-primary font-medium`},Ke={key:1,class:`text-xs text-warning bg-warning-light p-2 rounded`},qe={key:1,class:`p-3 border-b border-border`},Je={class:`flex items-center gap-2 mb-2`},Ye={class:`w-4 h-4 rounded-full bg-primary flex items-center justify-center text-primary-foreground`},Xe={class:`text-sm font-medium`},Ze={class:`text-xs text-muted-foreground mb-2`},Qe={class:`flex items-center gap-2 mb-2`},$e={class:`text-xs text-muted-foreground`},et={key:2,class:`p-3`},tt={class:`text-xs text-muted-foreground`},nt={class:`px-3 py-2 flex justify-between items-center text-xs text-muted-foreground`},rt={class:`flex-1 p-2 space-y-0.5 overflow-y-auto`},it={key:0,class:`my-1.5 border-t border-sidebar-border`},at={key:1,class:`flex items-center justify-between px-3 py-1.5`},ot={class:`text-[11px] font-medium text-sidebar-foreground/50 uppercase tracking-wider`},st=[`onClick`],ct={class:`p-3 border-t border-sidebar-border space-y-1`},lt={class:`bg-muted px-1 py-0.5 rounded text-xs`},ut=300*1e3,dt=u({__name:`Sidebar`,setup(l){let{isDark:u,toggleTheme:te}=ye(),{t:_}=r(),{locale:b,setLocale:ae,toggleTarget:oe}=be();async function D(){await ae(oe.value)}let O=x(null),k=x(!1),j=x(!1),M=x(!1),U=x(!1),W=x(!1),G=null;async function K(){try{O.value=await S.getUpgradeStatus()}catch{O.value=null}}async function Ee(){try{await S.triggerUpgradeCheck(),await K()}catch(t){H.error(e(t,_(`sidebar.upgrade.checkFailed`)))}}async function Ae(){if(O.value?.npm.latestVersion){M.value=!0;try{await S.executeUpgrade(O.value.npm.latestVersion),H.success(_(`sidebar.upgrade.upgradeSuccess`)),k.value=!1,j.value=!0,await K()}catch(t){H.error(e(t,_(`sidebar.upgrade.upgradeFailed`)))}finally{M.value=!1}}}async function Fe(){let t=O.value?.syncSource??`github`;U.value=!0;try{await S.syncConfig(t),H.success(_(`sidebar.upgrade.configSyncSuccess`)),await K()}catch(t){H.error(e(t,_(`sidebar.upgrade.syncFailed`)))}finally{U.value=!1}}async function dt(t){if(typeof t==`string`)try{await S.setSyncSource(t),await K()}catch(t){H.error(e(t,_(`sidebar.upgrade.saveFailed`)))}}let q=i(()=>{if(!O.value)return 0;let e=0;return O.value.npm.hasUpdate&&e++,O.value.config.hasUpdate&&e++,e});re(()=>{K(),G=setInterval(K,ut)}),ie(()=>{G&&clearInterval(G)});let J=i(()=>[{items:[{path:`/`,label:_(`sidebar.nav.dashboard`),icon:Oe}]},{label:_(`sidebar.nav.agentConfig`),expandable:!0,items:[{path:`/quick-setup`,label:_(`sidebar.nav.quickSetup`),icon:Ie},{path:`/providers`,label:_(`sidebar.nav.providers`),icon:Ne},{path:`/mappings`,label:_(`sidebar.nav.modelMappings`),icon:Se},{path:`/router-keys`,label:_(`sidebar.nav.routerKeys`),icon:De},{path:`/retry-rules`,label:_(`sidebar.nav.retryRules`),icon:je},{path:`/schedules`,label:_(`sidebar.nav.schedules`),icon:we}]},{label:_(`sidebar.nav.monitoring`),items:[{path:`/monitor`,label:_(`sidebar.nav.monitor`),icon:xe},{path:`/logs`,label:_(`sidebar.nav.logs`),icon:pe}]},{items:[{path:`/settings`,label:_(`sidebar.nav.settings`),icon:Pe}]}]),Y=x(new Set([1]));function X(e){return Y.value.has(e)}function Z(e){let t=new Set(Y.value);t.has(e)?t.delete(e):t.add(e),Y.value=t}let Q=ee(),ft=c();function $(e){return e===`/`?Q.path===`/`:Q.path.startsWith(e)}ne(()=>Q.path,()=>{J.value.forEach((e,t)=>{e.expandable&&e.items.some(e=>$(e.path))&&Y.value.add(t)})},{immediate:!0});async function pt(){try{await S.restartServer(),H.success(_(`sidebar.upgrade.restartSent`)),j.value=!1,setTimeout(()=>{window.location.reload()},5e3)}catch(t){H.error(e(t,_(`sidebar.upgrade.restartFailed`)))}}async function mt(){try{await S.logout()}finally{ft.push(`/login`)}}return(e,r)=>{let i=C(`router-link`);return E(),h(`aside`,Le,[s(`div`,Re,[s(`div`,ze,[r[9]||=s(`div`,{class:`w-8 h-8 bg-sidebar-primary rounded-lg flex items-center justify-center`},[s(`svg`,{class:`w-5 h-5 text-sidebar-primary-foreground`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[s(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z`})])],-1),g(d(_e),{open:W.value,"onUpdate:open":r[1]||=e=>W.value=e},{default:n(()=>[g(d(ve),{"as-child":``},{default:n(()=>[g(d(w),{variant:`ghost`,class:`flex items-center gap-2 px-0 h-auto`},{default:n(()=>[r[5]||=s(`span`,{class:`font-semibold text-sm`},`LLM Router`,-1),g(d(V),{variant:`secondary`,class:`text-[10px] px-1.5 py-0 h-4 leading-none`},{default:n(()=>[m(`v`+p(d(`0.9.5`)),1)]),_:1}),q.value>0?(E(),T(d(V),{key:0,variant:`destructive`,class:`text-[10px] px-1.5 h-4 leading-none bg-destructive text-destructive-foreground font-semibold`},{default:n(()=>[m(p(q.value),1)]),_:1})):o(``,!0)]),_:1})]),_:1}),g(d(ge),{side:`right`,align:`start`,class:`w-80 p-0`},{default:n(()=>[O.value?.npm.hasUpdate?(E(),h(`div`,Be,[s(`div`,Ve,[s(`div`,He,[g(d(Ce),{class:`w-3 h-3`})]),s(`span`,Ue,p(d(_)(`sidebar.upgrade.newVersion`)),1)]),s(`p`,We,[m(p(O.value.npm.currentVersion)+` → `,1),s(`span`,Ge,p(O.value.npm.latestVersion),1)]),O.value.deployment===`npm`?(E(),T(d(w),{key:0,size:`sm`,class:`w-full text-xs`,disabled:M.value,onClick:r[0]||=e=>k.value=!0},{default:n(()=>[m(p(M.value?d(_)(`sidebar.upgrade.upgrading`):d(_)(`sidebar.upgrade.oneClickUpgrade`)),1)]),_:1},8,[`disabled`])):(E(),h(`div`,Ke,[m(p(d(_)(`sidebar.upgrade.dockerDeploy`,{type:O.value.deployment===`docker`?`Docker`:`Unknown`}))+` `,1),r[6]||=s(`code`,{class:`block mt-1 text-warning bg-warning-dark/10 p-1 rounded`},`docker pull ghcr.io/zhushanwen321/llm-simple-router:latest`,-1)]))])):o(``,!0),O.value?.config.hasUpdate?(E(),h(`div`,qe,[s(`div`,Je,[s(`div`,Ye,[g(d(Me),{class:`w-3 h-3`})]),s(`span`,Xe,p(d(_)(`sidebar.upgrade.configUpdated`)),1)]),s(`p`,Ze,p(d(_)(`sidebar.upgrade.configUpdatedDesc`)),1),s(`div`,Qe,[s(`span`,$e,p(d(_)(`sidebar.upgrade.source`)),1),g(d(le),{"model-value":O.value?.syncSource,"onUpdate:modelValue":dt},{default:n(()=>[g(d(de),{class:`h-7 text-xs flex-1`},{default:n(()=>[g(d(fe))]),_:1}),g(d(ue),null,{default:n(()=>[g(d(A),{value:`github`},{default:n(()=>[...r[7]||=[m(`GitHub`,-1)]]),_:1}),g(d(A),{value:`gitee`},{default:n(()=>[...r[8]||=[m(`Gitee`,-1)]]),_:1})]),_:1})]),_:1},8,[`model-value`])]),g(d(w),{size:`sm`,variant:`secondary`,class:`w-full text-xs`,disabled:U.value,onClick:Fe},{default:n(()=>[m(p(U.value?d(_)(`sidebar.upgrade.syncing`):d(_)(`sidebar.upgrade.syncConfig`)),1)]),_:1},8,[`disabled`])])):o(``,!0),!O.value?.npm.hasUpdate&&!O.value?.config.hasUpdate?(E(),h(`div`,et,[s(`p`,tt,p(d(_)(`sidebar.upgrade.upToDate`)),1)])):o(``,!0),s(`div`,nt,[s(`span`,null,p(O.value?.lastCheckedAt?d(_)(`sidebar.upgrade.checkedAt`,{time:d(se)(O.value.lastCheckedAt).toLocaleTimeString(d(b)===`zh-CN`?`zh-CN`:`en`,{timeZone:`Asia/Shanghai`})}):d(_)(`sidebar.upgrade.notChecked`)),1),g(d(w),{variant:`link`,class:`text-primary h-auto p-0`,onClick:Ee},{default:n(()=>[m(p(d(_)(`sidebar.upgrade.checkNow`)),1)]),_:1})])]),_:1})]),_:1},8,[`open`])])]),s(`nav`,rt,[(E(!0),h(f,null,v(J.value,(e,r)=>(E(),h(f,{key:r},[r>0?(E(),h(`div`,it)):o(``,!0),e.label?(E(),h(`div`,at,[s(`span`,ot,p(e.label),1),e.expandable?(E(),h(`button`,{key:0,type:`button`,class:`flex items-center justify-center w-5 h-5 rounded hover:bg-sidebar-accent text-sidebar-foreground/50 hover:text-sidebar-foreground transition-colors cursor-pointer select-none`,onClick:e=>Z(r)},[g(d(ce),{class:t([`w-3.5 h-3.5 transition-transform duration-200`,X(r)?`rotate-0`:`-rotate-90`])},null,8,[`class`])],8,st)):o(``,!0)])):o(``,!0),e.expandable?(E(),h(`div`,{key:2,class:`overflow-hidden transition-all duration-200 ease-in-out`,style:a({maxHeight:X(r)?e.items.length*44+`px`:`0px`,opacity:+!!X(r)})},[(E(!0),h(f,null,v(e.items,e=>(E(),T(i,{key:e.path,to:e.path,class:t([`flex items-center gap-3 px-3 py-2 ml-1 rounded-lg text-sm transition-colors`,$(e.path)?`bg-sidebar-accent text-sidebar-primary`:`text-sidebar-foreground hover:bg-sidebar-accent`])},{default:n(()=>[(E(),T(y(e.icon),{class:`w-4 h-4`})),m(` `+p(e.label),1)]),_:2},1032,[`to`,`class`]))),128))],4)):o(``,!0),e.expandable?o(``,!0):(E(!0),h(f,{key:3},v(e.items,e=>(E(),T(i,{key:e.path,to:e.path,class:t([`flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors`,$(e.path)?`bg-sidebar-accent text-sidebar-primary`:`text-sidebar-foreground hover:bg-sidebar-accent`])},{default:n(()=>[(E(),T(y(e.icon),{class:`w-4 h-4`})),m(` `+p(e.label),1)]),_:2},1032,[`to`,`class`]))),128))],64))),128))]),s(`div`,ct,[g(d(w),{variant:`ghost`,class:`w-full justify-start text-sidebar-foreground hover:text-sidebar-foreground hover:bg-sidebar-accent`,onClick:d(te)},{default:n(()=>[d(u)?(E(),T(d(he),{key:1,class:`w-4 h-4`})):(E(),T(d(me),{key:0,class:`w-4 h-4`})),m(` `+p(d(u)?d(_)(`sidebar.theme.light`):d(_)(`sidebar.theme.dark`)),1)]),_:1},8,[`onClick`]),g(d(w),{variant:`ghost`,class:`w-full justify-start text-sidebar-foreground hover:text-sidebar-foreground hover:bg-sidebar-accent`,onClick:D},{default:n(()=>[g(d(Te),{class:`w-4 h-4`}),m(` `+p(d(b)===`zh-CN`?d(_)(`sidebar.language.switchToEn`):d(_)(`sidebar.language.switchToZh`)),1)]),_:1}),g(d(w),{variant:`ghost`,class:`w-full justify-start text-sidebar-foreground hover:text-sidebar-foreground hover:bg-sidebar-accent`,onClick:mt},{default:n(()=>[g(d(ke),{class:`w-4 h-4`}),m(` `+p(d(_)(`sidebar.logout`)),1)]),_:1})]),g(d(P),{open:k.value,"onUpdate:open":r[2]||=e=>k.value=e},{default:n(()=>[g(d(N),null,{default:n(()=>[g(d(I),null,{default:n(()=>[g(d(B),null,{default:n(()=>[m(p(d(_)(`sidebar.upgrade.confirmUpgrade`,{version:O.value?.npm.latestVersion})),1)]),_:1}),g(d(F),null,{default:n(()=>[m(p(d(_)(`sidebar.upgrade.upgradeDescBefore`))+` `,1),s(`code`,lt,`npm install -g llm-simple-router@`+p(O.value?.npm.latestVersion),1),m(p(d(_)(`sidebar.upgrade.upgradeDescAfter`)),1)]),_:1})]),_:1}),g(d(R),null,{default:n(()=>[g(d(L),null,{default:n(()=>[m(p(d(_)(`common.cancel`)),1)]),_:1}),g(d(z),{onClick:Ae,disabled:M.value},{default:n(()=>[m(p(M.value?d(_)(`sidebar.upgrade.upgrading`):d(_)(`common.confirm`)),1)]),_:1},8,[`disabled`])]),_:1})]),_:1})]),_:1},8,[`open`]),g(d(P),{open:j.value,"onUpdate:open":r[4]||=e=>j.value=e},{default:n(()=>[g(d(N),null,{default:n(()=>[g(d(I),null,{default:n(()=>[g(d(B),null,{default:n(()=>[m(p(d(_)(`sidebar.upgrade.upgradeSuccess`)),1)]),_:1}),g(d(F),null,{default:n(()=>[m(p(d(_)(`sidebar.upgrade.restartNeeded`,{version:O.value?.npm.latestVersion})),1)]),_:1})]),_:1}),g(d(R),null,{default:n(()=>[g(d(L),{onClick:r[3]||=e=>j.value=!1},{default:n(()=>[m(p(d(_)(`sidebar.upgrade.laterRestart`)),1)]),_:1}),g(d(z),{onClick:pt},{default:n(()=>[m(p(d(_)(`sidebar.upgrade.restartNow`)),1)]),_:1})]),_:1})]),_:1})]),_:1},8,[`open`])])}}}),q=u({__name:`Sonner`,props:{id:{},invert:{type:Boolean},theme:{},position:{},closeButtonPosition:{},hotkey:{},richColors:{type:Boolean},expand:{type:Boolean},duration:{},gap:{},visibleToasts:{},closeButton:{type:Boolean},toastOptions:{},class:{},style:{},offset:{},mobileOffset:{},dir:{},swipeDirections:{},icons:{},containerAriaLabel:{}},setup(e){let t=e;return(e,r)=>(E(),T(d(U),_({class:d(ae)(`toaster group`,t.class),style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius)`}},t),{"success-icon":n(()=>[g(d(K),{class:`size-4`})]),"info-icon":n(()=>[g(d(Ee),{class:`size-4`})]),"warning-icon":n(()=>[g(d(Fe),{class:`size-4`})]),"error-icon":n(()=>[g(d(Ae),{class:`size-4`})]),"loading-icon":n(()=>[s(`div`,null,[g(d(j),{class:`size-4 animate-spin`})])]),"close-icon":n(()=>[g(d(M),{class:`size-4`})]),_:1},16,[`class`]))}}),J={key:0,class:`h-screen flex overflow-hidden`},Y={class:`flex-1 overflow-auto bg-muted`},X=u({__name:`App`,setup(e){let t=c(),n=ee(),r=x(!1),a=i(()=>W.value?`dark`:`light`),o=[`/login`,`/setup`];async function l(){if(o.includes(n.path)){r.value=!1;return}try{await S.getStats(),r.value=!0}catch{r.value=!1,t.push(`/login`)}}return l(),ne(()=>n.path,l),(e,t)=>{let n=C(`router-view`);return E(),h(f,null,[r.value?(E(),h(`div`,J,[g(dt),s(`main`,Y,[g(n)])])):(E(),T(n,{key:1})),(E(),T(te,{to:`body`},[g(d(q),{theme:a.value,richColors:``,position:`top-center`,toastOptions:{duration:4e3}},null,8,[`theme`])]))],64)}}});G();var Z=oe(X);Z.use(b),Z.use(D);var Q=D.global.locale.value;document.documentElement.setAttribute(`lang`,Q),O(Q).then(()=>{Z.mount(`#app`)});
|
package/frontend-dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/admin/favicon.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>LLM Simple Router</title>
|
|
8
|
-
<script type="module" crossorigin src="/admin/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/admin/assets/index-C8DKlnvd.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/admin/assets/button-D27ClX8J.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/admin/assets/Teleport-Bmeh33lB.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/admin/assets/PopperContent-6BXua_FZ.js">
|
package/package.json
CHANGED