@maplezzk/llm-proxy 0.1.0
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/README.md +85 -0
- package/bin/llm-proxy.js +17 -0
- package/dist/adapter/handlers.d.ts +5 -0
- package/dist/adapter/handlers.d.ts.map +1 -0
- package/dist/adapter/handlers.js +61 -0
- package/dist/adapter/handlers.js.map +1 -0
- package/dist/adapter/router.d.ts +12 -0
- package/dist/adapter/router.d.ts.map +1 -0
- package/dist/adapter/router.js +40 -0
- package/dist/adapter/router.js.map +1 -0
- package/dist/api/admin/app.d.ts +2 -0
- package/dist/api/admin/app.d.ts.map +1 -0
- package/dist/api/admin/app.js +35 -0
- package/dist/api/admin/app.js.map +1 -0
- package/dist/api/admin/components/adapters.d.ts +33 -0
- package/dist/api/admin/components/adapters.d.ts.map +1 -0
- package/dist/api/admin/components/adapters.js +144 -0
- package/dist/api/admin/components/adapters.js.map +1 -0
- package/dist/api/admin/components/capture.d.ts +23 -0
- package/dist/api/admin/components/capture.d.ts.map +1 -0
- package/dist/api/admin/components/capture.js +198 -0
- package/dist/api/admin/components/capture.js.map +1 -0
- package/dist/api/admin/components/dashboard.d.ts +14 -0
- package/dist/api/admin/components/dashboard.d.ts.map +1 -0
- package/dist/api/admin/components/dashboard.js +48 -0
- package/dist/api/admin/components/dashboard.js.map +1 -0
- package/dist/api/admin/components/logs.d.ts +24 -0
- package/dist/api/admin/components/logs.d.ts.map +1 -0
- package/dist/api/admin/components/logs.js +89 -0
- package/dist/api/admin/components/logs.js.map +1 -0
- package/dist/api/admin/components/providers.d.ts +33 -0
- package/dist/api/admin/components/providers.d.ts.map +1 -0
- package/dist/api/admin/components/providers.js +165 -0
- package/dist/api/admin/components/providers.js.map +1 -0
- package/dist/api/admin/components/proxy-key.d.ts +10 -0
- package/dist/api/admin/components/proxy-key.d.ts.map +1 -0
- package/dist/api/admin/components/proxy-key.js +34 -0
- package/dist/api/admin/components/proxy-key.js.map +1 -0
- package/dist/api/admin/components/test-panel.d.ts +14 -0
- package/dist/api/admin/components/test-panel.d.ts.map +1 -0
- package/dist/api/admin/components/test-panel.js +58 -0
- package/dist/api/admin/components/test-panel.js.map +1 -0
- package/dist/api/admin/store.d.ts +2 -0
- package/dist/api/admin/store.d.ts.map +1 -0
- package/dist/api/admin/store.js +86 -0
- package/dist/api/admin/store.js.map +1 -0
- package/dist/api/admin/types.d.ts +41 -0
- package/dist/api/admin/types.d.ts.map +1 -0
- package/dist/api/admin/types.js +2 -0
- package/dist/api/admin/types.js.map +1 -0
- package/dist/api/admin-app.js +5 -0
- package/dist/api/admin-ui.html +799 -0
- package/dist/api/handlers/adapter-crud.d.ts +7 -0
- package/dist/api/handlers/adapter-crud.d.ts.map +1 -0
- package/dist/api/handlers/adapter-crud.js +118 -0
- package/dist/api/handlers/adapter-crud.js.map +1 -0
- package/dist/api/handlers/base.d.ts +15 -0
- package/dist/api/handlers/base.d.ts.map +1 -0
- package/dist/api/handlers/base.js +103 -0
- package/dist/api/handlers/base.js.map +1 -0
- package/dist/api/handlers/index.d.ts +7 -0
- package/dist/api/handlers/index.d.ts.map +1 -0
- package/dist/api/handlers/index.js +9 -0
- package/dist/api/handlers/index.js.map +1 -0
- package/dist/api/handlers/model-handlers.d.ts +7 -0
- package/dist/api/handlers/model-handlers.d.ts.map +1 -0
- package/dist/api/handlers/model-handlers.js +239 -0
- package/dist/api/handlers/model-handlers.js.map +1 -0
- package/dist/api/handlers/provider-crud.d.ts +6 -0
- package/dist/api/handlers/provider-crud.d.ts.map +1 -0
- package/dist/api/handlers/provider-crud.js +106 -0
- package/dist/api/handlers/provider-crud.js.map +1 -0
- package/dist/api/handlers.d.ts +16 -0
- package/dist/api/handlers.d.ts.map +1 -0
- package/dist/api/handlers.js +45 -0
- package/dist/api/handlers.js.map +1 -0
- package/dist/api/server.d.ts +26 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +114 -0
- package/dist/api/server.js.map +1 -0
- package/dist/cli/commands.d.ts +15 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +165 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/config/parser.d.ts +4 -0
- package/dist/config/parser.d.ts.map +1 -0
- package/dist/config/parser.js +75 -0
- package/dist/config/parser.js.map +1 -0
- package/dist/config/store.d.ts +16 -0
- package/dist/config/store.d.ts.map +1 -0
- package/dist/config/store.js +59 -0
- package/dist/config/store.js.map +1 -0
- package/dist/config/types.d.ts +72 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/validator.d.ts +3 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +109 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/http-utils.d.ts +4 -0
- package/dist/lib/http-utils.d.ts.map +1 -0
- package/dist/lib/http-utils.js +21 -0
- package/dist/lib/http-utils.js.map +1 -0
- package/dist/log/logger.d.ts +31 -0
- package/dist/log/logger.d.ts.map +1 -0
- package/dist/log/logger.js +170 -0
- package/dist/log/logger.js.map +1 -0
- package/dist/proxy/capture.d.ts +28 -0
- package/dist/proxy/capture.d.ts.map +1 -0
- package/dist/proxy/capture.js +49 -0
- package/dist/proxy/capture.js.map +1 -0
- package/dist/proxy/handlers.d.ts +6 -0
- package/dist/proxy/handlers.d.ts.map +1 -0
- package/dist/proxy/handlers.js +30 -0
- package/dist/proxy/handlers.js.map +1 -0
- package/dist/proxy/pipeline.d.ts +32 -0
- package/dist/proxy/pipeline.d.ts.map +1 -0
- package/dist/proxy/pipeline.js +120 -0
- package/dist/proxy/pipeline.js.map +1 -0
- package/dist/proxy/provider.d.ts +21 -0
- package/dist/proxy/provider.d.ts.map +1 -0
- package/dist/proxy/provider.js +231 -0
- package/dist/proxy/provider.js.map +1 -0
- package/dist/proxy/router.d.ts +4 -0
- package/dist/proxy/router.d.ts.map +1 -0
- package/dist/proxy/router.js +20 -0
- package/dist/proxy/router.js.map +1 -0
- package/dist/proxy/stream-converter.d.ts +16 -0
- package/dist/proxy/stream-converter.d.ts.map +1 -0
- package/dist/proxy/stream-converter.js +1050 -0
- package/dist/proxy/stream-converter.js.map +1 -0
- package/dist/proxy/translation.d.ts +23 -0
- package/dist/proxy/translation.d.ts.map +1 -0
- package/dist/proxy/translation.js +913 -0
- package/dist/proxy/translation.js.map +1 -0
- package/dist/proxy/types.d.ts +8 -0
- package/dist/proxy/types.d.ts.map +1 -0
- package/dist/proxy/types.js +2 -0
- package/dist/proxy/types.js.map +1 -0
- package/dist/status/token-tracker.d.ts +24 -0
- package/dist/status/token-tracker.d.ts.map +1 -0
- package/dist/status/token-tracker.js +65 -0
- package/dist/status/token-tracker.js.map +1 -0
- package/dist/status/tracker.d.ts +14 -0
- package/dist/status/tracker.d.ts.map +1 -0
- package/dist/status/tracker.js +44 -0
- package/dist/status/tracker.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>llm-proxy</title>
|
|
7
|
+
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M12 20 L12 12 C12 9 7 6 4 4'/><path d='M12 12 C12 9 17 6 20 4'/><polyline points='2,5 4,4 5,7'/><polyline points='18,2 20,4 18,6'/></svg>">
|
|
8
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsoneditor@10/dist/jsoneditor.min.css">
|
|
9
|
+
<style>
|
|
10
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
11
|
+
:root {
|
|
12
|
+
--sidebar: 220px;
|
|
13
|
+
--bg: #f0f1f3;
|
|
14
|
+
--surface: #fff;
|
|
15
|
+
--border: #e2e4e9;
|
|
16
|
+
--sidebar-bg: #15171b;
|
|
17
|
+
--sidebar-text: #9ca0b0;
|
|
18
|
+
--sidebar-active: #fff;
|
|
19
|
+
--sidebar-hover: #1e2027;
|
|
20
|
+
--text: #14151a;
|
|
21
|
+
--text-muted: #6b7084;
|
|
22
|
+
--accent: #3080f0;
|
|
23
|
+
--accent-bg: #eaf1fe;
|
|
24
|
+
--success: #1a8c4a;
|
|
25
|
+
--success-bg: #e6f7ed;
|
|
26
|
+
--danger: #d43b3b;
|
|
27
|
+
--danger-bg: #fce8e8;
|
|
28
|
+
--warn: #cc7a00;
|
|
29
|
+
--warn-bg: #fff3e0;
|
|
30
|
+
--debug: #6b7084;
|
|
31
|
+
--debug-bg: #f0f1f3;
|
|
32
|
+
--radius: 6px;
|
|
33
|
+
--font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
|
|
34
|
+
--mono: "SF Mono", "Fira Code", "Cascadia Code", "Menlo", monospace;
|
|
35
|
+
}
|
|
36
|
+
html, body { height: 100%; }
|
|
37
|
+
body { font-family: var(--font); background: var(--bg); color: var(--text); display: flex; line-height: 1.5; }
|
|
38
|
+
|
|
39
|
+
/* Toast */
|
|
40
|
+
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
|
|
41
|
+
.toast {
|
|
42
|
+
padding: 10px 16px; border-radius: var(--radius); font-size: 12.5px;
|
|
43
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.12); animation: toastIn 0.2s ease;
|
|
44
|
+
display: flex; align-items: center; gap: 8px; max-width: 360px;
|
|
45
|
+
}
|
|
46
|
+
.toast-success { background: var(--success-bg); color: var(--success); border-left: 3px solid var(--success); }
|
|
47
|
+
.toast-error { background: var(--danger-bg); color: var(--danger); border-left: 3px solid var(--danger); }
|
|
48
|
+
.toast-info { background: var(--accent-bg); color: var(--accent); border-left: 3px solid var(--accent); }
|
|
49
|
+
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
|
|
50
|
+
|
|
51
|
+
/* Custom Confirm */
|
|
52
|
+
.confirm-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.4); z-index:150; align-items:center; justify-content:center; }
|
|
53
|
+
.confirm-overlay.open { display:flex; }
|
|
54
|
+
.confirm-box { background:var(--surface); border-radius:var(--radius); padding:24px; min-width:320px; max-width:420px; box-shadow:0 8px 32px rgba(0,0,0,0.2); }
|
|
55
|
+
.confirm-box p { font-size:13.5px; margin-bottom:18px; line-height:1.6; }
|
|
56
|
+
.confirm-box .btn-row { display:flex; gap:8px; justify-content:flex-end; }
|
|
57
|
+
|
|
58
|
+
/* Sidebar */
|
|
59
|
+
.sidebar {
|
|
60
|
+
width: var(--sidebar); min-width: var(--sidebar);
|
|
61
|
+
background: var(--sidebar-bg); color: var(--sidebar-text);
|
|
62
|
+
display: flex; flex-direction: column;
|
|
63
|
+
height: 100vh; position: sticky; top: 0;
|
|
64
|
+
user-select: none;
|
|
65
|
+
}
|
|
66
|
+
.sidebar-header {
|
|
67
|
+
padding: 20px 20px 0;
|
|
68
|
+
margin-bottom: 24px;
|
|
69
|
+
}
|
|
70
|
+
.sidebar-header h1 {
|
|
71
|
+
font-size: 15px; font-weight: 600; color: var(--sidebar-active);
|
|
72
|
+
letter-spacing: -0.01em;
|
|
73
|
+
}
|
|
74
|
+
.sidebar-header .sub {
|
|
75
|
+
font-size: 11px; color: var(--sidebar-text); margin-top: 2px;
|
|
76
|
+
}
|
|
77
|
+
.sidebar-nav { flex: 1; padding: 0 8px; }
|
|
78
|
+
.sidebar-nav a {
|
|
79
|
+
display: flex; align-items: center; gap: 10px;
|
|
80
|
+
padding: 9px 12px; margin-bottom: 2px;
|
|
81
|
+
font-size: 13px; color: var(--sidebar-text); text-decoration: none;
|
|
82
|
+
border-radius: var(--radius); cursor: pointer;
|
|
83
|
+
transition: background 0.12s, color 0.12s;
|
|
84
|
+
}
|
|
85
|
+
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #c8cbd6; }
|
|
86
|
+
.sidebar-nav a.active { background: var(--sidebar-hover); color: var(--sidebar-active); font-weight: 500; }
|
|
87
|
+
.sidebar-nav a .icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; opacity: 0.7; flex-shrink: 0; }
|
|
88
|
+
.sidebar-nav a.active .icon { opacity: 1; }
|
|
89
|
+
.sidebar-footer {
|
|
90
|
+
padding: 12px 20px; font-size: 11px; color: var(--sidebar-text);
|
|
91
|
+
border-top: 1px solid rgba(255,255,255,0.06);
|
|
92
|
+
display: flex; align-items: center; gap: 8px;
|
|
93
|
+
}
|
|
94
|
+
.sidebar-footer .dot {
|
|
95
|
+
width: 7px; height: 7px; border-radius: 50%;
|
|
96
|
+
background: #555;
|
|
97
|
+
}
|
|
98
|
+
.sidebar-footer .dot.running { background: #34d058; box-shadow: 0 0 4px rgba(52,208,88,0.4); }
|
|
99
|
+
|
|
100
|
+
/* Main Content */
|
|
101
|
+
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
|
102
|
+
.topbar {
|
|
103
|
+
height: 48px; display: flex; align-items: center;
|
|
104
|
+
padding: 0 32px; gap: 12px; flex-shrink: 0;
|
|
105
|
+
border-bottom: 1px solid var(--border); background: var(--surface);
|
|
106
|
+
}
|
|
107
|
+
.topbar h2 { font-size: 14px; font-weight: 600; color: var(--text); }
|
|
108
|
+
.topbar .count {
|
|
109
|
+
font-size: 12px; padding: 1px 8px; border-radius: 10px;
|
|
110
|
+
background: var(--border); color: var(--text-muted);
|
|
111
|
+
}
|
|
112
|
+
.content { flex: 1; padding: 24px 32px; overflow-y: auto; }
|
|
113
|
+
.page { display: none; }
|
|
114
|
+
.page.active { display: block; animation: fadeIn 0.15s ease; }
|
|
115
|
+
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
|
|
116
|
+
|
|
117
|
+
/* Stats Grid */
|
|
118
|
+
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 32px; }
|
|
119
|
+
.stat {
|
|
120
|
+
background: var(--surface); border-radius: var(--radius); padding: 18px 20px;
|
|
121
|
+
border: 1px solid var(--border);
|
|
122
|
+
transition: box-shadow 0.15s;
|
|
123
|
+
}
|
|
124
|
+
.stat:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
|
|
125
|
+
.stat .label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; }
|
|
126
|
+
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
|
|
127
|
+
|
|
128
|
+
/* Section */
|
|
129
|
+
.section { margin-bottom: 28px; }
|
|
130
|
+
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
|
|
131
|
+
.section-header h3 { font-size: 13px; font-weight: 600; color: var(--text-muted); }
|
|
132
|
+
.section-header .search-box { display: flex; align-items: center; gap: 6px; }
|
|
133
|
+
.section-header .search-box input {
|
|
134
|
+
padding: 5px 10px; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius);
|
|
135
|
+
width: 200px; outline: none; background: var(--surface);
|
|
136
|
+
}
|
|
137
|
+
.section-header .search-box input:focus { border-color: var(--accent); }
|
|
138
|
+
|
|
139
|
+
.btn {
|
|
140
|
+
display: inline-flex; align-items: center; gap: 5px;
|
|
141
|
+
padding: 6px 14px; font-size: 12.5px; font-weight: 500;
|
|
142
|
+
border: none; border-radius: var(--radius); cursor: pointer;
|
|
143
|
+
transition: background 0.12s;
|
|
144
|
+
}
|
|
145
|
+
.btn-primary { background: var(--accent); color: #fff; }
|
|
146
|
+
.btn-primary:hover { background: #2770d8; }
|
|
147
|
+
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
|
|
148
|
+
.btn-ghost { background: transparent; color: var(--text-muted); }
|
|
149
|
+
.btn-ghost:hover { background: var(--border); color: var(--text); }
|
|
150
|
+
.btn-danger { background: var(--danger-bg); color: var(--danger); border:1px solid transparent; }
|
|
151
|
+
.btn-danger:hover { background: var(--danger); color: #fff; }
|
|
152
|
+
.btn-success { background: var(--success-bg); color: var(--success); border:1px solid transparent; }
|
|
153
|
+
.btn-success:hover { background: var(--success); color: #fff; }
|
|
154
|
+
.btn-warning { background: var(--warn-bg); color: var(--warn); border:1px solid transparent; }
|
|
155
|
+
.btn-warning:hover { background: var(--warn); color: #fff; }
|
|
156
|
+
.btn-sm { padding: 4px 10px; font-size: 11.5px; }
|
|
157
|
+
.btn-icon { padding: 4px 6px; font-size: 13px; }
|
|
158
|
+
|
|
159
|
+
/* Alerts */
|
|
160
|
+
.alert {
|
|
161
|
+
padding: 10px 14px; border-radius: var(--radius); font-size: 12.5px;
|
|
162
|
+
margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
|
|
163
|
+
}
|
|
164
|
+
.alert-success { background: var(--success-bg); color: var(--success); }
|
|
165
|
+
.alert-error { background: var(--danger-bg); color: var(--danger); }
|
|
166
|
+
.alert-warn { background: var(--warn-bg); color: var(--warn); }
|
|
167
|
+
|
|
168
|
+
/* Table */
|
|
169
|
+
.table-wrap {
|
|
170
|
+
background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
|
|
171
|
+
overflow: hidden;
|
|
172
|
+
}
|
|
173
|
+
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
174
|
+
thead th {
|
|
175
|
+
padding: 10px 16px; text-align: left;
|
|
176
|
+
font-weight: 600; font-size: 11px; color: var(--text-muted);
|
|
177
|
+
text-transform: uppercase; letter-spacing: 0.03em;
|
|
178
|
+
border-bottom: 1px solid var(--border); background: #f8f9fb;
|
|
179
|
+
}
|
|
180
|
+
tbody td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
|
|
181
|
+
tbody tr:last-child td { border-bottom: none; }
|
|
182
|
+
tbody tr:hover td { background: #f8f9fb; }
|
|
183
|
+
|
|
184
|
+
/* Badge */
|
|
185
|
+
.badge {
|
|
186
|
+
display: inline-block; padding: 1px 8px; border-radius: 10px;
|
|
187
|
+
font-size: 11px; font-weight: 500;
|
|
188
|
+
}
|
|
189
|
+
.badge-ok { background: var(--success-bg); color: var(--success); }
|
|
190
|
+
.badge-err { background: var(--danger-bg); color: var(--danger); }
|
|
191
|
+
.badge-warn { background: var(--warn-bg); color: var(--warn); }
|
|
192
|
+
.badge-muted { background: var(--border); color: var(--text-muted); }
|
|
193
|
+
|
|
194
|
+
/* Empty */
|
|
195
|
+
.empty { text-align: center; padding: 48px 24px; color: var(--text-muted); font-size: 13px; }
|
|
196
|
+
.empty .empty-action { margin-top: 12px; }
|
|
197
|
+
|
|
198
|
+
/* Values */
|
|
199
|
+
.mono { font-family: var(--mono); font-size: 12px; }
|
|
200
|
+
|
|
201
|
+
/* Skeleton */
|
|
202
|
+
.skeleton { background: linear-gradient(90deg, #f0f1f3 25%, #e2e4e9 50%, #f0f1f3 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
|
|
203
|
+
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
|
|
204
|
+
.skeleton-row { height: 41px; margin-bottom: 1px; }
|
|
205
|
+
|
|
206
|
+
/* Modal */
|
|
207
|
+
.modal-overlay { display:flex; position:fixed; inset:0; background:rgba(0,0,0,0.4); z-index:100; align-items:center; justify-content:center; }
|
|
208
|
+
.modal-overlay.open { display:flex; }
|
|
209
|
+
.modal { background:var(--surface); border-radius:var(--radius); padding:24px; min-width:420px; max-width:580px; width:90vw; box-shadow:0 8px 32px rgba(0,0,0,0.2); }
|
|
210
|
+
.modal h3 { font-size:14px; font-weight:600; margin-bottom:16px; }
|
|
211
|
+
.modal label { display:block; font-size:12px; font-weight:500; color:var(--text-muted); margin:10px 0 4px; }
|
|
212
|
+
.modal input, .modal select { width:100%; padding:7px 10px; font-size:13px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); color:var(--text); }
|
|
213
|
+
.modal input:focus, .modal select:focus { outline:none; border-color:var(--accent); }
|
|
214
|
+
.modal .hint { font-size:11px; color:var(--text-muted); margin-top:3px; }
|
|
215
|
+
.modal .btn-row { display:flex; gap:8px; justify-content:flex-end; margin-top:16px; }
|
|
216
|
+
|
|
217
|
+
/* Dynamic model/mapping rows */
|
|
218
|
+
.dynamic-rows { display:flex; flex-direction:column; gap:4px; margin-top:4px; }
|
|
219
|
+
.dynamic-row { display:flex; gap:6px; align-items:center; }
|
|
220
|
+
.dynamic-row input, .dynamic-row select { flex:1; min-width:0; padding:6px 8px; font-size:12px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); }
|
|
221
|
+
.pm-label { font-size:11px; color:var(--text-muted); white-space:nowrap; }
|
|
222
|
+
|
|
223
|
+
/* Log filter */
|
|
224
|
+
.log-filters { display:flex; gap:6px; margin-bottom:12px; }
|
|
225
|
+
.filter-btn { padding:4px 12px; font-size:11.5px; border:1px solid var(--border); border-radius:12px; background:var(--surface); cursor:pointer; color:var(--text-muted); transition:all 0.12s; }
|
|
226
|
+
.filter-btn.active { background:var(--accent); color:#fff; border-color:var(--accent); }
|
|
227
|
+
.filter-btn:disabled { opacity:0.4; cursor:default; }
|
|
228
|
+
|
|
229
|
+
/* jsoneditor overrides for capture page */
|
|
230
|
+
.jsoneditor-container .jsoneditor { border:none !important; }
|
|
231
|
+
.jsoneditor-container .jsoneditor-menu { background:var(--surface) !important; border-bottom:1px solid var(--border) !important; }
|
|
232
|
+
.jsoneditor-container .jsoneditor-tree { background:var(--surface) !important; }
|
|
233
|
+
|
|
234
|
+
.log-table { width:100%; border-collapse:collapse; font-size:12px; }
|
|
235
|
+
.log-table th { position:sticky; top:0; background:var(--surface); padding:8px 12px; font-size:11px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:0.04em; border-bottom:2px solid var(--border); text-align:left; z-index:1; }
|
|
236
|
+
.log-table td { padding:8px 12px; border-bottom:1px solid var(--border); vertical-align:top; }
|
|
237
|
+
.log-table tr:hover td { background:var(--bg); }
|
|
238
|
+
.log-table .log-icon { width:24px; height:24px; border-radius:5px; display:inline-flex; align-items:center; justify-content:center; flex-shrink:0; }
|
|
239
|
+
.log-table .log-icon.req { background:var(--accent-bg); color:var(--accent); }
|
|
240
|
+
.log-table .log-icon.sys { background:var(--warn-bg); color:var(--warn); }
|
|
241
|
+
.log-table .log-icon svg { width:12px; height:12px; }
|
|
242
|
+
.log-table .log-level { display:inline-block; font-size:10px; font-weight:600; text-transform:uppercase; padding:1px 5px; border-radius:3px; letter-spacing:0.03em; }
|
|
243
|
+
.log-table .log-level.debug { background:var(--debug-bg); color:var(--debug); }
|
|
244
|
+
.log-table .log-level.info { background:var(--accent-bg); color:var(--accent); }
|
|
245
|
+
.log-table .log-level.warn { background:var(--warn-bg); color:var(--warn); }
|
|
246
|
+
.log-table .log-level.error { background:var(--danger-bg); color:var(--danger); }
|
|
247
|
+
.log-table .log-detail-toggle { font-size:10.5px; color:var(--accent); cursor:pointer; user-select:none; }
|
|
248
|
+
.log-table .log-detail-toggle:hover { text-decoration:underline; }
|
|
249
|
+
.log-table .log-detail { font-family:var(--mono); font-size:10px; color:var(--text-muted); margin-top:4px; padding:6px 8px; background:var(--bg); border-radius:4px; max-height:160px; overflow-y:auto; white-space:pre-wrap; word-break:break-all; display:block; }
|
|
250
|
+
.log-table .log-detail.collapsed { display:none; }
|
|
251
|
+
|
|
252
|
+
/* Adapter tags */
|
|
253
|
+
.adapter-tag { display:inline-block; padding:2px 8px; border-radius:10px; font-size:10.5px; background:var(--accent-bg); color:var(--accent); margin:1px 2px; }
|
|
254
|
+
.adapter-tag-err { background:var(--danger-bg); color:var(--danger); }
|
|
255
|
+
.adapter-tags { display:flex; flex-wrap:wrap; gap:2px; }
|
|
256
|
+
|
|
257
|
+
@media (max-width: 720px) {
|
|
258
|
+
.sidebar { width: 48px; min-width: 48px; }
|
|
259
|
+
.sidebar-header h1, .sidebar-header .sub, .sidebar-nav a span, .sidebar-footer span { display: none; }
|
|
260
|
+
.sidebar-nav a { justify-content: center; padding: 9px; }
|
|
261
|
+
.sidebar-nav a .icon { margin: 0; }
|
|
262
|
+
.sidebar-footer { justify-content: center; }
|
|
263
|
+
.stats { grid-template-columns: repeat(2, 1fr); }
|
|
264
|
+
.content { padding: 16px; }
|
|
265
|
+
.topbar { padding: 0 16px; }
|
|
266
|
+
.section-header .search-box input { width: 140px; }
|
|
267
|
+
.modal { min-width: auto; width: 95vw; }
|
|
268
|
+
}
|
|
269
|
+
[x-cloak] { display: none !important; }
|
|
270
|
+
</style>
|
|
271
|
+
<script src="https://cdn.jsdelivr.net/npm/jsoneditor@10/dist/jsoneditor.min.js"></script>
|
|
272
|
+
<script defer src="/admin-app.js"></script>
|
|
273
|
+
</head>
|
|
274
|
+
<body>
|
|
275
|
+
|
|
276
|
+
<div class="sidebar">
|
|
277
|
+
<div class="sidebar-header">
|
|
278
|
+
<h1>llm-proxy</h1>
|
|
279
|
+
<div class="sub">Model Gateway</div>
|
|
280
|
+
</div>
|
|
281
|
+
<div class="sidebar-nav" x-data>
|
|
282
|
+
<template x-for="tab in ['dashboard','providers','adapters','logs','capture']" :key="tab">
|
|
283
|
+
<a :class="{ active: $store.app.currentTab === tab }"
|
|
284
|
+
href="#"
|
|
285
|
+
@click.prevent="$store.app.switchTab(tab)">
|
|
286
|
+
<span class="icon" x-html="$store.app.tabIcons[tab]"></span>
|
|
287
|
+
<span x-text="$store.app.tabNames[tab]"></span>
|
|
288
|
+
</a>
|
|
289
|
+
</template>
|
|
290
|
+
</div>
|
|
291
|
+
<div class="sidebar-footer" x-data>
|
|
292
|
+
<span class="dot" :class="{ running: $store.app.status === 'running' }"></span>
|
|
293
|
+
<span x-text="$store.app.status === 'running' ? '运行中' : $store.app.status === 'offline' ? '未连接' : '加载中'"></span>
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
|
|
297
|
+
<div class="main">
|
|
298
|
+
<div class="topbar" x-data>
|
|
299
|
+
<h2 x-text="$store.app.tabNames[$store.app.currentTab] || '仪表盘'"></h2>
|
|
300
|
+
</div>
|
|
301
|
+
<div class="content">
|
|
302
|
+
|
|
303
|
+
<!-- Dashboard -->
|
|
304
|
+
<div class="page" id="page-dashboard"
|
|
305
|
+
x-data="dashboardPage"
|
|
306
|
+
:class="{ active: $store.app.currentTab === 'dashboard' }">
|
|
307
|
+
<div class="stats">
|
|
308
|
+
<template x-for="stat in stats" :key="stat.label">
|
|
309
|
+
<div class="stat">
|
|
310
|
+
<div class="label" x-text="stat.label"></div>
|
|
311
|
+
<div class="value" :style="{ color: stat.clr }" x-text="stat.value"></div>
|
|
312
|
+
</div>
|
|
313
|
+
</template>
|
|
314
|
+
</div>
|
|
315
|
+
<div class="stats" style="margin-top:12px" x-show="tokenCards.length">
|
|
316
|
+
<template x-for="card in tokenCards" :key="card.label">
|
|
317
|
+
<div class="stat">
|
|
318
|
+
<div class="label" x-text="card.label"></div>
|
|
319
|
+
<div class="value" :style="{ color: card.clr }" x-text="card.value"></div>
|
|
320
|
+
<div style="font-size:11px;color:var(--text-muted);margin-top:2px" x-text="card.desc"></div>
|
|
321
|
+
</div>
|
|
322
|
+
</template>
|
|
323
|
+
</div>
|
|
324
|
+
<div class="section" style="margin-top:20px" x-data="proxyKeyForm">
|
|
325
|
+
<div class="section-header"><h3>代理 API Key</h3></div>
|
|
326
|
+
<div style="display:flex;align-items:center;gap:8px">
|
|
327
|
+
<input type="password" x-model="key" placeholder="不设置则无需鉴权" style="flex:1;padding:6px 10px;font-size:13px;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);color:var(--text)">
|
|
328
|
+
<button class="btn btn-primary btn-sm" @click="save()" :disabled="saving" x-text="saving ? '保存中...' : '保存'"></button>
|
|
329
|
+
<button class="btn btn-ghost btn-sm" @click="remove()" :disabled="saving" x-show="hasKey">移除</button>
|
|
330
|
+
</div>
|
|
331
|
+
<div style="font-size:11px;color:var(--text-muted);margin-top:4px" x-show="hasKey" x-text="'已设置 (请求需带 Authorization: Bearer <key> 或 x-api-key 头)'"></div>
|
|
332
|
+
<div style="font-size:11px;color:var(--text-muted);margin-top:4px" x-show="!hasKey">未设置 — 所有请求可直接访问</div>
|
|
333
|
+
</div>
|
|
334
|
+
</div>
|
|
335
|
+
|
|
336
|
+
<!-- Logs -->
|
|
337
|
+
<div class="page" id="page-logs"
|
|
338
|
+
x-data="logsPage"
|
|
339
|
+
:class="{ active: $store.app.currentTab === 'logs' }">
|
|
340
|
+
<div class="section">
|
|
341
|
+
<div class="section-header" style="display:flex;align-items:center;justify-content:space-between">
|
|
342
|
+
<h3>日志</h3>
|
|
343
|
+
<div style="display:flex;align-items:center;gap:16px;font-size:11px;color:var(--text-muted)">
|
|
344
|
+
<span>共 <strong style="color:var(--text)" x-text="totalCount"></strong> 条匹配 · 第 <strong style="color:var(--text)" x-text="page"></strong>/<strong style="color:var(--text)" x-text="totalPages"></strong> 页</span>
|
|
345
|
+
</div>
|
|
346
|
+
</div>
|
|
347
|
+
|
|
348
|
+
<!-- Filter bar -->
|
|
349
|
+
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:10px">
|
|
350
|
+
<input type="date" x-model="dateFilter" @change="page=1" style="padding:5px 10px;font-size:12px;border:1px solid var(--border);border-radius:8px;background:var(--surface);color:var(--text);width:135px">
|
|
351
|
+
<button class="filter-btn" @click="dateFilter='';page=1" x-show="dateFilter" style="font-size:10px;padding:3px 7px">✕</button>
|
|
352
|
+
<span style="color:var(--border)">|</span>
|
|
353
|
+
<button class="filter-btn" :class="{active:filter==='all'}" @click="filter='all';page=1">全部</button>
|
|
354
|
+
<button class="filter-btn" :class="{active:filter==='request'}" @click="filter='request';page=1">请求</button>
|
|
355
|
+
<button class="filter-btn" :class="{active:filter==='system'}" @click="filter='system';page=1">系统</button>
|
|
356
|
+
<span style="color:var(--border)">|</span>
|
|
357
|
+
<button class="filter-btn" :class="{active:levelFilter==='all'}" @click="levelFilter='all';page=1">全部</button>
|
|
358
|
+
<button class="filter-btn" :class="{active:levelFilter==='error'}" @click="levelFilter='error';page=1" style="border-color:var(--danger);color:var(--danger)" x-bind:style="levelFilter==='error' ? 'background:var(--danger);color:#fff;border-color:var(--danger)' : 'border-color:var(--danger);color:var(--danger)'">error</button>
|
|
359
|
+
<button class="filter-btn" :class="{active:levelFilter==='warn'}" @click="levelFilter='warn';page=1" style="border-color:var(--warn);color:var(--warn)" x-bind:style="levelFilter==='warn' ? 'background:var(--warn);color:#fff;border-color:var(--warn)' : 'border-color:var(--warn);color:var(--warn)'">warn</button>
|
|
360
|
+
<button class="filter-btn" :class="{active:levelFilter==='info'}" @click="levelFilter='info';page=1">info</button>
|
|
361
|
+
<button class="filter-btn" :class="{active:levelFilter==='debug'}" @click="levelFilter='debug';page=1" style="color:var(--text-muted)">debug</button>
|
|
362
|
+
<span style="color:var(--border)">|</span>
|
|
363
|
+
<input type="text" x-model="search" @input="page=1" placeholder="搜索…" style="flex:1;min-width:100px;padding:5px 10px;font-size:12px;border:1px solid var(--border);border-radius:8px;background:var(--surface);color:var(--text)">
|
|
364
|
+
<div style="display:flex;align-items:center;gap:4px">
|
|
365
|
+
<span style="font-size:11px;color:var(--text-muted)">记录级别</span>
|
|
366
|
+
<select x-model="currentLogLevel" @change="setLogLevel($event.target.value)" style="padding:4px 8px;font-size:11px;border:1px solid var(--border);border-radius:8px;background:var(--surface);color:var(--text)">
|
|
367
|
+
<option value="debug">debug</option>
|
|
368
|
+
<option value="info">info</option>
|
|
369
|
+
<option value="warn">warn</option>
|
|
370
|
+
<option value="error">error</option>
|
|
371
|
+
</select>
|
|
372
|
+
</div>
|
|
373
|
+
<button class="btn btn-primary btn-sm" @click="load()" style="padding:5px 12px;font-size:11px">刷新</button>
|
|
374
|
+
</div>
|
|
375
|
+
|
|
376
|
+
<!-- Log table -->
|
|
377
|
+
<div style="max-height:65vh;overflow-y:auto;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface)">
|
|
378
|
+
<table class="log-table">
|
|
379
|
+
<thead><tr>
|
|
380
|
+
<th style="width:36px"></th>
|
|
381
|
+
<th style="width:170px">时间</th>
|
|
382
|
+
<th style="width:52px">级别</th>
|
|
383
|
+
<th style="width:260px">消息</th>
|
|
384
|
+
<th>详情</th>
|
|
385
|
+
</tr></thead>
|
|
386
|
+
<tbody>
|
|
387
|
+
<template x-for="log in pagedLogs" :key="log.id">
|
|
388
|
+
<tr>
|
|
389
|
+
<td>
|
|
390
|
+
<span class="log-icon" :class="log.type === 'request' ? 'req' : 'sys'">
|
|
391
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" x-show="log.type === 'request'"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
|
|
392
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" x-show="log.type === 'system'"><circle cx="12" cy="12" r="3"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>
|
|
393
|
+
</span>
|
|
394
|
+
</td>
|
|
395
|
+
<td class="mono" style="font-size:11px;color:var(--text-muted)" x-text="formatTime(log.timestamp)"></td>
|
|
396
|
+
<td><span class="log-level" :class="log.level" x-text="log.level"></span></td>
|
|
397
|
+
<td style="max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" x-text="log.message"></td>
|
|
398
|
+
<td style="max-width:500px">
|
|
399
|
+
<template x-if="log.details">
|
|
400
|
+
<div>
|
|
401
|
+
<div style="display:flex;align-items:center;gap:6px;margin-bottom:2px">
|
|
402
|
+
<span class="log-detail-toggle" @click="log._closed = !log._closed" x-text="log._closed ? '展开' : '收起'"></span>
|
|
403
|
+
<span class="log-detail-toggle" @click="copyJson(log.details)" x-show="!log._closed">复制</span>
|
|
404
|
+
</div>
|
|
405
|
+
<div class="log-detail" :class="{collapsed: log._closed}" x-text="formatDetails(log.details)"></div>
|
|
406
|
+
</div>
|
|
407
|
+
</template>
|
|
408
|
+
</td>
|
|
409
|
+
</tr>
|
|
410
|
+
</template>
|
|
411
|
+
</tbody>
|
|
412
|
+
</table>
|
|
413
|
+
<div style="padding:32px;text-align:center;color:var(--text-muted);font-size:13px" x-show="filteredLogs.length === 0 && allLogs.length === 0">暂无日志</div>
|
|
414
|
+
<div style="padding:32px;text-align:center;color:var(--text-muted);font-size:13px" x-show="filteredLogs.length === 0 && allLogs.length > 0">没有匹配的日志</div>
|
|
415
|
+
</div>
|
|
416
|
+
|
|
417
|
+
<!-- Pagination -->
|
|
418
|
+
<div style="display:flex;align-items:center;justify-content:center;gap:10px;margin-top:12px" x-show="totalPages > 1">
|
|
419
|
+
<button class="filter-btn" @click="page=1" :disabled="page<=1">⏮</button>
|
|
420
|
+
<button class="filter-btn" @click="prevPage()" :disabled="page<=1">◀</button>
|
|
421
|
+
<span style="font-size:12px;color:var(--text-muted);min-width:60px;text-align:center" x-text="`${page}/${totalPages}`"></span>
|
|
422
|
+
<button class="filter-btn" @click="nextPage()" :disabled="page>=totalPages">▶</button>
|
|
423
|
+
<button class="filter-btn" @click="page=totalPages" :disabled="page>=totalPages">⏭</button>
|
|
424
|
+
</div>
|
|
425
|
+
</div>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
<!-- Providers -->
|
|
429
|
+
<div class="page" id="page-providers"
|
|
430
|
+
x-data="providersPage"
|
|
431
|
+
:class="{ active: $store.app.currentTab === 'providers' }">
|
|
432
|
+
<div class="section">
|
|
433
|
+
<div class="section-header">
|
|
434
|
+
<h3>模型供应商</h3>
|
|
435
|
+
<div style="display:flex;gap:8px;align-items:center">
|
|
436
|
+
<div class="search-box"><input x-model="search" placeholder="搜索模型供应商..."></div>
|
|
437
|
+
<button class="btn btn-primary btn-sm" @click="openForm(null)">+ 添加</button>
|
|
438
|
+
</div>
|
|
439
|
+
</div>
|
|
440
|
+
<div class="table-wrap">
|
|
441
|
+
<table><thead><tr>
|
|
442
|
+
<th>名称</th><th>类型</th><th>模型数</th><th>状态</th><th>操作</th>
|
|
443
|
+
</tr></thead><tbody>
|
|
444
|
+
<template x-for="p in filteredProviders" :key="p.name">
|
|
445
|
+
<tr>
|
|
446
|
+
<td><strong x-text="p.name"></strong></td>
|
|
447
|
+
<td><span class="mono" x-text="p.type === 'openai-responses' ? 'openai (responses)' : p.type"></span></td>
|
|
448
|
+
<td class="mono" x-text="p.models?.length ?? 0"></td>
|
|
449
|
+
<td><span class="badge" :class="p.available ? 'badge-ok' : 'badge-err'" x-text="p.available ? '正常' : '异常'"></span></td>
|
|
450
|
+
<td>
|
|
451
|
+
<button class="btn btn-sm btn-success" @click="openTestPanel(p.name)">测试</button>
|
|
452
|
+
<button class="btn btn-sm btn-warning" @click="openForm(p.name)">编辑</button>
|
|
453
|
+
<button class="btn btn-sm btn-danger" @click="confirmDelete(p.name)">删除</button>
|
|
454
|
+
</td>
|
|
455
|
+
</tr>
|
|
456
|
+
</template>
|
|
457
|
+
<tr x-show="filteredProviders.length === 0 && providers.length === 0">
|
|
458
|
+
<td colspan="5" class="empty">暂无数据</td>
|
|
459
|
+
</tr>
|
|
460
|
+
<tr x-show="filteredProviders.length === 0 && providers.length > 0">
|
|
461
|
+
<td colspan="5" class="empty">没有匹配的供应商</td>
|
|
462
|
+
</tr>
|
|
463
|
+
</tbody></table>
|
|
464
|
+
</div>
|
|
465
|
+
</div>
|
|
466
|
+
|
|
467
|
+
<!-- Provider Modal -->
|
|
468
|
+
<div class="modal-overlay" x-show="showModal" x-cloak style="display:none"><div class="modal" style="max-height:80vh;display:flex;flex-direction:column">
|
|
469
|
+
<h3 x-text="editingName ? '编辑模型供应商' : '添加模型供应商'"></h3>
|
|
470
|
+
<div style="flex:1;overflow-y:auto;padding-right:4px">
|
|
471
|
+
<label>名称</label><input x-model="form.name" placeholder="my-provider">
|
|
472
|
+
<label>类型</label><select x-model="form.type">
|
|
473
|
+
<option value="openai">OpenAI (Chat)</option>
|
|
474
|
+
<option value="openai-responses">OpenAI (Responses)</option>
|
|
475
|
+
<option value="anthropic">Anthropic</option>
|
|
476
|
+
</select>
|
|
477
|
+
<label>API Key</label>
|
|
478
|
+
<div style="display:flex;gap:4px">
|
|
479
|
+
<input x-model="form.apiKey" :type="showKey ? 'text' : 'password'" placeholder="sk-..." style="flex:1">
|
|
480
|
+
<button class="btn btn-sm btn-ghost" type="button"
|
|
481
|
+
@click="showKey = !showKey"
|
|
482
|
+
x-text="showKey ? '隐藏' : '查看'"
|
|
483
|
+
style="flex-shrink:0;font-size:12px"></button>
|
|
484
|
+
</div>
|
|
485
|
+
<div class="hint" x-show="editingName" x-text="'留空则保留原值'" style="display:none"></div>
|
|
486
|
+
<label>API Base(可选)</label>
|
|
487
|
+
<input x-model="form.apiBase" placeholder="https://api.openai.com">
|
|
488
|
+
<label>模型列表
|
|
489
|
+
<button class="btn btn-sm btn-success" @click="openPullModels()" style="margin-left:8px">拉取远程模型</button>
|
|
490
|
+
</label>
|
|
491
|
+
<div class="dynamic-rows">
|
|
492
|
+
<template x-for="(m, i) in form.models" :key="i">
|
|
493
|
+
<div class="dynamic-row">
|
|
494
|
+
<span class="pm-label">模型 ID</span>
|
|
495
|
+
<input x-model="m.id" placeholder="如 gpt-4o" style="flex:1">
|
|
496
|
+
<button class="btn btn-sm btn-danger btn-icon" @click="removeModelRow(i)">✕</button>
|
|
497
|
+
</div>
|
|
498
|
+
</template>
|
|
499
|
+
</div>
|
|
500
|
+
<button class="btn btn-sm btn-ghost" @click="addModelRow()" style="margin-top:4px;flex-shrink:0">+ 添加模型</button>
|
|
501
|
+
</div>
|
|
502
|
+
<div class="btn-row" style="flex-shrink:0">
|
|
503
|
+
<button class="btn btn-ghost" @click="showModal = false">取消</button>
|
|
504
|
+
<button class="btn btn-primary" @click="save()">保存</button>
|
|
505
|
+
</div>
|
|
506
|
+
</div></div>
|
|
507
|
+
|
|
508
|
+
<!-- Pull Models Modal -->
|
|
509
|
+
<div class="modal-overlay" x-show="pullModal.visible" x-cloak style="display:none"><div class="modal" style="max-height:80vh;display:flex;flex-direction:column">
|
|
510
|
+
<h3>远程模型列表</h3>
|
|
511
|
+
<div style="font-size:12px;color:var(--text-muted);margin-bottom:8px">
|
|
512
|
+
<span x-show="!pullModal.loading" x-text="'共 ' + pullModal.models.length + ' 个模型,' + pullModal.existing.length + ' 个已存在'"></span>
|
|
513
|
+
<span x-show="pullModal.loading">加载中...</span>
|
|
514
|
+
</div>
|
|
515
|
+
<div style="flex:1;overflow-y:auto;margin-bottom:12px">
|
|
516
|
+
<template x-if="!pullModal.loading && pullModal.models.length === 0">
|
|
517
|
+
<div class="empty" x-text="pullModal.error || '未找到可用模型'"></div>
|
|
518
|
+
</template>
|
|
519
|
+
<table x-show="!pullModal.loading && pullModal.models.length > 0">
|
|
520
|
+
<thead><tr><th style="width:30px"></th><th>模型 ID</th><th>来源</th></tr></thead>
|
|
521
|
+
<tbody>
|
|
522
|
+
<template x-for="(m, i) in pullModal.models" :key="i">
|
|
523
|
+
<tr>
|
|
524
|
+
<td><input type="checkbox"
|
|
525
|
+
:checked="pullModal.existing.includes(m.id) || true"
|
|
526
|
+
:disabled="pullModal.existing.includes(m.id)"></td>
|
|
527
|
+
<td><span class="mono" x-text="m.id"></span></td>
|
|
528
|
+
<td style="font-size:11px;color:var(--text-muted)" x-text="m.description || ''"></td>
|
|
529
|
+
</tr>
|
|
530
|
+
</template>
|
|
531
|
+
</tbody>
|
|
532
|
+
</table>
|
|
533
|
+
</div>
|
|
534
|
+
<div class="btn-row">
|
|
535
|
+
<button class="btn btn-ghost" @click="pullModal.visible = false">取消</button>
|
|
536
|
+
<button class="btn btn-primary" @click="importPullModels()" :disabled="pullModal.loading">导入选中</button>
|
|
537
|
+
</div>
|
|
538
|
+
</div></div>
|
|
539
|
+
</div>
|
|
540
|
+
|
|
541
|
+
<!-- Adapters -->
|
|
542
|
+
<div class="page" id="page-adapters"
|
|
543
|
+
x-data="adaptersPage"
|
|
544
|
+
:class="{ active: $store.app.currentTab === 'adapters' }">
|
|
545
|
+
<div class="section">
|
|
546
|
+
<div class="section-header">
|
|
547
|
+
<h3>工具适配器映射</h3>
|
|
548
|
+
<div style="display:flex;gap:8px;align-items:center">
|
|
549
|
+
<div class="search-box"><input x-model="search" placeholder="搜索适配器..."></div>
|
|
550
|
+
<button class="btn btn-primary btn-sm" @click="openForm(null)">+ 添加</button>
|
|
551
|
+
</div>
|
|
552
|
+
</div>
|
|
553
|
+
<div class="table-wrap">
|
|
554
|
+
<table><thead><tr>
|
|
555
|
+
<th>适配器</th><th>类型</th><th>Base URL</th><th>模型映射</th><th>状态</th><th>操作</th>
|
|
556
|
+
</tr></thead><tbody>
|
|
557
|
+
<template x-for="a in filteredAdapters" :key="a.name">
|
|
558
|
+
<tr>
|
|
559
|
+
<td><strong x-text="a.name"></strong></td>
|
|
560
|
+
<td><span class="mono" x-text="a.type === 'openai-responses' ? 'openai (responses)' : a.type"></span></td>
|
|
561
|
+
<td class="mono" style="font-size:11px;color:var(--text-muted)" x-text="a.baseUrl || '—'"></td>
|
|
562
|
+
<td><div class="adapter-tags">
|
|
563
|
+
<template x-for="m in a.models" :key="m.sourceModelId + m.targetModelId">
|
|
564
|
+
<span class="adapter-tag" :class="{ 'adapter-tag-err': m.status !== 'ok' }"
|
|
565
|
+
x-text="m.sourceModelId + ' → ' + m.provider + '/' + m.targetModelId"></span>
|
|
566
|
+
</template>
|
|
567
|
+
</div></td>
|
|
568
|
+
<td>
|
|
569
|
+
<span class="badge"
|
|
570
|
+
:class="a.models.every(m => m.status === 'ok') ? 'badge-ok' : 'badge-err'"
|
|
571
|
+
x-text="a.models.every(m => m.status === 'ok') ? '正常' : (a.models.find(m => m.status !== 'ok')?.status || '异常')"></span>
|
|
572
|
+
</td>
|
|
573
|
+
<td>
|
|
574
|
+
<button class="btn btn-sm btn-success" @click="openTestPanel(a.name)">测试</button>
|
|
575
|
+
<button class="btn btn-sm btn-warning" @click="openForm(a.name)">编辑</button>
|
|
576
|
+
<button class="btn btn-sm btn-danger" @click="confirmDelete(a.name)">删除</button>
|
|
577
|
+
</td>
|
|
578
|
+
</tr>
|
|
579
|
+
</template>
|
|
580
|
+
<tr x-show="filteredAdapters.length === 0 && adapters.length === 0">
|
|
581
|
+
<td colspan="6" class="empty">暂无适配器</td>
|
|
582
|
+
</tr>
|
|
583
|
+
<tr x-show="filteredAdapters.length === 0 && adapters.length > 0">
|
|
584
|
+
<td colspan="6" class="empty">没有匹配的适配器</td>
|
|
585
|
+
</tr>
|
|
586
|
+
</tbody></table>
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
|
|
590
|
+
<!-- Adapter Modal -->
|
|
591
|
+
<div class="modal-overlay" x-show="showModal" x-cloak style="display:none"><div class="modal" style="min-width:640px;max-width:740px">
|
|
592
|
+
<h3 x-text="editingName ? '编辑适配器' : '添加适配器'"></h3>
|
|
593
|
+
<label>名称</label><input x-model="form.name" placeholder="my-tool">
|
|
594
|
+
<label>类型</label><select x-model="form.type">
|
|
595
|
+
<option value="openai">OpenAI (Chat)</option>
|
|
596
|
+
<option value="openai-responses">OpenAI (Responses)</option>
|
|
597
|
+
<option value="anthropic">Anthropic</option>
|
|
598
|
+
</select>
|
|
599
|
+
<label>模型映射</label>
|
|
600
|
+
<div class="dynamic-rows">
|
|
601
|
+
<template x-for="(m, i) in form.models" :key="i">
|
|
602
|
+
<div class="dynamic-row">
|
|
603
|
+
<span class="pm-label">适配前模型 ID</span>
|
|
604
|
+
<input x-model="m.sourceModelId" placeholder="工具发出的模型名" style="flex:1">
|
|
605
|
+
<span class="pm-label">供应商</span>
|
|
606
|
+
<select :value="m.provider" @change="m.provider = $event.target.value; onProviderChange(i)" style="flex:1;min-width:0">
|
|
607
|
+
<option value="">-- 选择供应商 --</option>
|
|
608
|
+
<template x-for="p in providers" :key="p.name">
|
|
609
|
+
<option :value="p.name" :selected="p.name === m.provider" x-text="p.name"></option>
|
|
610
|
+
</template>
|
|
611
|
+
</select>
|
|
612
|
+
<span class="pm-label">适配后模型 ID</span>
|
|
613
|
+
<select :value="m.targetModelId" @change="m.targetModelId = $event.target.value" style="flex:2;min-width:140px">
|
|
614
|
+
<option value="">-- 选择模型 --</option>
|
|
615
|
+
<template x-for="mid in getProviderModels(m.provider)" :key="mid.id">
|
|
616
|
+
<option :value="mid.id" :selected="mid.id === m.targetModelId" x-text="mid.id"></option>
|
|
617
|
+
</template>
|
|
618
|
+
</select>
|
|
619
|
+
<button class="btn btn-sm btn-danger btn-icon" @click="removeMappingRow(i)">✕</button>
|
|
620
|
+
</div>
|
|
621
|
+
</template>
|
|
622
|
+
</div>
|
|
623
|
+
<button class="btn btn-sm btn-ghost" @click="addMappingRow()" style="margin-top:4px">+ 添加映射</button>
|
|
624
|
+
<div class="btn-row">
|
|
625
|
+
<button class="btn btn-ghost" @click="showModal = false">取消</button>
|
|
626
|
+
<button class="btn btn-primary" @click="save()">保存</button>
|
|
627
|
+
</div>
|
|
628
|
+
</div></div>
|
|
629
|
+
|
|
630
|
+
<!-- Adapter Test Modal -->
|
|
631
|
+
<div class="modal-overlay" x-show="adapterTestModal.visible" x-cloak style="display:none"><div class="modal" style="min-width:500px;max-width:640px">
|
|
632
|
+
<h3 x-text="'测试适配器 — ' + adapterTestModal.adapterName"></h3>
|
|
633
|
+
<div style="display:flex;gap:8px;margin-bottom:14px;align-items:center">
|
|
634
|
+
<select x-model="adapterTestModal.selectedModelId" style="flex:1;padding:6px 8px;font-size:12px;border:1px solid var(--border);border-radius:var(--radius)">
|
|
635
|
+
<template x-for="m in adapterTestModal.models" :key="m.id">
|
|
636
|
+
<option :value="m.id" x-text="m.id + (m.status !== 'ok' ? ' (' + m.status + ')' : '')"></option>
|
|
637
|
+
</template>
|
|
638
|
+
</select>
|
|
639
|
+
<button class="btn btn-primary btn-sm" @click="runAdapterTest()" style="min-width:52px" :disabled="adapterTestModal.running" x-text="adapterTestModal.running ? '测试中' : '运行'"></button>
|
|
640
|
+
</div>
|
|
641
|
+
<div style="max-height:360px;overflow-y:auto;display:flex;flex-direction:column;gap:6px">
|
|
642
|
+
<template x-for="(r, i) in adapterTestModal.results" :key="i">
|
|
643
|
+
<div :style="'display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:var(--radius);font-size:12.5px;background:' + (r.ok ? 'var(--success-bg)' : 'var(--danger-bg)') + ';border-left:3px solid ' + (r.ok ? 'var(--success)' : 'var(--danger)')">
|
|
644
|
+
<span style="font-weight:600;min-width:140px;max-width:200px;overflow:hidden;text-overflow:ellipsis" x-text="r.model"></span>
|
|
645
|
+
<span style="font-size:11px;color:var(--text-muted);min-width:60px" x-text="r.time"></span>
|
|
646
|
+
<span style="flex:1" x-text="r.ok ? '✓ ' + r.latency + 'ms' : '✗ ' + (r.error || '不可达').slice(0, 80)"></span>
|
|
647
|
+
</div>
|
|
648
|
+
</template>
|
|
649
|
+
<div class="empty" style="padding:24px" x-show="adapterTestModal.results.length === 0">点击 "运行" 测试所选映射模型</div>
|
|
650
|
+
</div>
|
|
651
|
+
<div class="btn-row">
|
|
652
|
+
<button class="btn btn-ghost" @click="adapterTestModal.results = []" style="font-size:11.5px">清除结果</button>
|
|
653
|
+
<button class="btn btn-ghost" @click="adapterTestModal.visible = false">关闭</button>
|
|
654
|
+
</div>
|
|
655
|
+
</div></div>
|
|
656
|
+
</div>
|
|
657
|
+
|
|
658
|
+
<!-- Protocol Capture (Wireshark) -->
|
|
659
|
+
<div class="page" id="page-capture"
|
|
660
|
+
x-data="capturePage"
|
|
661
|
+
:class="{ active: $store.app.currentTab === 'capture' }">
|
|
662
|
+
<div class="section" style="flex:1;display:flex;flex-direction:column">
|
|
663
|
+
<div class="section-header">
|
|
664
|
+
<h3>协议数据包捕获</h3>
|
|
665
|
+
<div style="display:flex;align-items:center;gap:8px">
|
|
666
|
+
<button class="filter-btn" :class="{active: running}" @click="startCapture()" x-show="!running">▶ 开始抓包</button>
|
|
667
|
+
<button class="filter-btn" @click="stopCapture()" x-show="running">⏸ 暂停</button>
|
|
668
|
+
<button class="filter-btn" @click="endCapture()" x-show="entries.length > 0" style="border-color:var(--danger);color:var(--danger)">■ 结束</button>
|
|
669
|
+
<span style="color:var(--border);margin:0 4px">|</span>
|
|
670
|
+
<span style="font-size:11px;color:var(--text-muted)" x-text="entries.length + ' 条'"></span>
|
|
671
|
+
</div>
|
|
672
|
+
</div>
|
|
673
|
+
|
|
674
|
+
<!-- Filter bar -->
|
|
675
|
+
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:10px">
|
|
676
|
+
<span style="font-size:11px;color:var(--text-muted)">来源</span>
|
|
677
|
+
<button class="filter-btn" :class="{active: !sourceFilter}" @click="sourceFilter = ''">全部</button>
|
|
678
|
+
<button class="filter-btn" :class="{active: sourceFilter === 'proxy'}" @click="sourceFilter = 'proxy'">代理</button>
|
|
679
|
+
<template x-for="s in [...new Set(entries.map(e => e.source))].filter(s => s.startsWith('adapter:')).sort()" :key="s">
|
|
680
|
+
<button class="filter-btn" :class="{active: sourceFilter === s}" @click="sourceFilter = s" x-text="s.slice(8)"></button>
|
|
681
|
+
</template>
|
|
682
|
+
</div>
|
|
683
|
+
|
|
684
|
+
<!-- Packet list -->
|
|
685
|
+
<div style="flex:0 0 auto;max-height:280px;overflow-y:auto;border:1px solid var(--border);border-radius:var(--radius);margin-bottom:12px">
|
|
686
|
+
<table style="width:100%;font-size:12px;font-family:monospace">
|
|
687
|
+
<thead><tr style="background:var(--bg-hover);position:sticky;top:0">
|
|
688
|
+
<th style="width:40px;text-align:center">#</th>
|
|
689
|
+
<th style="width:150px">时间</th>
|
|
690
|
+
<th style="width:100px">方向</th>
|
|
691
|
+
<th style="width:90px">来源</th>
|
|
692
|
+
<th style="width:90px">协议</th>
|
|
693
|
+
<th style="width:90px">模型</th>
|
|
694
|
+
<th style="width:60px;text-align:right">大小</th>
|
|
695
|
+
</tr></thead>
|
|
696
|
+
<tbody>
|
|
697
|
+
<template x-for="e in filteredEntries.slice().reverse()" :key="e.id">
|
|
698
|
+
<tr @click="select(e.id)"
|
|
699
|
+
:style="'cursor:pointer;background:' + (selectedId === e.id ? 'var(--accent-bg)' : 'transparent')">
|
|
700
|
+
<td style="text-align:center;color:var(--text-muted)" x-text="e.id"></td>
|
|
701
|
+
<td x-text="fmtTime(e.timestamp)"></td>
|
|
702
|
+
<td><span :style="'color:' + (e.direction.endsWith('-in') ? 'var(--success)' : 'var(--accent)')" x-html="dirIcon(e.direction) + ' ' + dirLabel(e.direction)"></span></td>
|
|
703
|
+
<td style="color:var(--text-muted)" x-text="e.source?.startsWith('adapter:') ? e.source.slice(8) : e.source"></td>
|
|
704
|
+
<td x-text="e.protocol"></td>
|
|
705
|
+
<td x-text="e.model"></td>
|
|
706
|
+
<td style="text-align:right;color:var(--text-muted)" x-text="fmtSize(e.rawData)"></td>
|
|
707
|
+
</tr>
|
|
708
|
+
</template>
|
|
709
|
+
</tbody>
|
|
710
|
+
</table>
|
|
711
|
+
<div style="padding:24px;text-align:center;color:var(--text-muted);font-size:13px" x-show="entries.length === 0">
|
|
712
|
+
暂无数据包 — 发起一次代理请求即可捕获
|
|
713
|
+
</div>
|
|
714
|
+
</div>
|
|
715
|
+
|
|
716
|
+
<!-- Detail split view -->
|
|
717
|
+
<template x-if="selected">
|
|
718
|
+
<div style="flex:1;display:flex;flex-direction:column;min-height:0">
|
|
719
|
+
<!-- Paired entries: side by side -->
|
|
720
|
+
<div style="display:flex;gap:8px;flex:1;min-height:0">
|
|
721
|
+
<template x-for="e in pairedEntries" :key="e.id">
|
|
722
|
+
<div style="flex:1;display:flex;flex-direction:column;min-width:0;border:1px solid var(--border);border-radius:var(--radius);overflow:hidden">
|
|
723
|
+
<div :style="'padding:6px 10px;font-size:11px;font-weight:600;background:' + (e.direction.endsWith('-in') ? 'var(--success-bg)' : 'var(--accent-bg)') + ';border-bottom:1px solid var(--border)'">
|
|
724
|
+
<span x-text="dirIcon(e.direction) + ' ' + dirLabel(e.direction)"></span>
|
|
725
|
+
<span style="float:right;opacity:0.7" x-text="e.protocol + ' · ' + e.model"></span>
|
|
726
|
+
<button @click="copyRaw(e.rawData)" style="float:right;margin-right:8px;font-size:10px;padding:2px 6px;border:1px solid var(--border);border-radius:4px;background:var(--surface);cursor:pointer;opacity:0.7" title="复制原始内容">📋</button>
|
|
727
|
+
</div>
|
|
728
|
+
<div class="jsoneditor-container" style="flex:1;min-height:200px"></div>
|
|
729
|
+
</div>
|
|
730
|
+
</template>
|
|
731
|
+
</div>
|
|
732
|
+
|
|
733
|
+
<!-- Diff summary -->
|
|
734
|
+
<div style="margin-top:8px;padding:8px 12px;background:var(--bg-hover);border-radius:var(--radius);font-size:11.5px;line-height:1.6" x-show="pairedEntries.length >= 2">
|
|
735
|
+
<div style="font-weight:600;margin-bottom:4px">转换差异</div>
|
|
736
|
+
<template x-for="d in getDiffLines(pairedEntries[0].rawData, pairedEntries[1].rawData)" :key="d">
|
|
737
|
+
<div x-text="d" :style="'color:' + (d.startsWith('+') ? 'var(--success)' : d.startsWith('-') ? 'var(--danger)' : d.startsWith('⚠') ? 'var(--warn)' : 'var(--text-muted)')"></div>
|
|
738
|
+
</template>
|
|
739
|
+
<div x-show="getDiffLines(pairedEntries[0].rawData, pairedEntries[1].rawData).length === 0" style="color:var(--text-muted)">同协议透传,无格式变化</div>
|
|
740
|
+
</div>
|
|
741
|
+
</div>
|
|
742
|
+
</template>
|
|
743
|
+
</div>
|
|
744
|
+
</div>
|
|
745
|
+
|
|
746
|
+
<!-- Test Panel -->
|
|
747
|
+
<div class="modal-overlay" x-data="testPanel" x-show="visible" x-cloak style="display:none"><div class="modal" style="min-width:500px;max-width:640px">
|
|
748
|
+
<h3 x-text="'测试 — ' + providerName"></h3>
|
|
749
|
+
<div style="display:flex;gap:8px;margin-bottom:14px;align-items:center">
|
|
750
|
+
<strong style="font-size:13px;min-width:80px" x-text="providerName"></strong>
|
|
751
|
+
<select x-model="selectedModel" style="flex:1;padding:6px 8px;font-size:12px;border:1px solid var(--border);border-radius:var(--radius)">
|
|
752
|
+
<template x-for="m in models" :key="m.id">
|
|
753
|
+
<option :value="m.id" x-text="m.id"></option>
|
|
754
|
+
</template>
|
|
755
|
+
</select>
|
|
756
|
+
<select x-model="endpoint" x-show="providerType === 'openai'" style="padding:6px 8px;font-size:11px;border:1px solid var(--border);border-radius:var(--radius)">
|
|
757
|
+
<option value="chat">Chat</option>
|
|
758
|
+
<option value="responses">Responses</option>
|
|
759
|
+
</select>
|
|
760
|
+
<button class="btn btn-primary btn-sm" @click="run()" style="min-width:52px" :disabled="running" x-text="running ? '测试中' : '运行'"></button>
|
|
761
|
+
</div>
|
|
762
|
+
<div style="max-height:360px;overflow-y:auto;display:flex;flex-direction:column;gap:6px">
|
|
763
|
+
<template x-for="(r, i) in results" :key="i">
|
|
764
|
+
<div :style="'display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:var(--radius);font-size:12.5px;background:' + (r.ok ? 'var(--success-bg)' : 'var(--danger-bg)') + ';border-left:3px solid ' + (r.ok ? 'var(--success)' : 'var(--danger)')">
|
|
765
|
+
<span style="font-weight:600;min-width:140px;max-width:200px;overflow:hidden;text-overflow:ellipsis" x-text="r.model"></span>
|
|
766
|
+
<span style="font-size:11px;color:var(--text-muted);min-width:60px" x-text="r.time"></span>
|
|
767
|
+
<span style="flex:1" x-text="r.ok ? '✓ ' + r.latency + 'ms' : '✗ ' + (r.error || '不可达').slice(0, 80)"></span>
|
|
768
|
+
</div>
|
|
769
|
+
</template>
|
|
770
|
+
<div class="empty" style="padding:24px" x-show="results.length === 0">点击 "运行" 测试所选模型</div>
|
|
771
|
+
</div>
|
|
772
|
+
<div class="btn-row">
|
|
773
|
+
<button class="btn btn-ghost" @click="clear()" style="font-size:11.5px">清除结果</button>
|
|
774
|
+
<button class="btn btn-ghost" @click="visible = false">关闭</button>
|
|
775
|
+
</div>
|
|
776
|
+
</div></div>
|
|
777
|
+
|
|
778
|
+
</div>
|
|
779
|
+
</div>
|
|
780
|
+
|
|
781
|
+
<!-- Confirm Dialog -->
|
|
782
|
+
<div class="confirm-overlay" x-data
|
|
783
|
+
:class="{ open: $store.app.showConfirm }"
|
|
784
|
+
x-cloak
|
|
785
|
+
style="display:none">
|
|
786
|
+
<div class="confirm-box">
|
|
787
|
+
<p x-text="$store.app.confirmMessage"></p>
|
|
788
|
+
<div class="btn-row">
|
|
789
|
+
<button class="btn btn-ghost" @click="$store.app.confirmResolve(false); $store.app.showConfirm = false">取消</button>
|
|
790
|
+
<button class="btn btn-danger" @click="$store.app.confirmResolve(true); $store.app.showConfirm = false">确定</button>
|
|
791
|
+
</div>
|
|
792
|
+
</div>
|
|
793
|
+
</div>
|
|
794
|
+
|
|
795
|
+
<div class="toast-container" id="toastContainer"></div>
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
</body>
|
|
799
|
+
</html>
|