dsh-session-guard 4.2.12 → 4.4.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.de.md +8 -0
- package/CHANGELOG.es.md +8 -0
- package/CHANGELOG.fr.md +8 -0
- package/CHANGELOG.it.md +8 -0
- package/CHANGELOG.ja.md +8 -0
- package/CHANGELOG.ko.md +8 -0
- package/CHANGELOG.md +20 -0
- package/CHANGELOG.pt.md +196 -0
- package/CHANGELOG.ru.md +8 -0
- package/INSTALL.de.md +3 -0
- package/INSTALL.es.md +3 -0
- package/INSTALL.fr.md +3 -0
- package/INSTALL.it.md +3 -0
- package/INSTALL.ja.md +1 -0
- package/INSTALL.ko.md +1 -0
- package/INSTALL.md +1 -0
- package/INSTALL.pt.md +120 -0
- package/INSTALL.ru.md +3 -0
- package/INSTALL.zh.md +1 -0
- package/README.de.md +4 -1
- package/README.en.md +5 -2
- package/README.es.md +4 -1
- package/README.fr.md +4 -1
- package/README.it.md +4 -1
- package/README.ja.md +4 -1
- package/README.ko.md +4 -1
- package/README.md +5 -2
- package/README.pt.md +377 -0
- package/README.ru.md +4 -1
- package/dsh.plugin.json +1 -1
- package/lib/client.js +429 -5
- package/lib/client.js.map +1 -1
- package/locale/pt.json +6 -0
- package/package.json +8 -5
- package/src/client/guide.tsx +368 -0
- package/src/client/index.ts +1 -1
- package/src/client/locales.ts +42 -3
- package/src/client/settings-card.tsx +45 -0
- package/src/holidays.js +215 -159
package/lib/client.js
CHANGED
|
@@ -250,6 +250,349 @@ window.__ModuleLoader__.load({
|
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
252
|
//#endregion
|
|
253
|
+
//#region src/client/guide.tsx
|
|
254
|
+
/**
|
|
255
|
+
* ⚠️ 生成副本 —— 请勿手改。真源:mine-dsh-plugins/_tools/guide-kit/guide.tsx
|
|
256
|
+
* 重新同步:node _tools/guide-kit/sync.mjs
|
|
257
|
+
*/
|
|
258
|
+
/**
|
|
259
|
+
* guide-kit —— 九插件共用的「首次使用引导」件(**生成副本,勿手改**)。
|
|
260
|
+
*
|
|
261
|
+
* 唯一真源:`mine-dsh-plugins/_tools/guide-kit/guide.tsx`
|
|
262
|
+
* 同步命令:`node _tools/guide-kit/sync.mjs`(会覆盖本文件;改这里等于白改)
|
|
263
|
+
*
|
|
264
|
+
* 六条契约(见 .agents/plans/unified-i18n-onboarding/spec.md §2):
|
|
265
|
+
* 1. Skip 恒定可见,任何步骤都能退;
|
|
266
|
+
* 2. 永远有字:引导外壳(标题/按钮/步进)自带 10 语词表,按 <html lang> 取词,
|
|
267
|
+
* 认不出的一律落 en;步骤正文按「本语 → en → zh → 任意可用」逐级回退,绝不留空白;
|
|
268
|
+
* 3. 重启入口:`GuideRestartButton`(或自己调 `resetGuide(ns)` + setOpen(true))就地重开;
|
|
269
|
+
* 4. 零依赖:只 react + localStorage,不 import 平台包,不抢宿主设置表单;
|
|
270
|
+
* 5. 引导自己绝不能成为卡面渲染的失败点:样式注入与存储访问全部 try/catch + 能力探测;
|
|
271
|
+
* 6. 外壳词表与步骤正文分离:外壳跨插件统一(本文件),正文每插件一份 `guide-steps.ts`。
|
|
272
|
+
*/
|
|
273
|
+
/** 生态通用的十个语言码(与各插件 `locale/*.json`、README 的十语镜像同口径)。 */
|
|
274
|
+
const GUIDE_LOCALES = [
|
|
275
|
+
"zh",
|
|
276
|
+
"en",
|
|
277
|
+
"ja",
|
|
278
|
+
"ko",
|
|
279
|
+
"fr",
|
|
280
|
+
"de",
|
|
281
|
+
"it",
|
|
282
|
+
"ru",
|
|
283
|
+
"es",
|
|
284
|
+
"pt"
|
|
285
|
+
];
|
|
286
|
+
/**
|
|
287
|
+
* 引导外壳词表(10 语)。
|
|
288
|
+
*
|
|
289
|
+
* 为什么不塞进各插件 locales:这七个词是**跨插件同一套**,塞进九个字典要重复翻译
|
|
290
|
+
* 9×10 次,且一旦措辞调整就得动九个仓。外壳留在本文件,正文留各插件。
|
|
291
|
+
*/
|
|
292
|
+
const GUIDE_COPY = {
|
|
293
|
+
zh: {
|
|
294
|
+
title: "快速上手",
|
|
295
|
+
skip: "跳过引导",
|
|
296
|
+
next: "下一步",
|
|
297
|
+
prev: "上一步",
|
|
298
|
+
done: "开始使用",
|
|
299
|
+
restart: "重新查看引导",
|
|
300
|
+
stepOf: (current, total) => `第 ${current} / ${total} 步`
|
|
301
|
+
},
|
|
302
|
+
en: {
|
|
303
|
+
title: "Quick start",
|
|
304
|
+
skip: "Skip guide",
|
|
305
|
+
next: "Next",
|
|
306
|
+
prev: "Back",
|
|
307
|
+
done: "Get started",
|
|
308
|
+
restart: "Show guide again",
|
|
309
|
+
stepOf: (current, total) => `Step ${current} of ${total}`
|
|
310
|
+
},
|
|
311
|
+
ja: {
|
|
312
|
+
title: "クイックスタート",
|
|
313
|
+
skip: "ガイドをスキップ",
|
|
314
|
+
next: "次へ",
|
|
315
|
+
prev: "戻る",
|
|
316
|
+
done: "はじめる",
|
|
317
|
+
restart: "ガイドをもう一度表示",
|
|
318
|
+
stepOf: (current, total) => `ステップ ${current} / ${total}`
|
|
319
|
+
},
|
|
320
|
+
ko: {
|
|
321
|
+
title: "빠른 시작",
|
|
322
|
+
skip: "가이드 건너뛰기",
|
|
323
|
+
next: "다음",
|
|
324
|
+
prev: "이전",
|
|
325
|
+
done: "시작하기",
|
|
326
|
+
restart: "가이드 다시 보기",
|
|
327
|
+
stepOf: (current, total) => `${current} / ${total} 단계`
|
|
328
|
+
},
|
|
329
|
+
fr: {
|
|
330
|
+
title: "Démarrage rapide",
|
|
331
|
+
skip: "Ignorer le guide",
|
|
332
|
+
next: "Suivant",
|
|
333
|
+
prev: "Retour",
|
|
334
|
+
done: "Commencer",
|
|
335
|
+
restart: "Revoir le guide",
|
|
336
|
+
stepOf: (current, total) => `Étape ${current} sur ${total}`
|
|
337
|
+
},
|
|
338
|
+
de: {
|
|
339
|
+
title: "Schnellstart",
|
|
340
|
+
skip: "Anleitung überspringen",
|
|
341
|
+
next: "Weiter",
|
|
342
|
+
prev: "Zurück",
|
|
343
|
+
done: "Loslegen",
|
|
344
|
+
restart: "Anleitung erneut anzeigen",
|
|
345
|
+
stepOf: (current, total) => `Schritt ${current} von ${total}`
|
|
346
|
+
},
|
|
347
|
+
it: {
|
|
348
|
+
title: "Avvio rapido",
|
|
349
|
+
skip: "Salta la guida",
|
|
350
|
+
next: "Avanti",
|
|
351
|
+
prev: "Indietro",
|
|
352
|
+
done: "Inizia",
|
|
353
|
+
restart: "Rivedi la guida",
|
|
354
|
+
stepOf: (current, total) => `Passo ${current} di ${total}`
|
|
355
|
+
},
|
|
356
|
+
ru: {
|
|
357
|
+
title: "Быстрый старт",
|
|
358
|
+
skip: "Пропустить руководство",
|
|
359
|
+
next: "Далее",
|
|
360
|
+
prev: "Назад",
|
|
361
|
+
done: "Начать",
|
|
362
|
+
restart: "Показать руководство снова",
|
|
363
|
+
stepOf: (current, total) => `Шаг ${current} из ${total}`
|
|
364
|
+
},
|
|
365
|
+
es: {
|
|
366
|
+
title: "Inicio rápido",
|
|
367
|
+
skip: "Omitir la guía",
|
|
368
|
+
next: "Siguiente",
|
|
369
|
+
prev: "Atrás",
|
|
370
|
+
done: "Empezar",
|
|
371
|
+
restart: "Ver la guía de nuevo",
|
|
372
|
+
stepOf: (current, total) => `Paso ${current} de ${total}`
|
|
373
|
+
},
|
|
374
|
+
pt: {
|
|
375
|
+
title: "Início rápido",
|
|
376
|
+
skip: "Ignorar o guia",
|
|
377
|
+
next: "Próximo",
|
|
378
|
+
prev: "Voltar",
|
|
379
|
+
done: "Começar",
|
|
380
|
+
restart: "Ver o guia novamente",
|
|
381
|
+
stepOf: (current, total) => `Passo ${current} de ${total}`
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
/** 语言标签 → 语言码:只认主标签,认不出的落 null(由调用方回退 en)。 */
|
|
385
|
+
function normalizeGuideLocale(tag) {
|
|
386
|
+
const primary = tag.toLowerCase().trim().split(/[-_]/)[0] ?? "";
|
|
387
|
+
return GUIDE_LOCALES.includes(primary) ? primary : null;
|
|
388
|
+
}
|
|
389
|
+
function htmlLang() {
|
|
390
|
+
try {
|
|
391
|
+
return typeof document === "undefined" ? "" : document.documentElement?.lang ?? "";
|
|
392
|
+
} catch {
|
|
393
|
+
return "";
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* 当前引导语言:以宿主 `<html lang>` 为准(语言切换会改写这个属性)。
|
|
398
|
+
*
|
|
399
|
+
* 认不出 → en:引导是「帮助」面,宁可给英文也不能给空白或中文硬串。
|
|
400
|
+
*/
|
|
401
|
+
function currentGuideLocale() {
|
|
402
|
+
return normalizeGuideLocale(htmlLang()) ?? "en";
|
|
403
|
+
}
|
|
404
|
+
/** 引导外壳取词。 */
|
|
405
|
+
function guideLabels(locale = currentGuideLocale()) {
|
|
406
|
+
return GUIDE_COPY[locale] ?? GUIDE_COPY.en;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* 步骤正文取词:本语 → en → zh → 表里第一个可用。
|
|
410
|
+
*
|
|
411
|
+
* 为什么需要回退链:九插件分批补语种,某个插件可能只有 zh/en 而宿主是 ru;
|
|
412
|
+
* 这时给英文是可用的,给空白等于「引导坏了」。`undefined` 步骤表按空表处理。
|
|
413
|
+
*/
|
|
414
|
+
function guideSteps(map) {
|
|
415
|
+
if (map === void 0) return [];
|
|
416
|
+
const order = [
|
|
417
|
+
currentGuideLocale(),
|
|
418
|
+
"en",
|
|
419
|
+
"zh"
|
|
420
|
+
];
|
|
421
|
+
for (const key of order) {
|
|
422
|
+
const hit = key === void 0 ? void 0 : map[key];
|
|
423
|
+
if (hit !== void 0 && hit.length > 0) return hit;
|
|
424
|
+
}
|
|
425
|
+
for (const key of GUIDE_LOCALES) {
|
|
426
|
+
const hit = map[key];
|
|
427
|
+
if (hit !== void 0 && hit.length > 0) return hit;
|
|
428
|
+
}
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
431
|
+
function guideStorageKey(ns) {
|
|
432
|
+
return `dsh.guide.${ns}.skipped`;
|
|
433
|
+
}
|
|
434
|
+
/** 是否已跳过(存储不可用时按「未跳过」处理:宁可多教一次,不要静默不教)。 */
|
|
435
|
+
function isGuideSkipped(ns) {
|
|
436
|
+
try {
|
|
437
|
+
return typeof localStorage !== "undefined" && localStorage.getItem(guideStorageKey(ns)) === "1";
|
|
438
|
+
} catch {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
/** 记下跳过;写失败不抛(隐私模式 / 存储禁用)。 */
|
|
443
|
+
function skipGuide(ns) {
|
|
444
|
+
try {
|
|
445
|
+
localStorage?.setItem(guideStorageKey(ns), "1");
|
|
446
|
+
} catch {}
|
|
447
|
+
}
|
|
448
|
+
/** 清标记 = 允许重新教学。 */
|
|
449
|
+
function resetGuide(ns) {
|
|
450
|
+
try {
|
|
451
|
+
localStorage?.removeItem(guideStorageKey(ns));
|
|
452
|
+
} catch {}
|
|
453
|
+
}
|
|
454
|
+
const GUIDE_CSS = `
|
|
455
|
+
.sgGuide{border:1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.28));background:var(--dsw-alias-bg-layer-2, rgba(127,127,127,.06));border-radius:12px;padding:14px 16px;margin:0 0 12px}
|
|
456
|
+
.sgGuideHead{display:flex;align-items:center;gap:8px;margin:0 0 10px}
|
|
457
|
+
.sgGuideTitle{font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary, currentColor)}
|
|
458
|
+
.sgGuideStep{font-size:12px;color:var(--dsw-alias-label-tertiary, rgba(127,127,127,.9));margin-left:auto}
|
|
459
|
+
.sgGuideBody{font-size:13px;line-height:1.6;color:var(--dsw-alias-label-secondary, currentColor);min-height:52px}
|
|
460
|
+
.sgGuideBody b{color:var(--dsw-alias-label-primary, currentColor);font-weight:600}
|
|
461
|
+
.sgGuideDots{display:flex;gap:6px;margin:10px 0 0}
|
|
462
|
+
.sgGuideDot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-border-l2, rgba(127,127,127,.3))}
|
|
463
|
+
.sgGuideDot-on{background:var(--dsw-alias-button-primary-fill, #4d6bfe)}
|
|
464
|
+
.sgGuideFoot{display:flex;align-items:center;gap:8px;margin:12px 0 0}
|
|
465
|
+
.sgGuideBtn{appearance:none;font:inherit;font-size:12px;padding:5px 12px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.3));background:transparent;color:var(--dsw-alias-label-primary, currentColor);cursor:pointer}
|
|
466
|
+
.sgGuideBtn-primary{background:var(--dsw-alias-button-primary-fill, #4d6bfe);border-color:transparent;color:#fff}
|
|
467
|
+
.sgGuideBtn-skip{margin-right:auto;color:var(--dsw-alias-label-tertiary, rgba(127,127,127,.9));border-color:transparent;text-decoration:underline}
|
|
468
|
+
.sgGuideRestart{appearance:none;font:inherit;font-size:12px;padding:0;border:0;background:transparent;color:var(--dsw-alias-link-primary, #4d6bfe);cursor:pointer;text-decoration:underline}
|
|
469
|
+
`;
|
|
470
|
+
function injectGuideCss() {
|
|
471
|
+
try {
|
|
472
|
+
if (typeof document === "undefined") return;
|
|
473
|
+
if (typeof document.querySelector !== "function") return;
|
|
474
|
+
if (typeof document.createElement !== "function") return;
|
|
475
|
+
if (!document.head) return;
|
|
476
|
+
if (document.querySelector("style[data-plugin-css=\"guide-kit\"]") !== null) return;
|
|
477
|
+
const tag = document.createElement("style");
|
|
478
|
+
tag.dataset.pluginCss = "guide-kit";
|
|
479
|
+
tag.textContent = GUIDE_CSS;
|
|
480
|
+
document.head.appendChild(tag);
|
|
481
|
+
} catch {}
|
|
482
|
+
}
|
|
483
|
+
/** 语言变更订阅:语言切换后重渲染词表(引导是短生命周期,直接跟随 <html lang>)。 */
|
|
484
|
+
function useLangTick() {
|
|
485
|
+
const [, setTick] = (0, react.useState)(0);
|
|
486
|
+
(0, react.useEffect)(() => {
|
|
487
|
+
try {
|
|
488
|
+
if (typeof MutationObserver === "undefined" || typeof document === "undefined") return;
|
|
489
|
+
if (!document.documentElement) return;
|
|
490
|
+
const observer = new MutationObserver(() => setTick((n) => n + 1));
|
|
491
|
+
observer.observe(document.documentElement, {
|
|
492
|
+
attributes: true,
|
|
493
|
+
attributeFilter: ["lang"]
|
|
494
|
+
});
|
|
495
|
+
return () => observer.disconnect();
|
|
496
|
+
} catch {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
}, []);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* 引导主体:3 步以内的小教学 + 恒定可见的 Skip。
|
|
503
|
+
*
|
|
504
|
+
* `onClose` 由宿主卡面传:Skip/Done 都会调用它(Skip 同时写标记)。
|
|
505
|
+
*/
|
|
506
|
+
function GuidePanel(props) {
|
|
507
|
+
const { ns, steps, onClose } = props;
|
|
508
|
+
const [index, setIndex] = (0, react.useState)(0);
|
|
509
|
+
useLangTick();
|
|
510
|
+
const labels = guideLabels();
|
|
511
|
+
(0, react.useEffect)(() => {
|
|
512
|
+
injectGuideCss();
|
|
513
|
+
}, []);
|
|
514
|
+
if (steps.length === 0) return null;
|
|
515
|
+
const current = steps[Math.min(index, steps.length - 1)];
|
|
516
|
+
const last = index >= steps.length - 1;
|
|
517
|
+
const finish = () => {
|
|
518
|
+
skipGuide(ns);
|
|
519
|
+
onClose();
|
|
520
|
+
};
|
|
521
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
522
|
+
className: "sgGuide",
|
|
523
|
+
"aria-label": labels.title,
|
|
524
|
+
children: [
|
|
525
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
526
|
+
className: "sgGuideHead",
|
|
527
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
528
|
+
className: "sgGuideTitle",
|
|
529
|
+
children: labels.title
|
|
530
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
531
|
+
className: "sgGuideStep",
|
|
532
|
+
children: labels.stepOf(index + 1, steps.length)
|
|
533
|
+
})]
|
|
534
|
+
}),
|
|
535
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
536
|
+
className: "sgGuideBody",
|
|
537
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: current.title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: current.body })]
|
|
538
|
+
}),
|
|
539
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
540
|
+
className: "sgGuideDots",
|
|
541
|
+
"aria-hidden": "true",
|
|
542
|
+
children: steps.map((step, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "sgGuideDot" + (i === index ? " sgGuideDot-on" : "") }, step.title))
|
|
543
|
+
}),
|
|
544
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
|
|
545
|
+
className: "sgGuideFoot",
|
|
546
|
+
children: [
|
|
547
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
548
|
+
type: "button",
|
|
549
|
+
className: "sgGuideBtn sgGuideBtn-skip",
|
|
550
|
+
onClick: () => finish(),
|
|
551
|
+
children: labels.skip
|
|
552
|
+
}),
|
|
553
|
+
index > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
554
|
+
type: "button",
|
|
555
|
+
className: "sgGuideBtn",
|
|
556
|
+
onClick: () => setIndex(index - 1),
|
|
557
|
+
children: labels.prev
|
|
558
|
+
}),
|
|
559
|
+
last ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
560
|
+
type: "button",
|
|
561
|
+
className: "sgGuideBtn sgGuideBtn-primary",
|
|
562
|
+
onClick: () => finish(),
|
|
563
|
+
children: labels.done
|
|
564
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
565
|
+
type: "button",
|
|
566
|
+
className: "sgGuideBtn sgGuideBtn-primary",
|
|
567
|
+
onClick: () => setIndex(index + 1),
|
|
568
|
+
children: labels.next
|
|
569
|
+
})
|
|
570
|
+
]
|
|
571
|
+
})
|
|
572
|
+
]
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* 重启入口:清标记 + 就地重开引导。
|
|
577
|
+
*
|
|
578
|
+
* 统一件,避免九插件各写一份(措辞/样式/清标记时机容易走样)。跳过之后
|
|
579
|
+
* 用户想再看一次,不需要去清浏览器存储。
|
|
580
|
+
*/
|
|
581
|
+
function GuideRestartButton(props) {
|
|
582
|
+
const { ns, onOpen, style } = props;
|
|
583
|
+
useLangTick();
|
|
584
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
585
|
+
type: "button",
|
|
586
|
+
className: "sgGuideRestart",
|
|
587
|
+
style,
|
|
588
|
+
onClick: () => {
|
|
589
|
+
resetGuide(ns);
|
|
590
|
+
onOpen();
|
|
591
|
+
},
|
|
592
|
+
children: guideLabels().restart
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
//#endregion
|
|
253
596
|
//#region src/client/settings-card.tsx
|
|
254
597
|
/**
|
|
255
598
|
* dsh-session-guard — 插件配置卡片(dsh-family.tab 共用设置节,抽屉默认展开)。
|
|
@@ -263,6 +606,37 @@ window.__ModuleLoader__.load({
|
|
|
263
606
|
* 仅依赖 react;CSS 经 `<style data-plugin-css>` 注入一次,控件为原生 HTML,
|
|
264
607
|
* 客户端 bundle 无 value-import @deepseek-ai/* 平台包(类型导入被构建擦除)。
|
|
265
608
|
*/
|
|
609
|
+
/** 首次使用引导文案(zh/en 为一等公民;其余语种由 guide-kit 的回退链落到 en)。 */
|
|
610
|
+
const GUIDE_STEPS = {
|
|
611
|
+
zh: [
|
|
612
|
+
{
|
|
613
|
+
title: "它会替你踩刹车",
|
|
614
|
+
body: "高峰时段自动暂停运行中的会话,退峰后自动续跑;周末模式让你无视峰谷畅快跑。"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
title: "判定口径按「官方源」",
|
|
618
|
+
body: "默认只拦 DeepSeek 官方源,本地/第三方 provider 照常跑;需要更严时再打开「官方源二维判定」下的名单。"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
title: "状态永远可见",
|
|
622
|
+
body: "输入框右侧的徽标显示当前状态(正常 / 峰值暂停中);停不下来时用旁边的暂停按钮手动接管。"
|
|
623
|
+
}
|
|
624
|
+
],
|
|
625
|
+
en: [
|
|
626
|
+
{
|
|
627
|
+
title: "It pumps the brakes for you",
|
|
628
|
+
body: "Running sessions auto-pause during peak hours and resume off-peak. Weekend mode ignores peaks entirely."
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
title: "Official-source scoping",
|
|
632
|
+
body: "By default only the DeepSeek official source is gated; local/third-party providers keep running. Tighten it via the official-source allowlists when needed."
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
title: "Status stays visible",
|
|
636
|
+
body: "The badge right of the composer shows the current state (Normal / Peak paused). Use the pause button beside it to take over manually."
|
|
637
|
+
}
|
|
638
|
+
]
|
|
639
|
+
};
|
|
266
640
|
/** 卡片样式,注入一次(保持 bundle CSS-free)。 */
|
|
267
641
|
const CARD_CSS = `
|
|
268
642
|
.sgCard{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}
|
|
@@ -442,6 +816,7 @@ window.__ModuleLoader__.load({
|
|
|
442
816
|
const readonly = unavailable || !snapshot.writable;
|
|
443
817
|
const value = snapshot.value ?? {};
|
|
444
818
|
const [open, setOpen] = (0, react.useState)(true);
|
|
819
|
+
const [guideOpen, setGuideOpen] = (0, react.useState)(() => !isGuideSkipped("session-guard"));
|
|
445
820
|
injectCss();
|
|
446
821
|
const toggle = (field, next) => {
|
|
447
822
|
scope.set(field, next);
|
|
@@ -477,9 +852,13 @@ window.__ModuleLoader__.load({
|
|
|
477
852
|
strokeLinejoin: "round"
|
|
478
853
|
})
|
|
479
854
|
})]
|
|
480
|
-
}), open && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
855
|
+
}), open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
481
856
|
className: "sgCardBody",
|
|
482
|
-
children:
|
|
857
|
+
children: [guideOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuidePanel, {
|
|
858
|
+
ns: "session-guard",
|
|
859
|
+
steps: guideSteps(GUIDE_STEPS),
|
|
860
|
+
onClose: () => setGuideOpen(false)
|
|
861
|
+
}), unavailable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
483
862
|
style: {
|
|
484
863
|
margin: "0",
|
|
485
864
|
padding: "12px 0",
|
|
@@ -615,8 +994,16 @@ window.__ModuleLoader__.load({
|
|
|
615
994
|
!snapshot.writable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
616
995
|
className: "sgReadonly",
|
|
617
996
|
children: "当前只读,无法修改。"
|
|
997
|
+
}),
|
|
998
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
999
|
+
className: "sgHint",
|
|
1000
|
+
style: { marginTop: 12 },
|
|
1001
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuideRestartButton, {
|
|
1002
|
+
ns: "session-guard",
|
|
1003
|
+
onOpen: () => setGuideOpen(true)
|
|
1004
|
+
})
|
|
618
1005
|
})
|
|
619
|
-
] })
|
|
1006
|
+
] })]
|
|
620
1007
|
})]
|
|
621
1008
|
});
|
|
622
1009
|
}
|
|
@@ -878,10 +1265,10 @@ window.__ModuleLoader__.load({
|
|
|
878
1265
|
}
|
|
879
1266
|
//#endregion
|
|
880
1267
|
//#region src/client/locales.ts
|
|
881
|
-
/** `session-guard` client dictionaries (zh / en / ja / ko / fr / de / it / ru / es). */
|
|
1268
|
+
/** `session-guard` client dictionaries (zh / en / ja / ko / fr / de / it / ru / es / pt). */
|
|
882
1269
|
/** Dictionary namespace owned by this plugin. */
|
|
883
1270
|
const NS = "session-guard";
|
|
884
|
-
/** Combined dictionary map — all
|
|
1271
|
+
/** Combined dictionary map — all 10 languages, for one-call registration. */
|
|
885
1272
|
const dictionaries = {
|
|
886
1273
|
zh: {
|
|
887
1274
|
"badge.normal": "正常",
|
|
@@ -1215,6 +1602,43 @@ window.__ModuleLoader__.load({
|
|
|
1215
1602
|
"status.paused_peak": "Pausa por pico activa",
|
|
1216
1603
|
"status.peak_official": "Pico · solo oficial",
|
|
1217
1604
|
"status.peak_all": "Pico · todo pausado"
|
|
1605
|
+
},
|
|
1606
|
+
pt: {
|
|
1607
|
+
"badge.normal": "Normal",
|
|
1608
|
+
"badge.paused": "Pausada (pico)",
|
|
1609
|
+
"badge_paused_peak": "Pausa por pico ativa",
|
|
1610
|
+
"settings.enabled": "Pausa automática no pico",
|
|
1611
|
+
"settings.enabled.desc": "Pausar automaticamente as sessões ativas durante as horas de pico",
|
|
1612
|
+
"settings.offPeakAutoResume": "Retomada automática fora do pico",
|
|
1613
|
+
"settings.offPeakAutoResume.desc": "Retomar automaticamente as sessões pausadas durante as horas de vale",
|
|
1614
|
+
"settings.weekendMode": "Modo fim de semana",
|
|
1615
|
+
"settings.weekendMode.desc": "Detectar fins de semana → sem pausa automática no fim de semana",
|
|
1616
|
+
"settings.queueFallback": "Fila de espera com lock como reserva",
|
|
1617
|
+
"settings.queueFallback.desc": "Recorrer à fila de espera com lock quando a porta de sessão própria não estiver disponível (fail-open)",
|
|
1618
|
+
"settings.retryEnabled": "Nova tentativa automática",
|
|
1619
|
+
"settings.retryEnabled.desc": "Retomar automaticamente após falhas transitórias (desativado por padrão, conservador)",
|
|
1620
|
+
"settings.timezone": "Fuso horário",
|
|
1621
|
+
"settings.peakWindows": "Janelas de horário de pico",
|
|
1622
|
+
"settings.providerGuard": "Veredito bidimensional de fonte oficial",
|
|
1623
|
+
"settings.providerGuard.desc": "No pico, bloquear somente as fontes oficiais do DeepSeek; provedores locais/de terceiros continuam rodando",
|
|
1624
|
+
"settings.officialProviders": "IDs de provedor oficiais adicionais",
|
|
1625
|
+
"settings.officialProviders.desc": "Correspondência exata, prioridade máxima (separados por vírgula)",
|
|
1626
|
+
"settings.officialBaseURLs": "Hosts de endpoints oficiais",
|
|
1627
|
+
"settings.officialBaseURLs.desc": "Hosts após a normalização da baseURL (separados por vírgula)",
|
|
1628
|
+
"settings.deferredMode": "Modo de interceptação",
|
|
1629
|
+
"settings.deferredMode.desc": "Reter sem erro; ou gerar erro e enfileirar como adiado",
|
|
1630
|
+
"settings.deferredResume": "Continuação automática após o pico",
|
|
1631
|
+
"settings.deferredResume.desc": "Desativado, requisições/sessões adiadas não retomam sozinhas; exigem /resume manual",
|
|
1632
|
+
"settings.deferredResumeText": "Mensagem de retomada",
|
|
1633
|
+
"settings.deferredResumeText.desc": "Conteúdo da mensagem enviada na retomada pós-pico no modo error",
|
|
1634
|
+
"settings.guardSubagents": "Incluir requisições de subagentes",
|
|
1635
|
+
"settings.guardSubagents.desc": "Requisições de subagentes também são cobradas; interceptadas por padrão",
|
|
1636
|
+
"settings.officialHint": "Cadeia do veredito: lista explícita de ids → endpoint da baseURL → endpoint padrão do catálogo → id embutido. Para investigar um veredito equivocado, abra /session-guard/provider?provider=<id> e veja matchedBy.",
|
|
1637
|
+
"settings.unavailable": "Configurações indisponíveis: confirme que o dsh-session-guard foi montado neste profile.",
|
|
1638
|
+
"status.normal": "Operação normal",
|
|
1639
|
+
"status.paused_peak": "Pausa por pico ativa",
|
|
1640
|
+
"status.peak_official": "Pico · só oficiais",
|
|
1641
|
+
"status.peak_all": "Pico · todas pausadas"
|
|
1218
1642
|
}
|
|
1219
1643
|
};
|
|
1220
1644
|
//#endregion
|