dsh-model-health 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/client.js +64 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,6 +57,7 @@ dsh --profile web --dump-config | grep dsh-model-health # 配置层含本行
|
|
|
57
57
|
- API Key 通过 DSH credential service(`ctx.credentials.resolve`)解析,密钥不会输出到浏览器
|
|
58
58
|
- 测试结果(状态/延迟/错误)持久化到 localStorage,刷新页面后仍可见
|
|
59
59
|
- 状态列的 可用 / 不可用 / 跳过 徽章随时可点击,对单个模型重新测试,原地刷新状态与延迟
|
|
60
|
+
- 设置导航使用脉搏线(Activity)图标——宿主图标表没有「健康」类目,参考 dsh-better-sidebar 的方案,JS 精准打 marker,CSS 用 `::before` + `mask` 把齿轮 svg 原地替换;颜色随主题走
|
|
60
61
|
|
|
61
62
|
## 实现方式 / How it works
|
|
62
63
|
|
|
@@ -101,7 +102,7 @@ dsh-model-health/
|
|
|
101
102
|
├── src/host/ # host 实现:config / models / markdown / http / model-test
|
|
102
103
|
├── src/client.tsx # client 入口壳:注入 React,装配插件导出
|
|
103
104
|
├── src/client/ # client 实现:types / runtime / i18n / storage / api /
|
|
104
|
-
│ # styles / columns / use-test-results / apply
|
|
105
|
+
│ # styles / columns / use-test-results / nav-icon / apply
|
|
105
106
|
│ └── components/ # ModelListSection / StatusCell / ErrorTooltip
|
|
106
107
|
├── cordis.patch.yml # bundle 层声明(id/name 走包名解析)
|
|
107
108
|
└── dist/ # 构建产物(发布包含在 files 字段中)
|
package/dist/client.js
CHANGED
|
@@ -699,6 +699,68 @@
|
|
|
699
699
|
})))), tooltip && /* @__PURE__ */ React.createElement(ErrorTooltip, { tip: tooltip }));
|
|
700
700
|
}
|
|
701
701
|
|
|
702
|
+
//#endregion
|
|
703
|
+
//#region src/client/nav-icon.ts
|
|
704
|
+
/** 本插件导航行按钮的 marker(参考 better-sidebar 的命名风格) */
|
|
705
|
+
const SETTINGS_NAV_MARKER = "data-dsh-model-health-settings-nav";
|
|
706
|
+
/**
|
|
707
|
+
* 在设置弹窗挂载期间,给本插件的导航行按钮持续打上 marker。
|
|
708
|
+
* label 解析器返回当前激活语言的 tab 文案(i18n 切换会重新求值),与导航行
|
|
709
|
+
* 按钮的 textContent 严格相等才算匹配——保证不会误伤其他插件的同名/相似 section。
|
|
710
|
+
* @param label - locale-aware label resolver used by the section registration
|
|
711
|
+
* @returns disposer: HMR / 插件卸载时断开观察器并清理已打的 marker
|
|
712
|
+
*/
|
|
713
|
+
function registerSettingsNavIcon(label) {
|
|
714
|
+
let disposed = false;
|
|
715
|
+
const sync = () => {
|
|
716
|
+
if (disposed) return;
|
|
717
|
+
const currentLabel = label().trim();
|
|
718
|
+
const buttons = document.querySelectorAll("[role=\"dialog\"] nav button");
|
|
719
|
+
for (let i = 0; i < buttons.length; i++) {
|
|
720
|
+
const button = buttons[i];
|
|
721
|
+
if (currentLabel.length > 0 && button.textContent && button.textContent.trim() === currentLabel) button.setAttribute(SETTINGS_NAV_MARKER, "");
|
|
722
|
+
else button.removeAttribute(SETTINGS_NAV_MARKER);
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
sync();
|
|
726
|
+
const observer = new MutationObserver(sync);
|
|
727
|
+
observer.observe(document.body, {
|
|
728
|
+
childList: true,
|
|
729
|
+
subtree: true,
|
|
730
|
+
characterData: true
|
|
731
|
+
});
|
|
732
|
+
return () => {
|
|
733
|
+
disposed = true;
|
|
734
|
+
observer.disconnect();
|
|
735
|
+
document.querySelectorAll(`[${SETTINGS_NAV_MARKER}]`).forEach((el) => {
|
|
736
|
+
el.removeAttribute(SETTINGS_NAV_MARKER);
|
|
737
|
+
});
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
/** 注入图标样式:隐藏 marker 行的齿轮 svg,用 ::before 注入脉搏线(mask 方案)。
|
|
741
|
+
* 16px 与宿主图标节奏一致;background: currentColor 让颜色跟随 nav 文案色
|
|
742
|
+
* (普通态 / hover / 选中态 / 明暗主题全自动)。 */
|
|
743
|
+
function ensureNavIconCss() {
|
|
744
|
+
const id = "dsh-model-health-nav-icon-style";
|
|
745
|
+
if (document.getElementById(id)) return;
|
|
746
|
+
const el = document.createElement("style");
|
|
747
|
+
el.id = id;
|
|
748
|
+
const mask = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 18 12 15 21 9 3 6 12 2 12'/%3E%3C/svg%3E\") center / contain no-repeat";
|
|
749
|
+
el.textContent = `
|
|
750
|
+
[data-dsh-model-health-settings-nav] > svg:first-child { display: none; }
|
|
751
|
+
[data-dsh-model-health-settings-nav]::before {
|
|
752
|
+
content: '';
|
|
753
|
+
flex: none;
|
|
754
|
+
width: 16px;
|
|
755
|
+
height: 16px;
|
|
756
|
+
background: currentColor;
|
|
757
|
+
-webkit-mask: ${mask};
|
|
758
|
+
mask: ${mask};
|
|
759
|
+
}
|
|
760
|
+
`;
|
|
761
|
+
document.head.appendChild(el);
|
|
762
|
+
}
|
|
763
|
+
|
|
702
764
|
//#endregion
|
|
703
765
|
//#region src/client/apply.tsx
|
|
704
766
|
/** client 侧依赖:slots(注册 UI slot 的服务)+ locale(多语言词典) */
|
|
@@ -726,11 +788,13 @@
|
|
|
726
788
|
function apply(ctx) {
|
|
727
789
|
const React = getReact();
|
|
728
790
|
ensureStatusCss();
|
|
791
|
+
ensureNavIconCss();
|
|
729
792
|
ctx.effect(() => ctx.locale.register(NS, {
|
|
730
793
|
zh,
|
|
731
794
|
en
|
|
732
795
|
}), "dsh-model-health: dictionaries");
|
|
733
796
|
const t = ctx.locale.bind(NS);
|
|
797
|
+
ctx.effect(() => registerSettingsNavIcon(() => t("tab")), "dsh-model-health: settings navigation icon");
|
|
734
798
|
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
735
799
|
name: "settings.section",
|
|
736
800
|
id: "model-health",
|
package/package.json
CHANGED