@alexpeng/dsh-custom-plugin 0.5.0 → 0.7.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/CHANGELOG.md +598 -394
- package/README.i18n.yaml +2 -2
- package/README.md +91 -33
- package/README.zh.md +73 -31
- package/lib/client.js +473 -933
- package/lib/client.js.map +1 -1
- package/lib/index.js +58 -18
- package/lib/types/client/custom.d.ts +1 -5
- package/lib/types/client/palette.d.ts +31 -0
- package/lib/types/client/styles.d.ts +1 -1
- package/lib/types/host-service.d.ts +9 -0
- package/lib/types/loopback.d.ts +14 -7
- package/lib/types/pricing.d.ts +1 -1
- package/lib/types/protocol.d.ts +2 -7
- package/lib/types/routes.d.ts +4 -4
- package/lib/types/state.d.ts +9 -0
- package/package.json +14 -13
package/lib/client.js
CHANGED
|
@@ -50,9 +50,6 @@ window.__ModuleLoader__.load({
|
|
|
50
50
|
glass: true,
|
|
51
51
|
glassMode: "frost",
|
|
52
52
|
globalGlass: true,
|
|
53
|
-
timeline: true,
|
|
54
|
-
timelineLeft: false,
|
|
55
|
-
starsOnly: false,
|
|
56
53
|
quote: true,
|
|
57
54
|
antiScroll: false,
|
|
58
55
|
mermaid: true,
|
|
@@ -151,14 +148,16 @@ window.__ModuleLoader__.load({
|
|
|
151
148
|
/** Official source used for the built-in estimate and shown in the panel. */
|
|
152
149
|
const DEEPSEEK_PRICING_SOURCE_URL = "https://api-docs.deepseek.com/zh-cn/quick_start/pricing/";
|
|
153
150
|
/** Date on which the built-in rule was checked against the official page. */
|
|
154
|
-
const DEEPSEEK_PRICING_CHECKED_ON = "2026-
|
|
151
|
+
const DEEPSEEK_PRICING_CHECKED_ON = "2026-09-30";
|
|
155
152
|
const FLASH_PRICE = {
|
|
156
|
-
input:
|
|
157
|
-
cacheHit: .
|
|
158
|
-
output:
|
|
153
|
+
input: 2,
|
|
154
|
+
cacheHit: .04,
|
|
155
|
+
output: 8
|
|
159
156
|
};
|
|
160
|
-
/** Current official peak prices, in CNY per 1M tokens.
|
|
157
|
+
/** Current official peak prices, in CNY per 1M tokens. Off-peak is exactly
|
|
158
|
+
* half of peak per the official page (weekday 9-12 / 14-18 Beijing time). */
|
|
161
159
|
const PEAK_PRICES = {
|
|
160
|
+
"deepseek-flash": FLASH_PRICE,
|
|
162
161
|
"deepseek-v4-flash": FLASH_PRICE,
|
|
163
162
|
"deepseek-v4-flash-vision-exp": FLASH_PRICE,
|
|
164
163
|
"deepseek-v4-pro": {
|
|
@@ -195,6 +194,215 @@ window.__ModuleLoader__.load({
|
|
|
195
194
|
totalCostCny: (peakCost + offPeakCost / 2) / 1e6
|
|
196
195
|
};
|
|
197
196
|
}
|
|
197
|
+
/** Estimate one row's total CNY cost. */
|
|
198
|
+
function estimateUsageCostCny(row, model) {
|
|
199
|
+
return usageCostBreakdown(row, model).totalCostCny;
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/client/palette.ts
|
|
203
|
+
/**
|
|
204
|
+
* Background palette and the dark-mode derivation shared by the appearance
|
|
205
|
+
* panel and the body/token painting.
|
|
206
|
+
*
|
|
207
|
+
* The 20 families are tuned as light pastels. Dark mode reuses the same hue
|
|
208
|
+
* family instead of disabling them: {@link toDarkRamp} keeps hue and
|
|
209
|
+
* saturation and drops lightness onto a dark-ramp target, so 雾蓝 reads as a
|
|
210
|
+
* dark blue-gray, 裸桃 as a warm dark gray, and so on — the canvas stays
|
|
211
|
+
* readable while the palette's character survives.
|
|
212
|
+
* @module @alexpeng/dsh-custom-plugin/client/palette
|
|
213
|
+
*/
|
|
214
|
+
/** Palette of 20 muted low-saturation backgrounds (with matching tab colors).
|
|
215
|
+
* 天青灰 leads the list: it is the install default and renders first among
|
|
216
|
+
* the palette swatches, right after 无颜色. */
|
|
217
|
+
const PALETTE = [
|
|
218
|
+
[
|
|
219
|
+
"天青灰",
|
|
220
|
+
"#E9EBEE",
|
|
221
|
+
"#D6DADF"
|
|
222
|
+
],
|
|
223
|
+
[
|
|
224
|
+
"暖象牙",
|
|
225
|
+
"#F5F0E8",
|
|
226
|
+
"#E8E0D4"
|
|
227
|
+
],
|
|
228
|
+
[
|
|
229
|
+
"雾灰绿",
|
|
230
|
+
"#E9EDE6",
|
|
231
|
+
"#D7DED3"
|
|
232
|
+
],
|
|
233
|
+
[
|
|
234
|
+
"烟熏玫瑰",
|
|
235
|
+
"#F2EAEC",
|
|
236
|
+
"#E5D6DA"
|
|
237
|
+
],
|
|
238
|
+
[
|
|
239
|
+
"雾蓝",
|
|
240
|
+
"#E8EDF2",
|
|
241
|
+
"#D4DDE6"
|
|
242
|
+
],
|
|
243
|
+
[
|
|
244
|
+
"薰衣草灰",
|
|
245
|
+
"#EFEDF4",
|
|
246
|
+
"#E0DCEB"
|
|
247
|
+
],
|
|
248
|
+
[
|
|
249
|
+
"燕麦米",
|
|
250
|
+
"#F3EEE6",
|
|
251
|
+
"#E5DED3"
|
|
252
|
+
],
|
|
253
|
+
[
|
|
254
|
+
"薄荷雾",
|
|
255
|
+
"#EAF0ED",
|
|
256
|
+
"#D7E3DC"
|
|
257
|
+
],
|
|
258
|
+
[
|
|
259
|
+
"裸桃",
|
|
260
|
+
"#F5EDE8",
|
|
261
|
+
"#E8DCD4"
|
|
262
|
+
],
|
|
263
|
+
[
|
|
264
|
+
"石板蓝",
|
|
265
|
+
"#E6EDF1",
|
|
266
|
+
"#D2DBE3"
|
|
267
|
+
],
|
|
268
|
+
[
|
|
269
|
+
"紫藤灰",
|
|
270
|
+
"#EEEBF2",
|
|
271
|
+
"#E1DAE8"
|
|
272
|
+
],
|
|
273
|
+
[
|
|
274
|
+
"奶油黄",
|
|
275
|
+
"#F4F0E6",
|
|
276
|
+
"#E6E1D5"
|
|
277
|
+
],
|
|
278
|
+
[
|
|
279
|
+
"鼠尾草",
|
|
280
|
+
"#EAEDE5",
|
|
281
|
+
"#D7DED1"
|
|
282
|
+
],
|
|
283
|
+
[
|
|
284
|
+
"腮红粉",
|
|
285
|
+
"#F3EAEC",
|
|
286
|
+
"#E6D6DA"
|
|
287
|
+
],
|
|
288
|
+
[
|
|
289
|
+
"香草白",
|
|
290
|
+
"#F3F0E6",
|
|
291
|
+
"#E5E0D4"
|
|
292
|
+
],
|
|
293
|
+
[
|
|
294
|
+
"青灰",
|
|
295
|
+
"#E7F0F0",
|
|
296
|
+
"#D3E1E1"
|
|
297
|
+
],
|
|
298
|
+
[
|
|
299
|
+
"杏仁白",
|
|
300
|
+
"#F0ECE8",
|
|
301
|
+
"#E2DAD3"
|
|
302
|
+
],
|
|
303
|
+
[
|
|
304
|
+
"尤加利",
|
|
305
|
+
"#EAF0ED",
|
|
306
|
+
"#D7E3DB"
|
|
307
|
+
],
|
|
308
|
+
[
|
|
309
|
+
"珍珠灰",
|
|
310
|
+
"#EDEDEE",
|
|
311
|
+
"#DCDCDD"
|
|
312
|
+
],
|
|
313
|
+
[
|
|
314
|
+
"淡金",
|
|
315
|
+
"#F4F1E4",
|
|
316
|
+
"#E6E1D0"
|
|
317
|
+
]
|
|
318
|
+
];
|
|
319
|
+
function hexToRgb(hex) {
|
|
320
|
+
const match = /^#?([0-9a-f]{6})$/i.exec(String(hex ?? "").trim());
|
|
321
|
+
if (match === null) return [
|
|
322
|
+
235,
|
|
323
|
+
238,
|
|
324
|
+
242
|
|
325
|
+
];
|
|
326
|
+
const value = parseInt(match[1], 16);
|
|
327
|
+
return [
|
|
328
|
+
value >> 16 & 255,
|
|
329
|
+
value >> 8 & 255,
|
|
330
|
+
value & 255
|
|
331
|
+
];
|
|
332
|
+
}
|
|
333
|
+
function rgbToHsl(rgb) {
|
|
334
|
+
const [r0, g0, b0] = rgb.map((v) => v / 255);
|
|
335
|
+
const max = Math.max(r0, g0, b0);
|
|
336
|
+
const min = Math.min(r0, g0, b0);
|
|
337
|
+
const l = (max + min) / 2;
|
|
338
|
+
if (max === min) return [
|
|
339
|
+
0,
|
|
340
|
+
0,
|
|
341
|
+
l
|
|
342
|
+
];
|
|
343
|
+
const d = max - min;
|
|
344
|
+
const s = l > .5 ? d / (2 - max - min) : d / (max + min);
|
|
345
|
+
let h;
|
|
346
|
+
if (max === r0) h = ((g0 - b0) / d + (g0 < b0 ? 6 : 0)) / 6;
|
|
347
|
+
else if (max === g0) h = ((b0 - r0) / d + 2) / 6;
|
|
348
|
+
else h = ((r0 - g0) / d + 4) / 6;
|
|
349
|
+
return [
|
|
350
|
+
h,
|
|
351
|
+
s,
|
|
352
|
+
l
|
|
353
|
+
];
|
|
354
|
+
}
|
|
355
|
+
function hslToRgb(h, s, l) {
|
|
356
|
+
if (s === 0) {
|
|
357
|
+
const v = Math.round(l * 255);
|
|
358
|
+
return [
|
|
359
|
+
v,
|
|
360
|
+
v,
|
|
361
|
+
v
|
|
362
|
+
];
|
|
363
|
+
}
|
|
364
|
+
const q = l < .5 ? l * (1 + s) : l + s - l * s;
|
|
365
|
+
const p = 2 * l - q;
|
|
366
|
+
const channel = (t0) => {
|
|
367
|
+
let t = t0;
|
|
368
|
+
if (t < 0) t += 1;
|
|
369
|
+
if (t > 1) t -= 1;
|
|
370
|
+
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
371
|
+
if (t < 1 / 2) return q;
|
|
372
|
+
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
373
|
+
return p;
|
|
374
|
+
};
|
|
375
|
+
return [
|
|
376
|
+
Math.round(channel(h + 1 / 3) * 255),
|
|
377
|
+
Math.round(channel(h) * 255),
|
|
378
|
+
Math.round(channel(h - 1 / 3) * 255)
|
|
379
|
+
];
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Map a palette color onto the dark ramp: hue is kept, saturation is
|
|
383
|
+
* compressed by {@link DARK_SATURATION_SCALE}, and lightness is clamped to
|
|
384
|
+
* `lightness`. The compression is not optional polish: HSL saturation at dark
|
|
385
|
+
* lightness reads far stronger for warm hues (gold / rose / peach) than for
|
|
386
|
+
* blue-grays on a dark canvas, so the raw values made most families glare.
|
|
387
|
+
* Invalid input degrades to a neutral gray at the same lightness.
|
|
388
|
+
*/
|
|
389
|
+
function toDarkRamp(hex, lightness) {
|
|
390
|
+
const l = Math.max(0, Math.min(1, lightness));
|
|
391
|
+
const [h, s] = rgbToHsl(hexToRgb(hex));
|
|
392
|
+
const [r, g, b] = hslToRgb(h, Math.max(0, Math.min(1, s * DARK_SATURATION_SCALE)), l);
|
|
393
|
+
return "#" + [
|
|
394
|
+
r,
|
|
395
|
+
g,
|
|
396
|
+
b
|
|
397
|
+
].map((v) => v.toString(16).padStart(2, "0")).join("");
|
|
398
|
+
}
|
|
399
|
+
/** Body-canvas lightness for the dark variant of a palette family. */
|
|
400
|
+
const DARK_CANVAS_LIGHTNESS = .12;
|
|
401
|
+
/** How much of a family's HSL saturation survives on the dark ramp. 0.55
|
|
402
|
+
* keeps the families clearly distinguishable while pulling the warm hues
|
|
403
|
+
* (gold / rose / peach) down from "eye-catching" to "ambient" on the dark
|
|
404
|
+
* canvas; 0.4 turned them into mud, 0.7 still glared. */
|
|
405
|
+
const DARK_SATURATION_SCALE = .55;
|
|
198
406
|
//#endregion
|
|
199
407
|
//#region src/client/api.ts
|
|
200
408
|
/**
|
|
@@ -607,7 +815,7 @@ window.__ModuleLoader__.load({
|
|
|
607
815
|
const STATIC_CSS = `/* dsh-custom-plugin static styles. Every rule is global by design: the UI
|
|
608
816
|
* mounts into product slots and overlays, so class names are prefixed vx-
|
|
609
817
|
* and must not be scoped by CSS Modules. Dynamic rules (body background,
|
|
610
|
-
*
|
|
818
|
+
* global-glass blur) are managed at runtime by a style
|
|
611
819
|
* element in custom.tsx and do not live here. */
|
|
612
820
|
.vx-root {
|
|
613
821
|
position: fixed;
|
|
@@ -670,16 +878,40 @@ window.__ModuleLoader__.load({
|
|
|
670
878
|
color: #eef1f7;
|
|
671
879
|
}
|
|
672
880
|
}
|
|
881
|
+
/* Liquid glass: the SVG displacement filter bends the backdrop at the
|
|
882
|
+
surface's edges; the chained blur+saturate keeps text over the middle of
|
|
883
|
+
large panels readable (pure displacement leaves the mid-area untouched,
|
|
884
|
+
which read as "nothing happened"). Chromium runs this chain; engines
|
|
885
|
+
without SVG-referencing backdrop filters fall back to frost below. */
|
|
673
886
|
.vx-liquid .vx-glass {
|
|
674
|
-
background: rgba(255, 255, 255, .
|
|
675
|
-
backdrop-filter: url(#vx-lg);
|
|
676
|
-
-webkit-backdrop-filter: url(#vx-lg);
|
|
887
|
+
background: rgba(255, 255, 255, .1);
|
|
888
|
+
backdrop-filter: url(#vx-lg) blur(2.5px) saturate(1.12);
|
|
889
|
+
-webkit-backdrop-filter: url(#vx-lg) blur(2.5px) saturate(1.12);
|
|
677
890
|
}
|
|
678
891
|
@media (prefers-color-scheme: dark) {
|
|
679
892
|
.vx-liquid .vx-glass {
|
|
680
|
-
background: rgba(0, 0, 0, .
|
|
893
|
+
background: rgba(0, 0, 0, .1);
|
|
681
894
|
}
|
|
682
895
|
}
|
|
896
|
+
/* The GUI theme classes are mirrored onto <html> by the client, so the
|
|
897
|
+
liquid fill has to out-rank the theme frost fills *inside* .vx-root as
|
|
898
|
+
well. The previous ".vx-root.* .vx-liquid .vx-glass" rules never matched
|
|
899
|
+
anything — vx-liquid lives on <html>, an ANCESTOR of .vx-root, not a
|
|
900
|
+
descendant — which left the big panels at the 64% frost fill while the
|
|
901
|
+
balance hover (mounted outside .vx-root) sat at 10%: the "panel is not
|
|
902
|
+
liquid, the balance card is" report, verbatim. */
|
|
903
|
+
:root.vx-liquid.vx-dark .vx-glass {
|
|
904
|
+
background: rgba(0, 0, 0, .1);
|
|
905
|
+
}
|
|
906
|
+
:root.vx-liquid.vx-light .vx-glass {
|
|
907
|
+
background: rgba(255, 255, 255, .1);
|
|
908
|
+
}
|
|
909
|
+
:root.vx-liquid .vx-root.vx-dark .vx-glass {
|
|
910
|
+
background: rgba(0, 0, 0, .1);
|
|
911
|
+
}
|
|
912
|
+
:root.vx-liquid .vx-root.vx-light .vx-glass {
|
|
913
|
+
background: rgba(255, 255, 255, .1);
|
|
914
|
+
}
|
|
683
915
|
@supports not (backdrop-filter: url(#vx-lg)) {
|
|
684
916
|
.vx-liquid .vx-glass {
|
|
685
917
|
background: rgba(255, 255, 255, .64);
|
|
@@ -692,158 +924,6 @@ window.__ModuleLoader__.load({
|
|
|
692
924
|
}
|
|
693
925
|
}
|
|
694
926
|
}
|
|
695
|
-
.vx-liquid .vx-pattern {
|
|
696
|
-
background-image: radial-gradient(rgba(150, 150, 160, .5) 3px, transparent 3px);
|
|
697
|
-
background-size: 24px 24px;
|
|
698
|
-
-webkit-mask-image: radial-gradient(ellipse at top, transparent 20%, black);
|
|
699
|
-
mask-image: radial-gradient(ellipse at top, transparent 20%, black);
|
|
700
|
-
animation: vx-pattern-move 25000ms linear infinite;
|
|
701
|
-
}
|
|
702
|
-
@media (prefers-color-scheme: dark) {
|
|
703
|
-
.vx-liquid .vx-pattern {
|
|
704
|
-
background-image: radial-gradient(rgba(110, 110, 128, .5) 3px, transparent 3px);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
.vx-pattern {
|
|
708
|
-
position: absolute;
|
|
709
|
-
inset: 0;
|
|
710
|
-
pointer-events: none;
|
|
711
|
-
z-index: -1;
|
|
712
|
-
background-image: radial-gradient(rgba(150, 150, 160, .42) 1px, transparent 1px);
|
|
713
|
-
background-size: 24px 24px;
|
|
714
|
-
-webkit-mask-image: radial-gradient(ellipse at center, transparent 30%, black 100%);
|
|
715
|
-
mask-image: radial-gradient(ellipse at center, transparent 30%, black 100%);
|
|
716
|
-
animation: vx-pattern-move 10000ms linear infinite;
|
|
717
|
-
}
|
|
718
|
-
@media (prefers-color-scheme: dark) {
|
|
719
|
-
.vx-pattern {
|
|
720
|
-
background-image: radial-gradient(rgba(100, 100, 116, .5) 1px, transparent 1px);
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
@keyframes vx-pattern-move {
|
|
724
|
-
from {
|
|
725
|
-
background-position: 0 0;
|
|
726
|
-
}
|
|
727
|
-
to {
|
|
728
|
-
background-position: 0 24px;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
@keyframes vx-aurora {
|
|
732
|
-
0% {
|
|
733
|
-
background-position: 0% 50%;
|
|
734
|
-
}
|
|
735
|
-
50% {
|
|
736
|
-
background-position: 100% 50%;
|
|
737
|
-
}
|
|
738
|
-
100% {
|
|
739
|
-
background-position: 0% 50%;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
.vx-rail {
|
|
743
|
-
position: absolute;
|
|
744
|
-
width: 12px;
|
|
745
|
-
border-radius: 8px;
|
|
746
|
-
background: rgba(120, 130, 150, .18);
|
|
747
|
-
border: 1px solid rgba(120, 130, 150, .25);
|
|
748
|
-
pointer-events: auto;
|
|
749
|
-
touch-action: none;
|
|
750
|
-
box-sizing: border-box;
|
|
751
|
-
}
|
|
752
|
-
.vx-rail.right {
|
|
753
|
-
right: 4px;
|
|
754
|
-
}
|
|
755
|
-
.vx-rail.left {
|
|
756
|
-
left: 56px;
|
|
757
|
-
}
|
|
758
|
-
/* When the rail is active it substitutes the native scrollbar: the scrollport
|
|
759
|
-
carrying the vx-rail-scroller class (added by the client when it resolves
|
|
760
|
-
the chat scrollport) hides its own bar so only one scroll affordance
|
|
761
|
-
remains. scrollbar-gutter: stable on the shell keeps the layout width. */
|
|
762
|
-
.vx-rail-scroller {
|
|
763
|
-
scrollbar-width: none;
|
|
764
|
-
}
|
|
765
|
-
.vx-rail-scroller::-webkit-scrollbar {
|
|
766
|
-
display: none;
|
|
767
|
-
}
|
|
768
|
-
.vx-thumb {
|
|
769
|
-
position: absolute;
|
|
770
|
-
left: 1px;
|
|
771
|
-
right: 1px;
|
|
772
|
-
border-radius: 8px;
|
|
773
|
-
background: rgba(90, 105, 135, .5);
|
|
774
|
-
border: 1px solid rgba(255, 255, 255, .35);
|
|
775
|
-
box-sizing: border-box;
|
|
776
|
-
}
|
|
777
|
-
.vx-thumb:hover {
|
|
778
|
-
background: rgba(90, 105, 135, .7);
|
|
779
|
-
}
|
|
780
|
-
.vx-dot {
|
|
781
|
-
position: absolute;
|
|
782
|
-
left: 50%;
|
|
783
|
-
transform: translate(-50%, -50%);
|
|
784
|
-
width: 10px;
|
|
785
|
-
height: 10px;
|
|
786
|
-
border-radius: 50%;
|
|
787
|
-
background: rgba(70, 85, 110, .92);
|
|
788
|
-
border: 2px solid rgba(255, 255, 255, .92);
|
|
789
|
-
box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
|
|
790
|
-
pointer-events: auto;
|
|
791
|
-
cursor: pointer;
|
|
792
|
-
transition: transform .12s;
|
|
793
|
-
padding: 0;
|
|
794
|
-
}
|
|
795
|
-
.vx-dot:hover {
|
|
796
|
-
transform: translate(-50%, -50%) scale(1.35);
|
|
797
|
-
}
|
|
798
|
-
.vx-dot.star {
|
|
799
|
-
background: #c9a24b;
|
|
800
|
-
border-color: #f3e3bd;
|
|
801
|
-
}
|
|
802
|
-
@media (prefers-color-scheme: dark) {
|
|
803
|
-
.vx-dot {
|
|
804
|
-
background: rgba(205, 215, 230, .95);
|
|
805
|
-
border-color: rgba(28, 34, 46, .9);
|
|
806
|
-
}
|
|
807
|
-
.vx-thumb {
|
|
808
|
-
background: rgba(165, 180, 205, .45);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
.vx-rail-pop {
|
|
812
|
-
position: absolute;
|
|
813
|
-
pointer-events: auto;
|
|
814
|
-
padding: 10px 12px;
|
|
815
|
-
width: 300px;
|
|
816
|
-
font-size: 12px;
|
|
817
|
-
line-height: 1.55;
|
|
818
|
-
z-index: 5;
|
|
819
|
-
}
|
|
820
|
-
/* Class = which side the rail sits on; the card must open toward the page
|
|
821
|
-
content. It is a child of the 12px-wide rail, so right:20px puts it left
|
|
822
|
-
of the rail and left:20px puts it right (20px = rail width + 8px gap). */
|
|
823
|
-
.vx-rail-pop.right {
|
|
824
|
-
right: 20px;
|
|
825
|
-
}
|
|
826
|
-
.vx-rail-pop.left {
|
|
827
|
-
left: 20px;
|
|
828
|
-
}
|
|
829
|
-
.vx-pop-time {
|
|
830
|
-
color: #6d7689;
|
|
831
|
-
font-size: 11px;
|
|
832
|
-
margin-bottom: 4px;
|
|
833
|
-
}
|
|
834
|
-
.vx-pop-text {
|
|
835
|
-
white-space: pre-wrap;
|
|
836
|
-
word-break: break-word;
|
|
837
|
-
max-height: 150px;
|
|
838
|
-
overflow: hidden;
|
|
839
|
-
margin-bottom: 8px;
|
|
840
|
-
}
|
|
841
|
-
.vx-pop-row {
|
|
842
|
-
display: flex;
|
|
843
|
-
gap: 5px;
|
|
844
|
-
flex-wrap: wrap;
|
|
845
|
-
align-items: center;
|
|
846
|
-
}
|
|
847
927
|
.vx-balance-wrap {
|
|
848
928
|
display: inline-flex;
|
|
849
929
|
align-items: center;
|
|
@@ -865,17 +945,10 @@ window.__ModuleLoader__.load({
|
|
|
865
945
|
.vx-balance-text:hover {
|
|
866
946
|
background: rgba(127, 164, 224, .28);
|
|
867
947
|
}
|
|
868
|
-
.vx-balance-text.vx-balance-
|
|
948
|
+
.vx-balance-text.vx-balance-open {
|
|
869
949
|
background: rgba(127, 164, 224, .36);
|
|
870
950
|
border-color: rgba(127, 164, 224, .8);
|
|
871
951
|
}
|
|
872
|
-
.vx-balance-head {
|
|
873
|
-
display: flex;
|
|
874
|
-
align-items: center;
|
|
875
|
-
justify-content: space-between;
|
|
876
|
-
gap: 8px;
|
|
877
|
-
margin-bottom: 8px;
|
|
878
|
-
}
|
|
879
952
|
.vx-balance-today {
|
|
880
953
|
opacity: .75;
|
|
881
954
|
font-size: 11.5px;
|
|
@@ -1491,204 +1564,62 @@ window.__ModuleLoader__.load({
|
|
|
1491
1564
|
}
|
|
1492
1565
|
.vx-mmd-stage svg {
|
|
1493
1566
|
max-width: 100%;
|
|
1494
|
-
height: auto;
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
/* DSH can select a theme independently of the operating system. The root
|
|
1498
|
-
classes are applied from the resolved GUI theme and intentionally win
|
|
1499
|
-
over the media-query fallback above. */
|
|
1500
|
-
.vx-root.vx-dark .vx-glass {
|
|
1501
|
-
background: rgba(13, 17, 25, .62);
|
|
1502
|
-
color: #eef1f7;
|
|
1503
|
-
}
|
|
1504
|
-
.vx-root.vx-dark .vx-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
.vx-root.vx-dark .vx-
|
|
1508
|
-
|
|
1509
|
-
}
|
|
1510
|
-
.vx-root.vx-dark .vx-
|
|
1511
|
-
background
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
.vx-root.vx-
|
|
1521
|
-
.vx-root.vx-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
.vx-root.vx-light .vx-balance-hover,
|
|
1551
|
-
.vx-root.vx-light .vx-panel,
|
|
1552
|
-
.vx-root.vx-light .vx-modal,
|
|
1553
|
-
.vx-root.vx-light .vx-folders {
|
|
1554
|
-
color: #20242e;
|
|
1555
|
-
}
|
|
1556
|
-
.vx-root.vx-light .vx-toast {
|
|
1557
|
-
background: rgba(26, 32, 44, .92);
|
|
1558
|
-
}
|
|
1559
|
-
}`;
|
|
1560
|
-
//#endregion
|
|
1561
|
-
//#region src/client/custom.tsx
|
|
1562
|
-
/**
|
|
1563
|
-
* Browser half of dsh-custom-plugin: the Custom convenience suite UI.
|
|
1564
|
-
*
|
|
1565
|
-
* A single mutable store (`S`) drives every surface through a lightweight
|
|
1566
|
-
* listener set; components re-render on `setS`. The file ports the earlier
|
|
1567
|
-
* dynamic-plugin implementation: React is a platform import, static styles
|
|
1568
|
-
* are injected through one owned style element (styles.ts), dynamic body
|
|
1569
|
-
* styles (background / aurora / global glass) extend it, and host calls go
|
|
1570
|
-
* over `/api/custom-plugin` fetch routes.
|
|
1571
|
-
* @module @alexpeng/dsh-custom-plugin/client/custom
|
|
1572
|
-
*/
|
|
1573
|
-
/**
|
|
1574
|
-
* dsh's shipped web profile configures the session index with `openAt: never`,
|
|
1575
|
-
* so cross-session full-text search can legitimately be unavailable. Say what
|
|
1576
|
-
* still works instead of leaving a bare error that reads as a broken palette.
|
|
1577
|
-
*/
|
|
1578
|
-
const CROSS_SEARCH_UNAVAILABLE = "跨会话全文搜索不可用;下方结果仍按标题匹配会话与工作区。";
|
|
1579
|
-
function fmtClock(time) {
|
|
1580
|
-
const d = new Date(time);
|
|
1581
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
1582
|
-
return `${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
1583
|
-
}
|
|
1584
|
-
function formatTokenCount(value) {
|
|
1585
|
-
return Math.round(value).toLocaleString("zh-CN");
|
|
1586
|
-
}
|
|
1587
|
-
/** Palette of 20 muted low-saturation backgrounds (with matching tab colors).
|
|
1588
|
-
* 天青灰 leads the list: it is the install default and renders first among
|
|
1589
|
-
* the palette swatches, right after 无颜色 / 极光. */
|
|
1590
|
-
const PALETTE = [
|
|
1591
|
-
[
|
|
1592
|
-
"天青灰",
|
|
1593
|
-
"#E9EBEE",
|
|
1594
|
-
"#D6DADF"
|
|
1595
|
-
],
|
|
1596
|
-
[
|
|
1597
|
-
"暖象牙",
|
|
1598
|
-
"#F5F0E8",
|
|
1599
|
-
"#E8E0D4"
|
|
1600
|
-
],
|
|
1601
|
-
[
|
|
1602
|
-
"雾灰绿",
|
|
1603
|
-
"#E9EDE6",
|
|
1604
|
-
"#D7DED3"
|
|
1605
|
-
],
|
|
1606
|
-
[
|
|
1607
|
-
"烟熏玫瑰",
|
|
1608
|
-
"#F2EAEC",
|
|
1609
|
-
"#E5D6DA"
|
|
1610
|
-
],
|
|
1611
|
-
[
|
|
1612
|
-
"雾蓝",
|
|
1613
|
-
"#E8EDF2",
|
|
1614
|
-
"#D4DDE6"
|
|
1615
|
-
],
|
|
1616
|
-
[
|
|
1617
|
-
"薰衣草灰",
|
|
1618
|
-
"#EFEDF4",
|
|
1619
|
-
"#E0DCEB"
|
|
1620
|
-
],
|
|
1621
|
-
[
|
|
1622
|
-
"燕麦米",
|
|
1623
|
-
"#F3EEE6",
|
|
1624
|
-
"#E5DED3"
|
|
1625
|
-
],
|
|
1626
|
-
[
|
|
1627
|
-
"薄荷雾",
|
|
1628
|
-
"#EAF0ED",
|
|
1629
|
-
"#D7E3DC"
|
|
1630
|
-
],
|
|
1631
|
-
[
|
|
1632
|
-
"裸桃",
|
|
1633
|
-
"#F5EDE8",
|
|
1634
|
-
"#E8DCD4"
|
|
1635
|
-
],
|
|
1636
|
-
[
|
|
1637
|
-
"石板蓝",
|
|
1638
|
-
"#E6EDF1",
|
|
1639
|
-
"#D2DBE3"
|
|
1640
|
-
],
|
|
1641
|
-
[
|
|
1642
|
-
"紫藤灰",
|
|
1643
|
-
"#EEEBF2",
|
|
1644
|
-
"#E1DAE8"
|
|
1645
|
-
],
|
|
1646
|
-
[
|
|
1647
|
-
"奶油黄",
|
|
1648
|
-
"#F4F0E6",
|
|
1649
|
-
"#E6E1D5"
|
|
1650
|
-
],
|
|
1651
|
-
[
|
|
1652
|
-
"鼠尾草",
|
|
1653
|
-
"#EAEDE5",
|
|
1654
|
-
"#D7DED1"
|
|
1655
|
-
],
|
|
1656
|
-
[
|
|
1657
|
-
"腮红粉",
|
|
1658
|
-
"#F3EAEC",
|
|
1659
|
-
"#E6D6DA"
|
|
1660
|
-
],
|
|
1661
|
-
[
|
|
1662
|
-
"香草白",
|
|
1663
|
-
"#F3F0E6",
|
|
1664
|
-
"#E5E0D4"
|
|
1665
|
-
],
|
|
1666
|
-
[
|
|
1667
|
-
"青灰",
|
|
1668
|
-
"#E7F0F0",
|
|
1669
|
-
"#D3E1E1"
|
|
1670
|
-
],
|
|
1671
|
-
[
|
|
1672
|
-
"杏仁白",
|
|
1673
|
-
"#F0ECE8",
|
|
1674
|
-
"#E2DAD3"
|
|
1675
|
-
],
|
|
1676
|
-
[
|
|
1677
|
-
"尤加利",
|
|
1678
|
-
"#EAF0ED",
|
|
1679
|
-
"#D7E3DB"
|
|
1680
|
-
],
|
|
1681
|
-
[
|
|
1682
|
-
"珍珠灰",
|
|
1683
|
-
"#EDEDEE",
|
|
1684
|
-
"#DCDCDD"
|
|
1685
|
-
],
|
|
1686
|
-
[
|
|
1687
|
-
"淡金",
|
|
1688
|
-
"#F4F1E4",
|
|
1689
|
-
"#E6E1D0"
|
|
1690
|
-
]
|
|
1691
|
-
];
|
|
1567
|
+
height: auto;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
/* DSH can select a theme independently of the operating system. The root
|
|
1571
|
+
classes are applied from the resolved GUI theme and intentionally win
|
|
1572
|
+
over the media-query fallback above. */
|
|
1573
|
+
.vx-root.vx-dark .vx-glass {
|
|
1574
|
+
background: rgba(13, 17, 25, .62);
|
|
1575
|
+
color: #eef1f7;
|
|
1576
|
+
}
|
|
1577
|
+
.vx-root.vx-dark .vx-balance-hover,
|
|
1578
|
+
.vx-root.vx-dark .vx-panel,
|
|
1579
|
+
.vx-root.vx-dark .vx-modal,
|
|
1580
|
+
.vx-root.vx-dark .vx-folders {
|
|
1581
|
+
color: #e8ebf2;
|
|
1582
|
+
}
|
|
1583
|
+
.vx-root.vx-dark .vx-toast {
|
|
1584
|
+
background: rgba(18, 22, 30, .94);
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
.vx-root.vx-light .vx-glass {
|
|
1588
|
+
background: rgba(255, 255, 255, .64);
|
|
1589
|
+
color: #20242e;
|
|
1590
|
+
}
|
|
1591
|
+
.vx-root.vx-light .vx-balance-hover,
|
|
1592
|
+
.vx-root.vx-light .vx-panel,
|
|
1593
|
+
.vx-root.vx-light .vx-modal,
|
|
1594
|
+
.vx-root.vx-light .vx-folders {
|
|
1595
|
+
color: #20242e;
|
|
1596
|
+
}
|
|
1597
|
+
.vx-root.vx-light .vx-toast {
|
|
1598
|
+
background: rgba(26, 32, 44, .92);
|
|
1599
|
+
}
|
|
1600
|
+
}`;
|
|
1601
|
+
//#endregion
|
|
1602
|
+
//#region src/client/custom.tsx
|
|
1603
|
+
/**
|
|
1604
|
+
* Browser half of dsh-custom-plugin: the Custom convenience suite UI.
|
|
1605
|
+
*
|
|
1606
|
+
* A single mutable store (`S`) drives every surface through a lightweight
|
|
1607
|
+
* listener set; components re-render on `setS`. The file ports the earlier
|
|
1608
|
+
* dynamic-plugin implementation: React is a platform import, static styles
|
|
1609
|
+
* are injected through one owned style element (styles.ts), dynamic body
|
|
1610
|
+
* styles (background / global glass) extend it, and host calls go
|
|
1611
|
+
* over `/api/custom-plugin` fetch routes.
|
|
1612
|
+
* @module @alexpeng/dsh-custom-plugin/client/custom
|
|
1613
|
+
*/
|
|
1614
|
+
/**
|
|
1615
|
+
* dsh's shipped web profile configures the session index with `openAt: never`,
|
|
1616
|
+
* so cross-session full-text search can legitimately be unavailable. Say what
|
|
1617
|
+
* still works instead of leaving a bare error that reads as a broken palette.
|
|
1618
|
+
*/
|
|
1619
|
+
const CROSS_SEARCH_UNAVAILABLE = "跨会话全文搜索不可用;下方结果仍按标题匹配会话与工作区。";
|
|
1620
|
+
function formatTokenCount(value) {
|
|
1621
|
+
return Math.round(value).toLocaleString("zh-CN");
|
|
1622
|
+
}
|
|
1692
1623
|
/** Neutral glass tokens used when no palette color is active. */
|
|
1693
1624
|
const NEUTRAL_TOKENS = {
|
|
1694
1625
|
"--dsw-alias-bg-base": {
|
|
@@ -1763,20 +1694,6 @@ window.__ModuleLoader__.load({
|
|
|
1763
1694
|
sessionId: null,
|
|
1764
1695
|
turns: null,
|
|
1765
1696
|
anchors: /* @__PURE__ */ new Map(),
|
|
1766
|
-
seqAnchor: /* @__PURE__ */ new Map(),
|
|
1767
|
-
railPositions: [],
|
|
1768
|
-
railSig: "",
|
|
1769
|
-
railHover: null,
|
|
1770
|
-
railHoverTimer: null,
|
|
1771
|
-
railBox: {
|
|
1772
|
-
top: 64,
|
|
1773
|
-
height: 600
|
|
1774
|
-
},
|
|
1775
|
-
railRight: 4,
|
|
1776
|
-
railLeft: 56,
|
|
1777
|
-
thumbTop: 0,
|
|
1778
|
-
thumbH: 26,
|
|
1779
|
-
scrollerEl: null,
|
|
1780
1697
|
panelOpen: false,
|
|
1781
1698
|
panelTab: "look",
|
|
1782
1699
|
panelPos: null,
|
|
@@ -1787,6 +1704,7 @@ window.__ModuleLoader__.load({
|
|
|
1787
1704
|
dropHint: null,
|
|
1788
1705
|
promptOpen: null,
|
|
1789
1706
|
promptQuery: "",
|
|
1707
|
+
balanceOpen: false,
|
|
1790
1708
|
batchModal: false,
|
|
1791
1709
|
mermaidModal: null,
|
|
1792
1710
|
quoteSel: null,
|
|
@@ -1860,13 +1778,9 @@ window.__ModuleLoader__.load({
|
|
|
1860
1778
|
sessionScopeHolders++;
|
|
1861
1779
|
if (S.sessionId !== id) {
|
|
1862
1780
|
S.anchors.clear();
|
|
1863
|
-
S.seqAnchor.clear();
|
|
1864
1781
|
setS({
|
|
1865
1782
|
sessionId: id,
|
|
1866
|
-
turns: null
|
|
1867
|
-
railPositions: [],
|
|
1868
|
-
railSig: "",
|
|
1869
|
-
railHover: null
|
|
1783
|
+
turns: null
|
|
1870
1784
|
});
|
|
1871
1785
|
fetchTurns(id);
|
|
1872
1786
|
}
|
|
@@ -1874,13 +1788,9 @@ window.__ModuleLoader__.load({
|
|
|
1874
1788
|
sessionScopeHolders--;
|
|
1875
1789
|
if (sessionScopeHolders === 0 && S.sessionId === id) {
|
|
1876
1790
|
S.anchors.clear();
|
|
1877
|
-
S.seqAnchor.clear();
|
|
1878
1791
|
setS({
|
|
1879
1792
|
sessionId: null,
|
|
1880
|
-
turns: null
|
|
1881
|
-
railPositions: [],
|
|
1882
|
-
railSig: "",
|
|
1883
|
-
railHover: null
|
|
1793
|
+
turns: null
|
|
1884
1794
|
});
|
|
1885
1795
|
}
|
|
1886
1796
|
};
|
|
@@ -2405,14 +2315,14 @@ window.__ModuleLoader__.load({
|
|
|
2405
2315
|
tokenDisposer = null;
|
|
2406
2316
|
}
|
|
2407
2317
|
if (theme !== void 0 && typeof theme.overrideTokens === "function") {
|
|
2408
|
-
if (cfg.bg !== void 0 && cfg.bg !== "default"
|
|
2318
|
+
if (cfg.bg !== void 0 && cfg.bg !== "default") {
|
|
2409
2319
|
const entry = PALETTE.find((p) => p[0] === cfg.bg) ?? PALETTE[0];
|
|
2410
2320
|
const base = entry[1];
|
|
2411
2321
|
const tab = entry[2] ?? shade(base, .94);
|
|
2412
2322
|
const glassOn = cfg.glass === true;
|
|
2413
2323
|
const mk = (c, a) => glassOn ? rgbaOf(c, a) : c;
|
|
2414
|
-
const darkBase =
|
|
2415
|
-
const darkTab =
|
|
2324
|
+
const darkBase = toDarkRamp(base, .14);
|
|
2325
|
+
const darkTab = toDarkRamp(tab, .18);
|
|
2416
2326
|
tokenDisposer = theme.overrideTokens("custom-plugin-appearance", {
|
|
2417
2327
|
"--dsw-alias-bg-base": {
|
|
2418
2328
|
light: mk(base, .5),
|
|
@@ -2435,18 +2345,18 @@ window.__ModuleLoader__.load({
|
|
|
2435
2345
|
dark: mk(darkTab, .62)
|
|
2436
2346
|
}
|
|
2437
2347
|
});
|
|
2438
|
-
} else if (cfg.glass === true
|
|
2348
|
+
} else if (cfg.glass === true) tokenDisposer = theme.overrideTokens("custom-plugin-appearance", NEUTRAL_TOKENS);
|
|
2439
2349
|
}
|
|
2440
2350
|
let dyn = "";
|
|
2441
|
-
if (cfg.bg
|
|
2442
|
-
dyn += "@keyframes vx-aurora { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }";
|
|
2443
|
-
dyn += " body { background: linear-gradient(120deg, #8fa8d8, #b59fd8, #8fc4b4, #d8a8c0) !important; background-size: 320% 320% !important; animation: vx-aurora 26s ease infinite !important; }";
|
|
2444
|
-
dyn += " body[data-ds-dark-theme] [data-conversation-scroll] > :has([data-conversation-composer-overlay]) { background: transparent !important; }";
|
|
2445
|
-
} else if (cfg.bg !== void 0 && cfg.bg !== "default") {
|
|
2351
|
+
if (cfg.bg !== void 0 && cfg.bg !== "default") {
|
|
2446
2352
|
const base = (PALETTE.find((p) => p[0] === cfg.bg) ?? PALETTE[0])[1];
|
|
2447
|
-
|
|
2353
|
+
const surface = S.dark === true ? toDarkRamp(base, DARK_CANVAS_LIGHTNESS) : base;
|
|
2354
|
+
dyn += ` body { background-color: ${surface} !important; }`;
|
|
2355
|
+
}
|
|
2356
|
+
if (cfg.globalGlass === true) {
|
|
2357
|
+
const filter = cfg.glass === true && cfg.glassMode === "liquid" && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("backdrop-filter", "url(#vx-lg)") ? "url(#vx-lg) blur(2.5px) saturate(1.12)" : "blur(8px) saturate(1.2)";
|
|
2358
|
+
dyn += ` [role='dialog'], [role='menu'], [role='tooltip'], [role='listbox'], [data-radix-popper-content-wrapper] { backdrop-filter: ${filter} !important; -webkit-backdrop-filter: ${filter} !important; }`;
|
|
2448
2359
|
}
|
|
2449
|
-
if (cfg.globalGlass === true) dyn += " [role='dialog'], [role='menu'], [role='tooltip'], [role='listbox'], [data-radix-popper-content-wrapper] { backdrop-filter: blur(8px) saturate(1.2) !important; -webkit-backdrop-filter: blur(8px) saturate(1.2) !important; }";
|
|
2450
2360
|
setDynCss(dyn);
|
|
2451
2361
|
}
|
|
2452
2362
|
function syncAntiScroll(on) {
|
|
@@ -2468,7 +2378,14 @@ window.__ModuleLoader__.load({
|
|
|
2468
2378
|
}
|
|
2469
2379
|
} catch {}
|
|
2470
2380
|
}
|
|
2381
|
+
const LOAD_RETRY_DELAYS = [
|
|
2382
|
+
1500,
|
|
2383
|
+
3e3,
|
|
2384
|
+
6e3
|
|
2385
|
+
];
|
|
2386
|
+
let loadCfgAttempt = 0;
|
|
2471
2387
|
async function loadCfg() {
|
|
2388
|
+
let failure = null;
|
|
2472
2389
|
try {
|
|
2473
2390
|
const result = await apiStateGet();
|
|
2474
2391
|
if (result.ok === true && result.data !== void 0) {
|
|
@@ -2480,6 +2397,10 @@ window.__ModuleLoader__.load({
|
|
|
2480
2397
|
};
|
|
2481
2398
|
delete cfg.clouds;
|
|
2482
2399
|
delete cfg.wind;
|
|
2400
|
+
delete cfg.timeline;
|
|
2401
|
+
delete cfg.timelineLeft;
|
|
2402
|
+
delete cfg.starsOnly;
|
|
2403
|
+
if (cfg.bg === "aurora") cfg.bg = "default";
|
|
2483
2404
|
S.cfg = cfg;
|
|
2484
2405
|
}
|
|
2485
2406
|
if (Array.isArray(data.folders)) S.folders = data.folders;
|
|
@@ -2488,13 +2409,26 @@ window.__ModuleLoader__.load({
|
|
|
2488
2409
|
if (typeof data.apiKeyConfigured === "boolean") S.apiKeyConfigured = data.apiKeyConfigured;
|
|
2489
2410
|
if (data.credentialStorage === "system" || data.credentialStorage === "legacy-state" || data.credentialStorage === "environment" || data.credentialStorage === "dsh" || data.credentialStorage === "none") S.credentialStorage = data.credentialStorage;
|
|
2490
2411
|
if (data.usage !== void 0 && data.usage !== null && typeof data.usage === "object") S.usage = data.usage;
|
|
2491
|
-
|
|
2492
|
-
|
|
2412
|
+
loadCfgAttempt = 0;
|
|
2413
|
+
} else if (result.ok !== true) failure = result.error ?? "状态读取失败";
|
|
2414
|
+
} catch (error) {
|
|
2415
|
+
failure = String(error?.message ?? error);
|
|
2416
|
+
}
|
|
2417
|
+
if (failure !== null) {
|
|
2418
|
+
apiDiagReport("loadCfg: " + failure);
|
|
2419
|
+
if (loadCfgAttempt < LOAD_RETRY_DELAYS.length) {
|
|
2420
|
+
const delay = LOAD_RETRY_DELAYS[loadCfgAttempt];
|
|
2421
|
+
loadCfgAttempt++;
|
|
2422
|
+
setTimeout(() => {
|
|
2423
|
+
loadCfg();
|
|
2424
|
+
}, delay);
|
|
2425
|
+
} else if (S.booted) toast("配置读取失败:" + failure, "error");
|
|
2426
|
+
}
|
|
2493
2427
|
S.booted = true;
|
|
2494
2428
|
setS({});
|
|
2495
2429
|
if (!S.greeted) {
|
|
2496
2430
|
S.greeted = true;
|
|
2497
|
-
new Promise((resolve) => setTimeout(resolve, 1200)).then(() => toast("Custom 便利套件已就绪", "info")).catch(() => {});
|
|
2431
|
+
new Promise((resolve) => setTimeout(resolve, 1200)).then(() => toast(failure !== null ? "Custom 便利套件加载失败:" + failure : "Custom 便利套件已就绪", failure !== null ? "error" : "info")).catch(() => {});
|
|
2498
2432
|
}
|
|
2499
2433
|
}
|
|
2500
2434
|
function saveCfg() {
|
|
@@ -2511,7 +2445,9 @@ window.__ModuleLoader__.load({
|
|
|
2511
2445
|
};
|
|
2512
2446
|
apiStateSave(edit).then((result) => {
|
|
2513
2447
|
if (result.ok !== true) {
|
|
2514
|
-
|
|
2448
|
+
const message = result.error ?? "设置保存失败";
|
|
2449
|
+
apiDiagReport("saveCfg: " + message);
|
|
2450
|
+
toast(message, "error");
|
|
2515
2451
|
return;
|
|
2516
2452
|
}
|
|
2517
2453
|
if (keyDirty && S.apiKeyDirty && S.apiKey === (edit.apiKey ?? "")) setS({
|
|
@@ -2519,8 +2455,10 @@ window.__ModuleLoader__.load({
|
|
|
2519
2455
|
apiKeyConfigured: result.apiKeyConfigured ?? S.apiKey.trim() !== "",
|
|
2520
2456
|
credentialStorage: result.credentialStorage ?? S.credentialStorage
|
|
2521
2457
|
});
|
|
2522
|
-
}).catch(() => {
|
|
2523
|
-
|
|
2458
|
+
}).catch((error) => {
|
|
2459
|
+
const message = String(error?.message ?? error);
|
|
2460
|
+
apiDiagReport("saveCfg: " + message);
|
|
2461
|
+
toast("设置保存失败:" + message, "error");
|
|
2524
2462
|
});
|
|
2525
2463
|
}
|
|
2526
2464
|
const FX = {
|
|
@@ -2849,13 +2787,12 @@ window.__ModuleLoader__.load({
|
|
|
2849
2787
|
function FxCanvas() {
|
|
2850
2788
|
const s = useS();
|
|
2851
2789
|
const ref = react.useRef(null);
|
|
2852
|
-
/**
|
|
2853
|
-
*
|
|
2854
|
-
|
|
2855
|
-
const lightRef = react.useRef(!(s.dark === true) || s.cfg.bg === "aurora");
|
|
2790
|
+
/** 粒子配色跟随背景亮度:浅色主题需要更深的粒子颜色才可辨识。
|
|
2791
|
+
* ref 让 RAF 循环每帧读到最新值,主题/背景切换时无需重建粒子场。 */
|
|
2792
|
+
const lightRef = react.useRef(!(s.dark === true));
|
|
2856
2793
|
react.useEffect(() => {
|
|
2857
|
-
lightRef.current = !(s.dark === true)
|
|
2858
|
-
}, [s.dark
|
|
2794
|
+
lightRef.current = !(s.dark === true);
|
|
2795
|
+
}, [s.dark]);
|
|
2859
2796
|
react.useEffect(() => {
|
|
2860
2797
|
const cvs = ref.current;
|
|
2861
2798
|
if (cvs === null) return;
|
|
@@ -2889,9 +2826,7 @@ window.__ModuleLoader__.load({
|
|
|
2889
2826
|
className: "vx-fx"
|
|
2890
2827
|
});
|
|
2891
2828
|
}
|
|
2892
|
-
let lastRefetchAt = 0;
|
|
2893
2829
|
let turnsRequestSerial = 0;
|
|
2894
|
-
let railRefetchRows = -1;
|
|
2895
2830
|
const diagAtByKey = /* @__PURE__ */ new Map();
|
|
2896
2831
|
function diagThrottled(message) {
|
|
2897
2832
|
const key = message.slice(0, 24);
|
|
@@ -2901,12 +2836,6 @@ window.__ModuleLoader__.load({
|
|
|
2901
2836
|
diagAtByKey.set(key, now);
|
|
2902
2837
|
reportDiag(message);
|
|
2903
2838
|
}
|
|
2904
|
-
function scheduleTurnsRefetch() {
|
|
2905
|
-
const now = Date.now();
|
|
2906
|
-
if (now - lastRefetchAt < 2e3) return;
|
|
2907
|
-
lastRefetchAt = now;
|
|
2908
|
-
fetchTurns(S.sessionId);
|
|
2909
|
-
}
|
|
2910
2839
|
async function fetchTurns(sessionId) {
|
|
2911
2840
|
const requestSerial = ++turnsRequestSerial;
|
|
2912
2841
|
try {
|
|
@@ -2918,7 +2847,6 @@ window.__ModuleLoader__.load({
|
|
|
2918
2847
|
items: result.items ?? []
|
|
2919
2848
|
};
|
|
2920
2849
|
setS({ turns: S.turns });
|
|
2921
|
-
updateRailPositions();
|
|
2922
2850
|
diagThrottled("timeline " + (result.items?.length ?? 0) + " items " + sessionId.slice(0, 24));
|
|
2923
2851
|
} else diagThrottled("timeline failed: " + String(result.error ?? "unknown"));
|
|
2924
2852
|
} catch (error) {
|
|
@@ -2961,130 +2889,19 @@ window.__ModuleLoader__.load({
|
|
|
2961
2889
|
}
|
|
2962
2890
|
return null;
|
|
2963
2891
|
}
|
|
2964
|
-
/**
|
|
2965
|
-
*
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
return Array.from(scroller.querySelectorAll("[data-chat-flow-kind=\"user\"], [data-chat-flow-kind=\"steering\"]"));
|
|
2969
|
-
} catch {
|
|
2970
|
-
return [];
|
|
2971
|
-
}
|
|
2972
|
-
}
|
|
2973
|
-
/** Keep the rail-scroller class on exactly the current scrollport so the
|
|
2974
|
-
* native scrollbar hides only for the column the rail substitutes. */
|
|
2975
|
-
function syncRailScrollerClass(scroller) {
|
|
2976
|
-
const previous = S.scrollerEl;
|
|
2977
|
-
if (previous !== null && previous !== scroller) try {
|
|
2978
|
-
previous.classList.remove("vx-rail-scroller");
|
|
2979
|
-
} catch {}
|
|
2980
|
-
if (scroller !== null && scroller !== previous) try {
|
|
2981
|
-
scroller.classList.add("vx-rail-scroller");
|
|
2982
|
-
} catch {}
|
|
2983
|
-
}
|
|
2984
|
-
function updateRailPositions() {
|
|
2985
|
-
if (S.cfg.timeline !== true || S.sessionId === null) {
|
|
2986
|
-
syncRailScrollerClass(null);
|
|
2987
|
-
if (S.railPositions.length > 0 || S.thumbTop !== 0 || S.thumbH !== 26) setS({
|
|
2988
|
-
railPositions: [],
|
|
2989
|
-
railSig: "",
|
|
2990
|
-
railBox: {
|
|
2991
|
-
top: 64,
|
|
2992
|
-
height: 600
|
|
2993
|
-
},
|
|
2994
|
-
railRight: 4,
|
|
2995
|
-
railLeft: 56,
|
|
2996
|
-
thumbTop: 0,
|
|
2997
|
-
thumbH: 26,
|
|
2998
|
-
scrollerEl: null
|
|
2999
|
-
});
|
|
3000
|
-
return;
|
|
3001
|
-
}
|
|
3002
|
-
const w = typeof window !== "undefined" ? window : null;
|
|
3003
|
-
if (w === null) return;
|
|
3004
|
-
if (S.turns === null || S.turns.sessionId !== S.sessionId) {
|
|
3005
|
-
railRefetchRows = -1;
|
|
3006
|
-
scheduleTurnsRefetch();
|
|
3007
|
-
}
|
|
3008
|
-
const items = S.turns !== null && Array.isArray(S.turns.items) ? S.turns.items : [];
|
|
3009
|
-
let scroller = S.scrollerEl;
|
|
3010
|
-
if (scroller === null || !scroller.isConnected) scroller = resolveScroller();
|
|
3011
|
-
syncRailScrollerClass(scroller);
|
|
3012
|
-
const vh = w.innerHeight || 800;
|
|
3013
|
-
let top = 64;
|
|
3014
|
-
let height = vh - 64 - 120;
|
|
3015
|
-
let scrollH = Math.max(1, height);
|
|
3016
|
-
let scrollTop = 0;
|
|
3017
|
-
let viewH = height;
|
|
3018
|
-
let railRight = 4;
|
|
3019
|
-
let railLeft = 56;
|
|
3020
|
-
let scrollerRect = null;
|
|
3021
|
-
if (scroller !== null) try {
|
|
3022
|
-
const r = scroller.getBoundingClientRect();
|
|
3023
|
-
scrollerRect = r;
|
|
3024
|
-
top = Math.max(0, r.top);
|
|
3025
|
-
height = Math.max(60, r.height);
|
|
3026
|
-
viewH = Math.max(1, scroller.clientHeight || r.height);
|
|
3027
|
-
scrollH = Math.max(viewH, scroller.scrollHeight || viewH);
|
|
3028
|
-
scrollTop = Math.max(0, scroller.scrollTop || 0);
|
|
3029
|
-
railRight = Math.max(2, Math.round(w.innerWidth - r.right + 4));
|
|
3030
|
-
railLeft = Math.max(2, Math.round(r.left + 4));
|
|
3031
|
-
} catch {}
|
|
3032
|
-
const trackH = height;
|
|
3033
|
-
const pos = [];
|
|
3034
|
-
const seqAnchor = /* @__PURE__ */ new Map();
|
|
3035
|
-
if (scroller !== null && scrollerRect !== null) {
|
|
3036
|
-
const rows = queryUserRows(scroller);
|
|
3037
|
-
const offset = items.length - rows.length;
|
|
3038
|
-
if (rows.length > items.length && railRefetchRows < rows.length) {
|
|
3039
|
-
railRefetchRows = rows.length;
|
|
3040
|
-
scheduleTurnsRefetch();
|
|
3041
|
-
}
|
|
3042
|
-
for (let i = 0; i < rows.length; i++) {
|
|
3043
|
-
const item = offset + i >= 0 ? items[offset + i] : void 0;
|
|
3044
|
-
if (item === void 0) continue;
|
|
3045
|
-
try {
|
|
3046
|
-
const r = rows[i].getBoundingClientRect();
|
|
3047
|
-
const pct = Math.max(0, Math.min(1, (r.top + r.height / 2 - scrollerRect.top + scrollTop) / Math.max(1, scroller.scrollHeight || 1)));
|
|
3048
|
-
const starred = S.stars[S.sessionId]?.[item.seq] === true;
|
|
3049
|
-
seqAnchor.set(item.seq, rows[i]);
|
|
3050
|
-
pos.push({
|
|
3051
|
-
seq: item.seq,
|
|
3052
|
-
y: Math.round(pct * trackH),
|
|
3053
|
-
st: starred
|
|
3054
|
-
});
|
|
3055
|
-
} catch {}
|
|
3056
|
-
}
|
|
3057
|
-
}
|
|
3058
|
-
const thumbH = Math.max(26, Math.round(trackH * (viewH / scrollH)));
|
|
3059
|
-
const thumbTop = scrollTop / Math.max(1, scrollH - viewH) * (trackH - thumbH);
|
|
3060
|
-
const sig = JSON.stringify(pos) + "|" + thumbTop + "|" + thumbH + "|" + top + "|" + height + "|" + railRight + "|" + railLeft;
|
|
3061
|
-
S.seqAnchor = seqAnchor;
|
|
3062
|
-
if (sig !== S.railSig) {
|
|
3063
|
-
setS({
|
|
3064
|
-
railPositions: pos,
|
|
3065
|
-
railSig: sig,
|
|
3066
|
-
railBox: {
|
|
3067
|
-
top,
|
|
3068
|
-
height
|
|
3069
|
-
},
|
|
3070
|
-
railRight,
|
|
3071
|
-
railLeft,
|
|
3072
|
-
thumbTop: Math.round(thumbTop),
|
|
3073
|
-
thumbH,
|
|
3074
|
-
scrollerEl: scroller
|
|
3075
|
-
});
|
|
3076
|
-
diagThrottled("rail " + pos.length + " dots / anchors " + S.anchors.size + " / turns " + items.length + " / scroller " + (scroller === null ? "none" : scroller.tagName.toLowerCase() + "." + String(scroller.className ?? "").slice(0, 60)));
|
|
3077
|
-
}
|
|
3078
|
-
}
|
|
2892
|
+
/** Scroll the rendered message row for `seq` to the viewport center. The
|
|
2893
|
+
* element comes from the turnTail anchor map (our own chips register it);
|
|
2894
|
+
* the scrollport is resolved at call time from the shell's semantic
|
|
2895
|
+
* attribute, with scrollIntoView as the fallback. */
|
|
3079
2896
|
function scrollToSeq(seq) {
|
|
3080
|
-
const el = S.
|
|
3081
|
-
if (el ===
|
|
2897
|
+
const el = S.anchors.get(seq)?.el ?? null;
|
|
2898
|
+
if (el === null) {
|
|
3082
2899
|
toast("该消息尚未渲染,请稍后重试", "error");
|
|
3083
2900
|
return;
|
|
3084
2901
|
}
|
|
3085
|
-
const scroller =
|
|
2902
|
+
const scroller = resolveScroller();
|
|
3086
2903
|
let done = false;
|
|
3087
|
-
if (scroller !== null
|
|
2904
|
+
if (scroller !== null) try {
|
|
3088
2905
|
const er = el.getBoundingClientRect();
|
|
3089
2906
|
const sr = scroller.getBoundingClientRect();
|
|
3090
2907
|
const floor = Math.max(0, (scroller.scrollHeight ?? 0) - (scroller.clientHeight ?? 0));
|
|
@@ -3102,43 +2919,6 @@ window.__ModuleLoader__.load({
|
|
|
3102
2919
|
el.scrollIntoView(true);
|
|
3103
2920
|
} catch {}
|
|
3104
2921
|
}
|
|
3105
|
-
setS({ railHover: null });
|
|
3106
|
-
}
|
|
3107
|
-
function toggleStar(seq) {
|
|
3108
|
-
const sid = S.sessionId;
|
|
3109
|
-
if (sid === null) return;
|
|
3110
|
-
const next = { ...S.stars[sid] ?? {} };
|
|
3111
|
-
if (next[seq] === true) delete next[seq];
|
|
3112
|
-
else next[seq] = true;
|
|
3113
|
-
const stars = { ...S.stars };
|
|
3114
|
-
stars[sid] = next;
|
|
3115
|
-
setS({ stars });
|
|
3116
|
-
saveCfg();
|
|
3117
|
-
updateRailPositions();
|
|
3118
|
-
}
|
|
3119
|
-
async function forkAt(seq) {
|
|
3120
|
-
const remote = sessionRemote();
|
|
3121
|
-
if (remote === void 0) {
|
|
3122
|
-
toast("分支不可用:会话 Remote 服务缺失", "error");
|
|
3123
|
-
return;
|
|
3124
|
-
}
|
|
3125
|
-
try {
|
|
3126
|
-
const result = await remote.fork({
|
|
3127
|
-
sessionId: S.sessionId,
|
|
3128
|
-
atSeq: seq
|
|
3129
|
-
});
|
|
3130
|
-
if (!result.ok) {
|
|
3131
|
-
toast("创建分支失败: " + remoteErrorMessage(result.error, "未知错误"), "error");
|
|
3132
|
-
return;
|
|
3133
|
-
}
|
|
3134
|
-
const childId = result.value.sessionId;
|
|
3135
|
-
toast("分支会话已创建", "info", {
|
|
3136
|
-
label: "打开分支",
|
|
3137
|
-
run: () => openSessionItem(childId)
|
|
3138
|
-
});
|
|
3139
|
-
} catch (error) {
|
|
3140
|
-
toast("创建分支失败: " + String(error?.message ?? error), "error");
|
|
3141
|
-
}
|
|
3142
2922
|
}
|
|
3143
2923
|
function extractLatex(text) {
|
|
3144
2924
|
const out = [];
|
|
@@ -3441,11 +3221,18 @@ window.__ModuleLoader__.load({
|
|
|
3441
3221
|
delete block.dataset.vxMmdFail;
|
|
3442
3222
|
}
|
|
3443
3223
|
}
|
|
3224
|
+
let balanceRetryTimer = null;
|
|
3225
|
+
let balanceRetries = 0;
|
|
3444
3226
|
async function refreshBalance() {
|
|
3227
|
+
if (balanceRetryTimer !== null) {
|
|
3228
|
+
clearTimeout(balanceRetryTimer);
|
|
3229
|
+
balanceRetryTimer = null;
|
|
3230
|
+
}
|
|
3445
3231
|
try {
|
|
3446
3232
|
const result = await apiBalanceGet();
|
|
3447
3233
|
S.balance = result;
|
|
3448
3234
|
S.apiKeyConfigured = result.keyConfigured === true;
|
|
3235
|
+
balanceRetries = 0;
|
|
3449
3236
|
const usageToday = result.usageToday;
|
|
3450
3237
|
if (usageToday !== void 0 && usageToday !== null && typeof usageToday === "object") {
|
|
3451
3238
|
S.usage = { ...S.usage };
|
|
@@ -3462,10 +3249,20 @@ window.__ModuleLoader__.load({
|
|
|
3462
3249
|
} catch (error) {
|
|
3463
3250
|
S.balance = {
|
|
3464
3251
|
ok: false,
|
|
3252
|
+
keyConfigured: S.apiKeyConfigured === true,
|
|
3465
3253
|
error: String(error?.message ?? error)
|
|
3466
3254
|
};
|
|
3467
3255
|
setS({ balance: S.balance });
|
|
3468
3256
|
}
|
|
3257
|
+
const failed = S.balance.ok === false;
|
|
3258
|
+
const keyPresent = S.balance.keyConfigured === true;
|
|
3259
|
+
if (failed && keyPresent && balanceRetries < 3) {
|
|
3260
|
+
balanceRetries++;
|
|
3261
|
+
balanceRetryTimer = setTimeout(() => {
|
|
3262
|
+
balanceRetryTimer = null;
|
|
3263
|
+
refreshBalance();
|
|
3264
|
+
}, balanceRetries === 1 ? 8e3 : 3e4);
|
|
3265
|
+
}
|
|
3469
3266
|
}
|
|
3470
3267
|
async function refreshUsageScan() {
|
|
3471
3268
|
try {
|
|
@@ -3631,7 +3428,9 @@ window.__ModuleLoader__.load({
|
|
|
3631
3428
|
title: "项目文件夹",
|
|
3632
3429
|
onClick: () => setS({
|
|
3633
3430
|
foldersOpen: !S.foldersOpen,
|
|
3634
|
-
panelOpen: false
|
|
3431
|
+
panelOpen: false,
|
|
3432
|
+
promptOpen: null,
|
|
3433
|
+
balanceOpen: false
|
|
3635
3434
|
})
|
|
3636
3435
|
}, react.createElement(Icon, {
|
|
3637
3436
|
n: "folder",
|
|
@@ -3645,7 +3444,9 @@ window.__ModuleLoader__.load({
|
|
|
3645
3444
|
title: "个性化中心",
|
|
3646
3445
|
onClick: () => setS({
|
|
3647
3446
|
panelOpen: !S.panelOpen,
|
|
3648
|
-
foldersOpen: false
|
|
3447
|
+
foldersOpen: false,
|
|
3448
|
+
promptOpen: null,
|
|
3449
|
+
balanceOpen: false
|
|
3649
3450
|
})
|
|
3650
3451
|
}, react.createElement(Icon, {
|
|
3651
3452
|
n: "sliders",
|
|
@@ -3658,13 +3459,17 @@ window.__ModuleLoader__.load({
|
|
|
3658
3459
|
className: "vx-header-btn",
|
|
3659
3460
|
title: "快速调用提示词",
|
|
3660
3461
|
onClick: (e) => {
|
|
3462
|
+
const open = S.promptOpen !== null;
|
|
3661
3463
|
const r = e.currentTarget.getBoundingClientRect();
|
|
3662
3464
|
setS({
|
|
3663
|
-
promptOpen: {
|
|
3465
|
+
promptOpen: open ? null : {
|
|
3664
3466
|
x: Math.max(8, r.left),
|
|
3665
3467
|
y: r.bottom + 6
|
|
3666
3468
|
},
|
|
3667
|
-
promptQuery: ""
|
|
3469
|
+
promptQuery: "",
|
|
3470
|
+
panelOpen: false,
|
|
3471
|
+
foldersOpen: false,
|
|
3472
|
+
balanceOpen: false
|
|
3668
3473
|
});
|
|
3669
3474
|
}
|
|
3670
3475
|
}, react.createElement(Icon, {
|
|
@@ -3684,7 +3489,7 @@ window.__ModuleLoader__.load({
|
|
|
3684
3489
|
left: p.x,
|
|
3685
3490
|
top: p.y
|
|
3686
3491
|
}
|
|
3687
|
-
}, react.createElement("div", { className: "vx-
|
|
3492
|
+
}, react.createElement("div", { className: "vx-pop-head" }, react.createElement("span", null, "提示词库"), react.createElement("button", {
|
|
3688
3493
|
className: "vx-chip",
|
|
3689
3494
|
title: "关闭",
|
|
3690
3495
|
onClick: () => setS({ promptOpen: null })
|
|
@@ -3710,8 +3515,6 @@ window.__ModuleLoader__.load({
|
|
|
3710
3515
|
useViewedSession(props);
|
|
3711
3516
|
const s = useS();
|
|
3712
3517
|
const b = s.balance;
|
|
3713
|
-
const [hover, setHover] = react.useState(false);
|
|
3714
|
-
const [pinned, setPinned] = react.useState(false);
|
|
3715
3518
|
react.useEffect(() => {
|
|
3716
3519
|
if (S.balance === null) refreshBalance();
|
|
3717
3520
|
const timer = setInterval(() => {
|
|
@@ -3723,27 +3526,27 @@ window.__ModuleLoader__.load({
|
|
|
3723
3526
|
}, []);
|
|
3724
3527
|
const usageToday = s.usage[dayKey()] ?? {};
|
|
3725
3528
|
const calls = Object.keys(usageToday).reduce((n, k) => n + (usageToday[k].calls ?? 0), 0);
|
|
3529
|
+
const estimate = Object.entries(usageToday).reduce((sum, [model, row]) => sum + estimateUsageCostCny(row, model), 0);
|
|
3726
3530
|
const bal = b?.ok === true && b.balance !== null && b.balance !== void 0 ? b.balance : null;
|
|
3727
|
-
const
|
|
3728
|
-
const
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
}, react.createElement("span", {
|
|
3734
|
-
className: "vx-balance-text" + (
|
|
3735
|
-
title:
|
|
3736
|
-
onClick: () =>
|
|
3531
|
+
const keyConfigured = b?.ok === false && b.keyConfigured === true;
|
|
3532
|
+
const balance = bal !== null ? (bal.currency ?? "CNY") === "CNY" ? "¥" + (bal.total ?? "") : `${bal.total ?? ""} ${bal.currency ?? ""}` : keyConfigured ? "额度" : b === null ? "额度…" : `≈¥${estimate.toFixed(2)}`;
|
|
3533
|
+
const estimateTitle = `按本机 token 用量与官方价目表折算的估算值(${DEEPSEEK_PRICING_CHECKED_ON} 核对),非账号账单;配置 API Key 后显示真实余额`;
|
|
3534
|
+
const balanceError = keyConfigured && b?.ok === false ? String(b.error ?? "未知错误") : null;
|
|
3535
|
+
const pillTitle = bal !== null ? void 0 : balanceError !== null ? `余额查询失败:${balanceError}(失败后会自动重试,也可在面板中手动刷新)` : b === null ? void 0 : estimateTitle;
|
|
3536
|
+
const open = s.balanceOpen === true;
|
|
3537
|
+
return react.createElement("span", { className: "vx-balance-wrap" }, react.createElement("span", {
|
|
3538
|
+
className: "vx-balance-text" + (open ? " vx-balance-open" : ""),
|
|
3539
|
+
title: open ? "再次点击收起面板" : "点击打开面板",
|
|
3540
|
+
onClick: () => setS({
|
|
3541
|
+
balanceOpen: !open,
|
|
3542
|
+
panelOpen: false,
|
|
3543
|
+
promptOpen: null,
|
|
3544
|
+
foldersOpen: false
|
|
3545
|
+
})
|
|
3737
3546
|
}, react.createElement(Icon, {
|
|
3738
3547
|
n: "wallet",
|
|
3739
3548
|
size: 13
|
|
3740
|
-
}), react.createElement("span",
|
|
3741
|
-
className: "vx-btn vx-btn-sm",
|
|
3742
|
-
onClick: () => setPinned(false)
|
|
3743
|
-
}, react.createElement(Icon, {
|
|
3744
|
-
n: "x",
|
|
3745
|
-
size: 12
|
|
3746
|
-
}), " 取消固定")) : null, react.createElement(BalancePanelContent, { onInteract: () => setPinned(true) })) : null);
|
|
3549
|
+
}), react.createElement("span", { title: pillTitle }, balance), calls > 0 ? react.createElement("span", { className: "vx-balance-today" }, `今日 ${calls} 次`) : null), open ? react.createElement("div", { className: "vx-glass vx-balance-hover" }, react.createElement(BalancePanelContent, null)) : null);
|
|
3747
3550
|
}
|
|
3748
3551
|
function UsageTable() {
|
|
3749
3552
|
const day = useS().usage[dayKey()] ?? {};
|
|
@@ -3856,17 +3659,31 @@ window.__ModuleLoader__.load({
|
|
|
3856
3659
|
onBlur: saveCfg
|
|
3857
3660
|
}), " %")));
|
|
3858
3661
|
}
|
|
3859
|
-
function BalancePanelContent(
|
|
3662
|
+
function BalancePanelContent() {
|
|
3860
3663
|
const s = useS();
|
|
3861
3664
|
const b = s.balance;
|
|
3862
|
-
|
|
3665
|
+
const configured = s.apiKeyConfigured === true;
|
|
3666
|
+
const [balanceOpen, setBalanceOpen] = react.useState(configured);
|
|
3667
|
+
const keyConfigured = b?.ok === false && b.keyConfigured === true;
|
|
3668
|
+
return react.createElement("div", { className: "vx-col" }, react.createElement("div", { className: "vx-muted" }, "以下用量与费用全部来自本机会话记录,不需要 API Key;费用为按官方价目表折算的估算值,可能与账号账单有差异。"), react.createElement("div", { className: "vx-section-title" }, "用量趋势与预算"), react.createElement(UsageHistory, null), react.createElement("div", { className: "vx-section-title" }, "今日模型明细"), react.createElement(UsageTable, null), react.createElement("button", {
|
|
3669
|
+
className: "vx-btn",
|
|
3670
|
+
onClick: () => {
|
|
3671
|
+
refreshUsageScan();
|
|
3672
|
+
}
|
|
3673
|
+
}, react.createElement(Icon, {
|
|
3674
|
+
n: "list",
|
|
3675
|
+
size: 13
|
|
3676
|
+
}), " 扫描今日会话日志更新用量"), react.createElement("div", { className: "vx-row" }, react.createElement("button", {
|
|
3677
|
+
className: "vx-chip",
|
|
3678
|
+
onClick: () => setBalanceOpen(!balanceOpen)
|
|
3679
|
+
}, react.createElement(Icon, {
|
|
3680
|
+
n: balanceOpen ? "chevronDown" : "chevronRight",
|
|
3681
|
+
size: 11
|
|
3682
|
+
}), balanceOpen ? " 收起余额查询" : " 余额查询(可选,需要 API Key)")), balanceOpen ? react.createElement("div", { className: "vx-col" }, react.createElement("div", { className: "vx-row" }, react.createElement("input", {
|
|
3863
3683
|
className: "vx-input",
|
|
3864
3684
|
type: "password",
|
|
3865
|
-
placeholder:
|
|
3685
|
+
placeholder: configured ? "已配置 Key;输入新 Key 覆盖" : "DeepSeek API Key (sk-…)",
|
|
3866
3686
|
value: s.apiKey,
|
|
3867
|
-
onFocus: () => {
|
|
3868
|
-
props.onInteract?.();
|
|
3869
|
-
},
|
|
3870
3687
|
onChange: (e) => {
|
|
3871
3688
|
setS({
|
|
3872
3689
|
apiKey: e.target.value,
|
|
@@ -3889,19 +3706,11 @@ window.__ModuleLoader__.load({
|
|
|
3889
3706
|
}, react.createElement(Icon, {
|
|
3890
3707
|
n: "refresh",
|
|
3891
3708
|
size: 13
|
|
3892
|
-
}), " 刷新")), react.createElement("div", { className: "vx-muted" }, `Key 不回传浏览器;当前来源:${s.credentialStorage === "system" ? "系统凭据" : s.credentialStorage === "legacy-state" ? "旧状态文件(待迁移)" : s.credentialStorage === "environment" ? "环境变量" : s.credentialStorage === "dsh" ? "DSH 凭据" : "未配置"}。留空后保存可清除插件自定义 Key。`), b !== null && b.ok === true && b.balance !== null && b.balance !== void 0 ? (() => {
|
|
3709
|
+
}), " 刷新")), react.createElement("div", { className: "vx-muted" }, configured ? `Key 不回传浏览器;当前来源:${s.credentialStorage === "system" ? "系统凭据" : s.credentialStorage === "legacy-state" ? "旧状态文件(待迁移)" : s.credentialStorage === "environment" ? "环境变量" : s.credentialStorage === "dsh" ? "DSH 凭据" : "未配置"}。留空后保存可清除插件自定义 Key。` : "填写 sk- 开头的 DeepSeek API Key 即可查询官方余额;Key 不回传浏览器,留空保存可清除已存 Key。"), b !== null && b.ok === true && b.balance !== null && b.balance !== void 0 ? (() => {
|
|
3893
3710
|
const info = b.balance;
|
|
3894
3711
|
const sym = (info.currency ?? "CNY") === "CNY" ? "¥" : `${info.currency ?? ""} `;
|
|
3895
3712
|
return react.createElement("div", { className: "vx-balance-lines" }, react.createElement("div", null, `可用额度: ${sym}${info.total ?? ""}`), react.createElement("div", { className: "vx-muted" }, `赠送 ${sym}${info.granted ?? ""} · 充值 ${sym}${info.toppedUp ?? ""}${b.available === false ? " · 余额不足不可用" : ""}`));
|
|
3896
|
-
})() : null, b !== null && b.ok === false ? react.createElement("div", { className: "vx-error" }, String(b.error ?? "未知错误")) : null
|
|
3897
|
-
className: "vx-btn",
|
|
3898
|
-
onClick: () => {
|
|
3899
|
-
refreshUsageScan();
|
|
3900
|
-
}
|
|
3901
|
-
}, react.createElement(Icon, {
|
|
3902
|
-
n: "list",
|
|
3903
|
-
size: 13
|
|
3904
|
-
}), " 扫描今日会话日志更新用量"));
|
|
3713
|
+
})() : null, keyConfigured && b !== null && b.ok === false ? react.createElement("div", { className: "vx-error" }, String(b.error ?? "未知错误")) : null) : null);
|
|
3905
3714
|
}
|
|
3906
3715
|
function QuoteDock(props) {
|
|
3907
3716
|
useViewedSession(props);
|
|
@@ -4052,177 +3861,6 @@ window.__ModuleLoader__.load({
|
|
|
4052
3861
|
}
|
|
4053
3862
|
}, btns.length > 0 ? react.createElement("span", { className: "vx-turn-actions" }, btns) : null);
|
|
4054
3863
|
}
|
|
4055
|
-
function RailPopover() {
|
|
4056
|
-
const s = useS();
|
|
4057
|
-
const h = s.railHover;
|
|
4058
|
-
const popRef = react.useRef(null);
|
|
4059
|
-
react.useLayoutEffect(() => {
|
|
4060
|
-
const el = popRef.current;
|
|
4061
|
-
if (el === null || h === null) return;
|
|
4062
|
-
const rail = el.parentElement;
|
|
4063
|
-
if (rail === null) return;
|
|
4064
|
-
const base = Math.max(8, h.y - 90);
|
|
4065
|
-
el.style.top = base + "px";
|
|
4066
|
-
const over = el.offsetTop + el.offsetHeight - rail.clientHeight;
|
|
4067
|
-
if (over > 0) el.style.top = Math.max(8, base - over) + "px";
|
|
4068
|
-
}, [h?.seq, h?.y]);
|
|
4069
|
-
if (h === null) return null;
|
|
4070
|
-
const item = s.turns !== null && Array.isArray(s.turns.items) ? s.turns.items.find((x) => x.seq === h.seq) ?? null : null;
|
|
4071
|
-
if (item === null) return null;
|
|
4072
|
-
const starred = S.sessionId !== null && s.stars[S.sessionId]?.[h.seq] === true;
|
|
4073
|
-
const side = s.cfg.timelineLeft === true ? "left" : "right";
|
|
4074
|
-
return react.createElement("div", {
|
|
4075
|
-
ref: (el) => {
|
|
4076
|
-
popRef.current = el;
|
|
4077
|
-
},
|
|
4078
|
-
className: `vx-glass vx-rail-pop ${side}`,
|
|
4079
|
-
style: { top: Math.max(8, h.y - 90) },
|
|
4080
|
-
onMouseEnter: () => {
|
|
4081
|
-
if (S.railHoverTimer !== null) {
|
|
4082
|
-
clearTimeout(S.railHoverTimer);
|
|
4083
|
-
S.railHoverTimer = null;
|
|
4084
|
-
}
|
|
4085
|
-
},
|
|
4086
|
-
onMouseLeave: () => {
|
|
4087
|
-
S.railHoverTimer = setTimeout(() => setS({ railHover: null }), 350);
|
|
4088
|
-
}
|
|
4089
|
-
}, react.createElement("div", { className: "vx-pattern" }), react.createElement("div", { className: "vx-pop-time" }, `${fmtClock(item.time)} · 第 ${item.turn ?? "?"} 轮${item.imageCount > 0 ? ` · ${item.imageCount} 张图片` : ""}`), react.createElement("div", { className: "vx-pop-text" }, item.text.slice(0, 220) + (item.text.length > 220 ? "…" : "")), react.createElement("div", { className: "vx-pop-row" }, react.createElement("button", {
|
|
4090
|
-
className: "vx-chip",
|
|
4091
|
-
onClick: () => scrollToSeq(h.seq)
|
|
4092
|
-
}, react.createElement(Icon, {
|
|
4093
|
-
n: "arrowDown",
|
|
4094
|
-
size: 11
|
|
4095
|
-
}), " 跳转"), react.createElement("button", {
|
|
4096
|
-
className: "vx-chip",
|
|
4097
|
-
onClick: () => toggleStar(h.seq)
|
|
4098
|
-
}, react.createElement(Icon, {
|
|
4099
|
-
n: "star",
|
|
4100
|
-
size: 11,
|
|
4101
|
-
filled: starred
|
|
4102
|
-
}), starred ? " 已星标" : " 星标"), react.createElement("button", {
|
|
4103
|
-
className: "vx-chip",
|
|
4104
|
-
onClick: () => void forkAt(h.seq)
|
|
4105
|
-
}, react.createElement(Icon, {
|
|
4106
|
-
n: "fork",
|
|
4107
|
-
size: 11
|
|
4108
|
-
}), " 分支"), react.createElement("button", {
|
|
4109
|
-
className: "vx-chip",
|
|
4110
|
-
onClick: () => void copyText(item.text).then((ok) => toast(ok ? "已复制全文" : "复制失败", ok ? "info" : "error"))
|
|
4111
|
-
}, react.createElement(Icon, {
|
|
4112
|
-
n: "copy",
|
|
4113
|
-
size: 11
|
|
4114
|
-
}), " 全文")), item.hasLatex === true || item.hasMathml === true || item.hasMermaid === true ? react.createElement("div", { className: "vx-pop-row" }, item.hasLatex === true ? react.createElement("button", {
|
|
4115
|
-
className: "vx-chip",
|
|
4116
|
-
onClick: () => void copyLatexOf(item)
|
|
4117
|
-
}, "LaTeX") : null, item.hasMathml === true ? react.createElement("button", {
|
|
4118
|
-
className: "vx-chip",
|
|
4119
|
-
onClick: () => void copyMathmlOf(item)
|
|
4120
|
-
}, "MathML") : null, item.hasMermaid === true ? react.createElement("button", {
|
|
4121
|
-
className: "vx-chip",
|
|
4122
|
-
onClick: () => openMermaidOf(item)
|
|
4123
|
-
}, "Mermaid") : null) : null);
|
|
4124
|
-
}
|
|
4125
|
-
function TimelineRail(props) {
|
|
4126
|
-
const s = useS();
|
|
4127
|
-
const sessions = useSessionsSafe(props);
|
|
4128
|
-
const summary = sessions !== null && s.sessionId !== null ? sessions.byId[s.sessionId] : null;
|
|
4129
|
-
const trackRef = react.useRef(null);
|
|
4130
|
-
react.useEffect(() => {
|
|
4131
|
-
if (s.cfg.timeline !== true || S.sessionId === null) return;
|
|
4132
|
-
const running = summary?.running === true;
|
|
4133
|
-
const handle = setInterval(() => {
|
|
4134
|
-
if (running) fetchTurns(S.sessionId);
|
|
4135
|
-
}, 3e3);
|
|
4136
|
-
return () => clearInterval(handle);
|
|
4137
|
-
}, [
|
|
4138
|
-
s.cfg.timeline,
|
|
4139
|
-
s.sessionId,
|
|
4140
|
-
summary?.running
|
|
4141
|
-
]);
|
|
4142
|
-
react.useEffect(() => {
|
|
4143
|
-
if (s.cfg.timeline !== true || S.sessionId === null) return;
|
|
4144
|
-
const el = trackRef.current;
|
|
4145
|
-
if (el === null) return;
|
|
4146
|
-
const fromPopover = (e) => e.target instanceof Element && e.target.closest(".vx-rail-pop") !== null;
|
|
4147
|
-
const down = (e) => {
|
|
4148
|
-
const scroller = S.scrollerEl;
|
|
4149
|
-
if (scroller === null || !scroller.isConnected) return;
|
|
4150
|
-
if (fromPopover(e)) return;
|
|
4151
|
-
e.preventDefault();
|
|
4152
|
-
const rect = el.getBoundingClientRect();
|
|
4153
|
-
const startY = e.clientY;
|
|
4154
|
-
const startScroll = scroller.scrollTop ?? 0;
|
|
4155
|
-
const scrollH = Math.max(1, (scroller.scrollHeight ?? 1) - (scroller.clientHeight ?? rect.height));
|
|
4156
|
-
const onMove = (ev) => {
|
|
4157
|
-
const delta = (ev.clientY - startY) / Math.max(1, rect.height) * scrollH;
|
|
4158
|
-
scroller.scrollTop = Math.max(0, Math.min(scrollH, startScroll + delta));
|
|
4159
|
-
};
|
|
4160
|
-
const onUp = () => {
|
|
4161
|
-
const w = typeof window !== "undefined" ? window : null;
|
|
4162
|
-
if (w !== null) {
|
|
4163
|
-
w.removeEventListener("pointermove", onMove);
|
|
4164
|
-
w.removeEventListener("pointerup", onUp);
|
|
4165
|
-
}
|
|
4166
|
-
};
|
|
4167
|
-
const w = typeof window !== "undefined" ? window : null;
|
|
4168
|
-
if (w !== null) {
|
|
4169
|
-
w.addEventListener("pointermove", onMove);
|
|
4170
|
-
w.addEventListener("pointerup", onUp);
|
|
4171
|
-
}
|
|
4172
|
-
};
|
|
4173
|
-
el.addEventListener("pointerdown", down);
|
|
4174
|
-
const onWheel = (e) => {
|
|
4175
|
-
const scroller = S.scrollerEl;
|
|
4176
|
-
if (scroller === null || !scroller.isConnected) return;
|
|
4177
|
-
if (fromPopover(e)) return;
|
|
4178
|
-
e.preventDefault();
|
|
4179
|
-
const floor = Math.max(0, (scroller.scrollHeight ?? 1) - (scroller.clientHeight ?? 0));
|
|
4180
|
-
scroller.scrollTop = Math.max(0, Math.min(floor, (scroller.scrollTop ?? 0) + (e.deltaY || 0)));
|
|
4181
|
-
};
|
|
4182
|
-
el.addEventListener("wheel", onWheel, { passive: false });
|
|
4183
|
-
return () => {
|
|
4184
|
-
el.removeEventListener("pointerdown", down);
|
|
4185
|
-
el.removeEventListener("wheel", onWheel);
|
|
4186
|
-
};
|
|
4187
|
-
}, [
|
|
4188
|
-
s.cfg.timeline,
|
|
4189
|
-
s.sessionId,
|
|
4190
|
-
s.scrollerEl
|
|
4191
|
-
]);
|
|
4192
|
-
if (s.cfg.timeline !== true || S.sessionId === null) return null;
|
|
4193
|
-
const right = s.cfg.timelineLeft !== true;
|
|
4194
|
-
const dots = s.railPositions.filter((p) => s.cfg.starsOnly !== true || p.st);
|
|
4195
|
-
return react.createElement("div", {
|
|
4196
|
-
ref: trackRef,
|
|
4197
|
-
className: `vx-rail ${right ? "right" : "left"}`,
|
|
4198
|
-
style: {
|
|
4199
|
-
top: s.railBox.top,
|
|
4200
|
-
height: s.railBox.height,
|
|
4201
|
-
...right ? { right: s.railRight } : { left: s.railLeft }
|
|
4202
|
-
}
|
|
4203
|
-
}, react.createElement("div", {
|
|
4204
|
-
className: "vx-thumb",
|
|
4205
|
-
style: {
|
|
4206
|
-
top: s.thumbTop,
|
|
4207
|
-
height: s.thumbH
|
|
4208
|
-
}
|
|
4209
|
-
}), dots.map((p) => react.createElement("button", {
|
|
4210
|
-
key: p.seq,
|
|
4211
|
-
className: "vx-dot" + (p.st ? " star" : ""),
|
|
4212
|
-
style: { top: p.y },
|
|
4213
|
-
onMouseEnter: () => {
|
|
4214
|
-
if (S.railHoverTimer !== null) clearTimeout(S.railHoverTimer);
|
|
4215
|
-
setS({ railHover: {
|
|
4216
|
-
seq: p.seq,
|
|
4217
|
-
y: p.y
|
|
4218
|
-
} });
|
|
4219
|
-
},
|
|
4220
|
-
onMouseLeave: () => {
|
|
4221
|
-
S.railHoverTimer = setTimeout(() => setS({ railHover: null }), 350);
|
|
4222
|
-
},
|
|
4223
|
-
onClick: () => scrollToSeq(p.seq)
|
|
4224
|
-
})), react.createElement(RailPopover, null));
|
|
4225
|
-
}
|
|
4226
3864
|
function AppearanceTab() {
|
|
4227
3865
|
const s = useS();
|
|
4228
3866
|
const dark = s.dark === true;
|
|
@@ -4233,7 +3871,7 @@ window.__ModuleLoader__.load({
|
|
|
4233
3871
|
} });
|
|
4234
3872
|
saveCfg();
|
|
4235
3873
|
};
|
|
4236
|
-
return react.createElement("div", { className: "vx-col" }, react.createElement("div", { className: "vx-muted" }, "主题背景、天气特效与玻璃质感,选择后即时生效。"), react.createElement("div", { className: "vx-section-title" }, "背景颜色"), react.createElement("div", { className: "vx-muted" }, "20
|
|
3874
|
+
return react.createElement("div", { className: "vx-col" }, react.createElement("div", { className: "vx-muted" }, "主题背景、天气特效与玻璃质感,选择后即时生效。"), react.createElement("div", { className: "vx-section-title" }, "背景颜色"), react.createElement("div", { className: "vx-muted" }, "20 组低饱和色板,深浅色模式均可用;深色下自动使用同色系的深色变体(预览即实际效果)。"), react.createElement("div", { className: "vx-swatches" }, react.createElement("button", {
|
|
4237
3875
|
key: "default",
|
|
4238
3876
|
className: "vx-swatch" + (s.cfg.bg === "default" ? " on" : ""),
|
|
4239
3877
|
onClick: () => set("bg", "default"),
|
|
@@ -4241,24 +3879,18 @@ window.__ModuleLoader__.load({
|
|
|
4241
3879
|
}, react.createElement("span", {
|
|
4242
3880
|
className: "vx-swatch-box",
|
|
4243
3881
|
style: { background: "repeating-conic-gradient(#ccc 0 25%, #eee 0 50%) 0 0/10px 10px" }
|
|
4244
|
-
}), react.createElement("span", { className: "vx-swatch-label" }, "无颜色")),
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
onClick: () => set("bg", p[0]),
|
|
4257
|
-
title: p[0] + " " + p[1] + (dark ? "(深色模式禁用)" : "")
|
|
4258
|
-
}, react.createElement("span", {
|
|
4259
|
-
className: "vx-swatch-box",
|
|
4260
|
-
style: { background: p[1] }
|
|
4261
|
-
}), react.createElement("span", { className: "vx-swatch-label" }, p[0])))), react.createElement("div", { className: "vx-section-title" }, "天气特效"), react.createElement("div", { className: "vx-row wrap" }, [
|
|
3882
|
+
}), react.createElement("span", { className: "vx-swatch-label" }, "无颜色")), PALETTE.map((p) => {
|
|
3883
|
+
const preview = dark ? toDarkRamp(p[1], DARK_CANVAS_LIGHTNESS) : p[1];
|
|
3884
|
+
return react.createElement("button", {
|
|
3885
|
+
key: p[0],
|
|
3886
|
+
className: "vx-swatch" + (s.cfg.bg === p[0] ? " on" : ""),
|
|
3887
|
+
onClick: () => set("bg", p[0]),
|
|
3888
|
+
title: p[0] + " " + p[1]
|
|
3889
|
+
}, react.createElement("span", {
|
|
3890
|
+
className: "vx-swatch-box",
|
|
3891
|
+
style: { background: preview }
|
|
3892
|
+
}), react.createElement("span", { className: "vx-swatch-label" }, p[0]));
|
|
3893
|
+
})), react.createElement("div", { className: "vx-section-title" }, "天气特效"), react.createElement("div", { className: "vx-row wrap" }, [
|
|
4262
3894
|
"none",
|
|
4263
3895
|
"snow",
|
|
4264
3896
|
"rain",
|
|
@@ -4292,11 +3924,11 @@ window.__ModuleLoader__.load({
|
|
|
4292
3924
|
}, "毛玻璃"), react.createElement("button", {
|
|
4293
3925
|
className: "vx-btn" + (s.cfg.glassMode === "liquid" ? " on" : ""),
|
|
4294
3926
|
onClick: () => set("glassMode", "liquid")
|
|
4295
|
-
}, "液态玻璃")), react.createElement(
|
|
3927
|
+
}, "液态玻璃")), react.createElement(Toggle, {
|
|
4296
3928
|
label: "全局浮层玻璃",
|
|
4297
3929
|
checked: s.cfg.globalGlass === true,
|
|
4298
3930
|
onChange: (v) => set("globalGlass", v),
|
|
4299
|
-
hint: "
|
|
3931
|
+
hint: "对弹窗/菜单等浮层应用玻璃质感;液态玻璃模式下浮层同样位移折射"
|
|
4300
3932
|
}));
|
|
4301
3933
|
}
|
|
4302
3934
|
function FolderNode(props) {
|
|
@@ -4776,29 +4408,6 @@ window.__ModuleLoader__.load({
|
|
|
4776
4408
|
}
|
|
4777
4409
|
}))));
|
|
4778
4410
|
}
|
|
4779
|
-
function TimelineTab() {
|
|
4780
|
-
const s = useS();
|
|
4781
|
-
const set = (k, v) => {
|
|
4782
|
-
setS({ cfg: {
|
|
4783
|
-
...s.cfg,
|
|
4784
|
-
[k]: v
|
|
4785
|
-
} });
|
|
4786
|
-
saveCfg();
|
|
4787
|
-
};
|
|
4788
|
-
return react.createElement("div", { className: "vx-col" }, react.createElement("div", { className: "vx-muted" }, "为每条用户消息生成导航节点:悬停预览、点击跳转,支持星标与分支。"), react.createElement(Toggle, {
|
|
4789
|
-
label: "显示时间线",
|
|
4790
|
-
checked: s.cfg.timeline === true,
|
|
4791
|
-
onChange: (v) => set("timeline", v)
|
|
4792
|
-
}), react.createElement(Toggle, {
|
|
4793
|
-
label: "时间线在左侧",
|
|
4794
|
-
checked: s.cfg.timelineLeft === true,
|
|
4795
|
-
onChange: (v) => set("timelineLeft", v)
|
|
4796
|
-
}), react.createElement(Toggle, {
|
|
4797
|
-
label: "仅显示星标",
|
|
4798
|
-
checked: s.cfg.starsOnly === true,
|
|
4799
|
-
onChange: (v) => set("starsOnly", v)
|
|
4800
|
-
}));
|
|
4801
|
-
}
|
|
4802
4411
|
function BackupControls() {
|
|
4803
4412
|
const [mode, setMode] = react.useState("merge");
|
|
4804
4413
|
const exportBackup = async () => {
|
|
@@ -4883,7 +4492,7 @@ window.__ModuleLoader__.load({
|
|
|
4883
4492
|
toast("目标会话不可用", "error");
|
|
4884
4493
|
return;
|
|
4885
4494
|
}
|
|
4886
|
-
const rendered = () => S.
|
|
4495
|
+
const rendered = () => S.anchors.get(item.anchorSeq)?.el !== void 0;
|
|
4887
4496
|
for (let page = 0; !rendered() && face.getSnapshot().hasMore && page < 20; page++) {
|
|
4888
4497
|
if (S.sessionId !== expectedSessionId) {
|
|
4889
4498
|
toast("会话已切换,搜索结果已失效", "error");
|
|
@@ -4891,7 +4500,6 @@ window.__ModuleLoader__.load({
|
|
|
4891
4500
|
}
|
|
4892
4501
|
await face.loadOlder();
|
|
4893
4502
|
await new Promise((resolve) => setTimeout(resolve, 60));
|
|
4894
|
-
updateRailPositions();
|
|
4895
4503
|
}
|
|
4896
4504
|
if (S.sessionId !== expectedSessionId) {
|
|
4897
4505
|
toast("会话已切换,搜索结果已失效", "error");
|
|
@@ -5104,7 +4712,7 @@ window.__ModuleLoader__.load({
|
|
|
5104
4712
|
react.useEffect(() => {
|
|
5105
4713
|
loadInfo();
|
|
5106
4714
|
}, []);
|
|
5107
|
-
return react.createElement("div", { className: "vx-col vx-pad" }, react.createElement("div", null, "Custom 便利套件"), react.createElement("div", { className: "vx-muted" }, "外观与天气特效 ·
|
|
4715
|
+
return react.createElement("div", { className: "vx-col vx-pad" }, react.createElement("div", null, "Custom 便利套件"), react.createElement("div", { className: "vx-muted" }, "外观与天气特效 · 项目文件夹 · 提示词 · 会话导出 · Mermaid 渲染 · 额度面板"), info !== null && info.ok === true ? react.createElement("pre", { className: "vx-pre" }, `状态文件: ${String(info.statePath ?? "")}\n今日: ${String(info.today ?? "")}\nMermaid: ${String(info.mermaidBytes ?? 0)} bytes\n今日用量: ${JSON.stringify(info.usageToday ?? {})}\n客户端诊断: ${Array.isArray(info.diagReports) ? `${String(info.diagReports.length)} 条` : "0 条"}`) : null, react.createElement("button", {
|
|
5108
4716
|
className: "vx-btn",
|
|
5109
4717
|
onClick: () => void loadInfo()
|
|
5110
4718
|
}, react.createElement(Icon, {
|
|
@@ -5132,7 +4740,7 @@ window.__ModuleLoader__.load({
|
|
|
5132
4740
|
className: "vx-glass vx-modal",
|
|
5133
4741
|
style: { width: "min(360px, 92vw)" },
|
|
5134
4742
|
onClick: (e) => e.stopPropagation()
|
|
5135
|
-
}, react.createElement("div", { className: "vx-
|
|
4743
|
+
}, react.createElement("div", { className: "vx-pop-head" }, react.createElement("span", null, ask.title)), react.createElement("input", {
|
|
5136
4744
|
className: "vx-input",
|
|
5137
4745
|
value: val,
|
|
5138
4746
|
autoFocus: true,
|
|
@@ -5164,7 +4772,7 @@ window.__ModuleLoader__.load({
|
|
|
5164
4772
|
className: "vx-glass vx-modal",
|
|
5165
4773
|
style: { width: "min(380px, 92vw)" },
|
|
5166
4774
|
onClick: (e) => e.stopPropagation()
|
|
5167
|
-
}, react.createElement("div", { className: "vx-
|
|
4775
|
+
}, react.createElement("div", { className: "vx-pad" }, c.message), react.createElement("div", { className: "vx-row vx-pad-sm" }, react.createElement("button", {
|
|
5168
4776
|
className: "vx-btn vx-btn-danger",
|
|
5169
4777
|
onClick: () => answer(true)
|
|
5170
4778
|
}, "确定"), react.createElement("button", {
|
|
@@ -5210,7 +4818,7 @@ window.__ModuleLoader__.load({
|
|
|
5210
4818
|
className: "vx-glass vx-modal",
|
|
5211
4819
|
style: { width: "min(440px, 92vw)" },
|
|
5212
4820
|
onClick: (e) => e.stopPropagation()
|
|
5213
|
-
}, react.createElement("div", { className: "vx-
|
|
4821
|
+
}, react.createElement("div", { className: "vx-pop-head" }, react.createElement("span", null, `填写变量 · ${prompt.name}`)), names.map((name) => react.createElement("label", {
|
|
5214
4822
|
key: name,
|
|
5215
4823
|
className: "vx-col"
|
|
5216
4824
|
}, react.createElement("span", { className: "vx-muted" }, name), react.createElement("input", {
|
|
@@ -5312,7 +4920,7 @@ window.__ModuleLoader__.load({
|
|
|
5312
4920
|
}, react.createElement("div", {
|
|
5313
4921
|
className: "vx-glass vx-modal",
|
|
5314
4922
|
onClick: (e) => e.stopPropagation()
|
|
5315
|
-
}, react.createElement("div", { className: "vx-
|
|
4923
|
+
}, react.createElement("div", { className: "vx-pop-head" }, react.createElement("span", null, `${mm.title} (${mm.index + 1}/${mm.codes.length})`), react.createElement("span", { className: "vx-row" }, mm.codes.length > 1 ? react.createElement("button", {
|
|
5316
4924
|
className: "vx-chip",
|
|
5317
4925
|
title: "上一个",
|
|
5318
4926
|
onClick: () => setS({ mermaidModal: {
|
|
@@ -5424,21 +5032,6 @@ window.__ModuleLoader__.load({
|
|
|
5424
5032
|
runExport("markdown");
|
|
5425
5033
|
}
|
|
5426
5034
|
},
|
|
5427
|
-
{
|
|
5428
|
-
key: "timeline",
|
|
5429
|
-
label: `${S.cfg.timeline ? "关闭" : "开启"}时间线`,
|
|
5430
|
-
detail: "功能开关",
|
|
5431
|
-
run: () => {
|
|
5432
|
-
setS({
|
|
5433
|
-
commandOpen: false,
|
|
5434
|
-
cfg: {
|
|
5435
|
-
...S.cfg,
|
|
5436
|
-
timeline: !S.cfg.timeline
|
|
5437
|
-
}
|
|
5438
|
-
});
|
|
5439
|
-
saveCfg();
|
|
5440
|
-
}
|
|
5441
|
-
},
|
|
5442
5035
|
{
|
|
5443
5036
|
key: "search-current",
|
|
5444
5037
|
label: "搜索当前会话",
|
|
@@ -5609,7 +5202,7 @@ window.__ModuleLoader__.load({
|
|
|
5609
5202
|
className: "vx-glass vx-modal",
|
|
5610
5203
|
style: { width: "min(560px, 92vw)" },
|
|
5611
5204
|
onClick: (e) => e.stopPropagation()
|
|
5612
|
-
}, react.createElement("div", { className: "vx-
|
|
5205
|
+
}, react.createElement("div", { className: "vx-pop-head" }, react.createElement("span", null, "批量归档会话"), react.createElement("button", {
|
|
5613
5206
|
className: "vx-chip",
|
|
5614
5207
|
title: "关闭",
|
|
5615
5208
|
onClick: () => setS({ batchModal: false })
|
|
@@ -5673,7 +5266,6 @@ window.__ModuleLoader__.load({
|
|
|
5673
5266
|
useWorkspaces: props.useWorkspaces
|
|
5674
5267
|
});
|
|
5675
5268
|
if (s.panelTab === "prompt") return react.createElement(PromptsTab, null);
|
|
5676
|
-
if (s.panelTab === "timeline") return react.createElement(TimelineTab, null);
|
|
5677
5269
|
if (s.panelTab === "search") return react.createElement(SearchTab, null);
|
|
5678
5270
|
if (s.panelTab === "export") return react.createElement(ExportTab, null);
|
|
5679
5271
|
if (s.panelTab === "mermaid") return react.createElement(MermaidTab, null);
|
|
@@ -5700,11 +5292,6 @@ window.__ModuleLoader__.load({
|
|
|
5700
5292
|
"zap",
|
|
5701
5293
|
"提示词"
|
|
5702
5294
|
],
|
|
5703
|
-
[
|
|
5704
|
-
"timeline",
|
|
5705
|
-
"clock",
|
|
5706
|
-
"时间线"
|
|
5707
|
-
],
|
|
5708
5295
|
[
|
|
5709
5296
|
"search",
|
|
5710
5297
|
"search",
|
|
@@ -5775,7 +5362,7 @@ window.__ModuleLoader__.load({
|
|
|
5775
5362
|
ref,
|
|
5776
5363
|
className: "vx-glass vx-panel",
|
|
5777
5364
|
style
|
|
5778
|
-
}, react.createElement("div", {
|
|
5365
|
+
}, react.createElement("div", {
|
|
5779
5366
|
className: "vx-panel-head",
|
|
5780
5367
|
onMouseDown: onHeadDown
|
|
5781
5368
|
}, react.createElement(Icon, {
|
|
@@ -5802,7 +5389,7 @@ window.__ModuleLoader__.load({
|
|
|
5802
5389
|
}
|
|
5803
5390
|
function SidebarFoldersPanel(props) {
|
|
5804
5391
|
if (useS().foldersOpen !== true) return null;
|
|
5805
|
-
return react.createElement("div", { className: "vx-glass vx-folders" }, react.createElement("div", { className: "vx-
|
|
5392
|
+
return react.createElement("div", { className: "vx-glass vx-folders" }, react.createElement("div", { className: "vx-pop-head" }, react.createElement(Icon, {
|
|
5806
5393
|
n: "folder",
|
|
5807
5394
|
size: 14
|
|
5808
5395
|
}), react.createElement("span", null, "项目文件夹"), react.createElement("span", { className: "vx-flex1" }), react.createElement("button", {
|
|
@@ -5839,7 +5426,7 @@ window.__ModuleLoader__.load({
|
|
|
5839
5426
|
}))));
|
|
5840
5427
|
}
|
|
5841
5428
|
function SettingsPage() {
|
|
5842
|
-
return react.createElement("div", { className: "vx-settings-page" }, react.createElement(AppearanceTab, null), react.createElement("div", { className: "vx-section-title" }, "功能开关"), react.createElement(
|
|
5429
|
+
return react.createElement("div", { className: "vx-settings-page" }, react.createElement(AppearanceTab, null), react.createElement("div", { className: "vx-section-title" }, "功能开关"), react.createElement(ToolsTab, null), react.createElement(MermaidTab, null));
|
|
5843
5430
|
}
|
|
5844
5431
|
function Toasts() {
|
|
5845
5432
|
const s = useS();
|
|
@@ -5900,7 +5487,8 @@ window.__ModuleLoader__.load({
|
|
|
5900
5487
|
s.cfg.bg,
|
|
5901
5488
|
s.cfg.glass,
|
|
5902
5489
|
s.cfg.glassMode,
|
|
5903
|
-
s.cfg.globalGlass
|
|
5490
|
+
s.cfg.globalGlass,
|
|
5491
|
+
s.dark
|
|
5904
5492
|
]);
|
|
5905
5493
|
react.useEffect(() => {
|
|
5906
5494
|
syncAntiScroll(s.cfg.antiScroll === true);
|
|
@@ -5910,13 +5498,6 @@ window.__ModuleLoader__.load({
|
|
|
5910
5498
|
const d = typeof document !== "undefined" ? document : null;
|
|
5911
5499
|
const applyDark = (dark) => {
|
|
5912
5500
|
S.dark = dark;
|
|
5913
|
-
if (dark && S.booted && S.cfg.bg !== "default" && S.cfg.bg !== "aurora") {
|
|
5914
|
-
S.cfg = {
|
|
5915
|
-
...S.cfg,
|
|
5916
|
-
bg: "default"
|
|
5917
|
-
};
|
|
5918
|
-
saveCfg();
|
|
5919
|
-
}
|
|
5920
5501
|
setS({ dark });
|
|
5921
5502
|
};
|
|
5922
5503
|
applyDark(readDark());
|
|
@@ -5954,67 +5535,26 @@ window.__ModuleLoader__.load({
|
|
|
5954
5535
|
react.useEffect(() => {
|
|
5955
5536
|
const dark = readDark();
|
|
5956
5537
|
S.dark = dark;
|
|
5957
|
-
|
|
5958
|
-
S.cfg = {
|
|
5959
|
-
...S.cfg,
|
|
5960
|
-
bg: "default"
|
|
5961
|
-
};
|
|
5962
|
-
setS({ cfg: S.cfg });
|
|
5963
|
-
saveCfg();
|
|
5964
|
-
} else setS({ dark });
|
|
5538
|
+
setS({ dark });
|
|
5965
5539
|
}, [s.booted]);
|
|
5966
5540
|
react.useEffect(() => {
|
|
5967
|
-
const tick = () => {
|
|
5968
|
-
const d = typeof document !== "undefined" ? document : null;
|
|
5969
|
-
if (d !== null && d.visibilityState === "hidden") return;
|
|
5970
|
-
updateRailPositions();
|
|
5971
|
-
};
|
|
5972
|
-
const stop = setInterval(tick, 450);
|
|
5973
5541
|
const d = typeof document !== "undefined" ? document : null;
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
if (w !== null) w.addEventListener("resize", h);
|
|
5981
|
-
return () => {
|
|
5982
|
-
clearInterval(stop);
|
|
5983
|
-
if (d !== null) {
|
|
5984
|
-
d.removeEventListener("scroll", h, true);
|
|
5985
|
-
d.removeEventListener("visibilitychange", h);
|
|
5986
|
-
}
|
|
5987
|
-
if (w !== null) w.removeEventListener("resize", h);
|
|
5988
|
-
};
|
|
5989
|
-
}, []);
|
|
5542
|
+
if (d === null) return;
|
|
5543
|
+
d.documentElement.classList.toggle("vx-dark", s.dark === true);
|
|
5544
|
+
d.documentElement.classList.toggle("vx-light", s.dark !== true);
|
|
5545
|
+
}, [s.dark]);
|
|
5546
|
+
const sessions = useSessionsSafe(props);
|
|
5547
|
+
const summary = sessions !== null && s.sessionId !== null ? sessions.byId[s.sessionId] : null;
|
|
5990
5548
|
react.useEffect(() => {
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
const
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
timer = setTimeout(() => {
|
|
5999
|
-
updateRailPositions();
|
|
6000
|
-
}, 120);
|
|
6001
|
-
});
|
|
6002
|
-
observer.observe(scroller, {
|
|
6003
|
-
childList: true,
|
|
6004
|
-
subtree: true
|
|
6005
|
-
});
|
|
6006
|
-
return () => {
|
|
6007
|
-
observer.disconnect();
|
|
6008
|
-
if (timer !== null) clearTimeout(timer);
|
|
6009
|
-
};
|
|
6010
|
-
}, [s.scrollerEl]);
|
|
5549
|
+
if (S.sessionId === null) return;
|
|
5550
|
+
const running = summary?.running === true;
|
|
5551
|
+
const handle = setInterval(() => {
|
|
5552
|
+
if (running && S.sessionId !== null) fetchTurns(S.sessionId);
|
|
5553
|
+
}, 3e3);
|
|
5554
|
+
return () => clearInterval(handle);
|
|
5555
|
+
}, [s.sessionId, summary?.running]);
|
|
6011
5556
|
const children = [react.createElement(FxCanvas, { key: "fx" })];
|
|
6012
5557
|
children.push(react.createElement(MermaidInPlace, { key: "mmd" }));
|
|
6013
|
-
children.push(react.createElement(TimelineRail, {
|
|
6014
|
-
key: "rail",
|
|
6015
|
-
useSessions: props.useSessions,
|
|
6016
|
-
useWorkspaces: props.useWorkspaces
|
|
6017
|
-
}));
|
|
6018
5558
|
if (s.panelOpen === true) children.push(react.createElement(PersonalizePanel, {
|
|
6019
5559
|
key: "panel",
|
|
6020
5560
|
useSessions: props.useSessions,
|