dsh-model-doctor 0.5.3 → 0.5.4
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/lib/client/index.js +33 -5
- package/package.json +1 -1
package/lib/client/index.js
CHANGED
|
@@ -74,7 +74,8 @@ window.__ModuleLoader__.load({
|
|
|
74
74
|
.dmd-btn.dmd-delete:hover{color:#e5484d}
|
|
75
75
|
.dmd-btn.is-armed{width:auto;padding:0 9px;color:#e5484d;opacity:1;font-size:12px;font-weight:600;line-height:26px}
|
|
76
76
|
@keyframes dmd-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
|
|
77
|
-
.dmd-chip{font-size:11px;line-height:17px;padding:0 7px;margin-left:2px;border-radius:999px;white-space:nowrap;vertical-align:middle;display:inline-block;flex:none;
|
|
77
|
+
.dmd-chip{font-size:11px;line-height:17px;padding:0 7px;margin-left:2px;border-radius:999px;white-space:nowrap;vertical-align:middle;display:inline-block;flex:none;box-sizing:border-box;width:84px;text-align:center;overflow:hidden;text-overflow:ellipsis}
|
|
78
|
+
.dmd-chip.is-stale{opacity:.45}
|
|
78
79
|
.dmd-chip.is-ok{color:#2fa96e;background:color-mix(in srgb,#2fa96e 16%,transparent)}
|
|
79
80
|
.dmd-chip.is-bad{color:#e5484d;background:color-mix(in srgb,#e5484d 14%,transparent)}
|
|
80
81
|
.dmd-chip.is-warn{color:#d08700;background:color-mix(in srgb,#d08700 16%,transparent)}
|
|
@@ -155,6 +156,8 @@ window.__ModuleLoader__.load({
|
|
|
155
156
|
/** 本轮扫描是否改动过菜单 DOM(用于决定要不要让官方菜单立刻重新锚定)。 */
|
|
156
157
|
let mutatedThisPass = false
|
|
157
158
|
let reanchorAt = 0
|
|
159
|
+
/** 上一轮看到的官方菜单尺寸(宽x高):尺寸一变就立刻让官方重新锚定。 */
|
|
160
|
+
let lastMenuSize = ''
|
|
158
161
|
|
|
159
162
|
/** 本页会话内已删除的模型键,防目录未刷新时行又冒出来。 */
|
|
160
163
|
const deletedKeys = new Set()
|
|
@@ -727,8 +730,10 @@ window.__ModuleLoader__.load({
|
|
|
727
730
|
barBusy = true
|
|
728
731
|
status.textContent = '探测中…'
|
|
729
732
|
balance.textContent = ''
|
|
733
|
+
// 只把旧结果「变灰」,绝不删除:删徽章会让行变窄、菜单跟着变窄,
|
|
734
|
+
// 而官方 place() 要等下次滚动才重算 —— 表现就是检测期间一滚动菜单就右移。
|
|
730
735
|
rowByKey.forEach((row) => {
|
|
731
|
-
row.querySelectorAll('.dmd-chip').forEach((chip) => chip.
|
|
736
|
+
row.querySelectorAll('.dmd-chip').forEach((chip) => chip.classList.add('is-stale'))
|
|
732
737
|
})
|
|
733
738
|
doctor.checkAll().then((result) => {
|
|
734
739
|
if (disposed) return
|
|
@@ -760,6 +765,8 @@ window.__ModuleLoader__.load({
|
|
|
760
765
|
.map(([providerId, value]) => `${providerLabel(providerId)}: ¥${value}`)
|
|
761
766
|
balance.textContent = parts.join(' · ')
|
|
762
767
|
}
|
|
768
|
+
// 状态条文案变长也会改菜单尺寸:补一次重锚定
|
|
769
|
+
reanchorOfficialMenu(true)
|
|
763
770
|
})
|
|
764
771
|
})
|
|
765
772
|
// preventDefault 阻止焦点转移到本按钮:焦点一旦离开菜单,官方 onBlur 就会关闭菜单
|
|
@@ -1037,17 +1044,33 @@ window.__ModuleLoader__.load({
|
|
|
1037
1044
|
* 这里向菜单派发一个 scroll 事件:它不冒泡,所以只会在捕获阶段命中官方监听,
|
|
1038
1045
|
* 不会惊动其它监听 window 滚动(冒泡阶段)的组件。
|
|
1039
1046
|
*/
|
|
1040
|
-
function reanchorOfficialMenu() {
|
|
1047
|
+
function reanchorOfficialMenu(force = false) {
|
|
1041
1048
|
const menu = document.querySelector(`[class*="${OFFICIAL_MENU_SUFFIX}"]`)
|
|
1042
1049
|
if (menu === null) return
|
|
1043
1050
|
const now = Date.now()
|
|
1044
|
-
if (now - reanchorAt < 200) return
|
|
1051
|
+
if (!force && now - reanchorAt < 200) return
|
|
1045
1052
|
reanchorAt = now
|
|
1046
1053
|
try {
|
|
1054
|
+
// 官方 place() 同时监听 window 的 scroll(捕获阶段)与 resize:
|
|
1055
|
+
// 前者精准(不冒泡,不会惊动其它滚动监听),后者作为保底。
|
|
1047
1056
|
menu.dispatchEvent(new Event('scroll'))
|
|
1057
|
+
window.dispatchEvent(new Event('resize'))
|
|
1048
1058
|
} catch { /* 忽略派发失败 */ }
|
|
1049
1059
|
}
|
|
1050
1060
|
|
|
1061
|
+
/** 菜单尺寸(宽x高)是否与上一轮不同;不同就说明位置需要立刻重算。 */
|
|
1062
|
+
function officialMenuSizeChanged() {
|
|
1063
|
+
const menu = document.querySelector(`[class*="${OFFICIAL_MENU_SUFFIX}"]`)
|
|
1064
|
+
if (menu === null) {
|
|
1065
|
+
lastMenuSize = ''
|
|
1066
|
+
return false
|
|
1067
|
+
}
|
|
1068
|
+
const size = `${menu.offsetWidth}x${menu.offsetHeight}`
|
|
1069
|
+
if (size === lastMenuSize) return false
|
|
1070
|
+
lastMenuSize = size
|
|
1071
|
+
return true
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1051
1074
|
function enhanceInner() {
|
|
1052
1075
|
if (directory === null || Date.now() - directoryAt >= DIRECTORY_TTL_MS) {
|
|
1053
1076
|
void fetchDirectory()
|
|
@@ -1069,7 +1092,12 @@ window.__ModuleLoader__.load({
|
|
|
1069
1092
|
|
|
1070
1093
|
const wired = official.wired + legacyWired + genericWired
|
|
1071
1094
|
if (wired > 0) paintLastRun('上次结果:')
|
|
1072
|
-
if (
|
|
1095
|
+
if (official.menuFound) {
|
|
1096
|
+
// 兜底:无论尺寸变化是谁造成的(我们加/删元素、官方自身重渲染、状态条文案变长),
|
|
1097
|
+
// 只要实测尺寸变了,就立刻让官方重新锚定,绝不把这个问题留给用户的下一次滚动。
|
|
1098
|
+
const sizeChanged = officialMenuSizeChanged()
|
|
1099
|
+
if (mutatedThisPass || sizeChanged) reanchorOfficialMenu(sizeChanged)
|
|
1100
|
+
}
|
|
1073
1101
|
|
|
1074
1102
|
const menuVisible = official.menuFound || menu !== null
|
|
1075
1103
|
reportDiagnostics({
|
package/package.json
CHANGED