dsh-pick 0.2.3 → 0.2.5
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 +4 -3
- package/package.json +1 -1
- package/plugin/client.js +160 -6
- package/plugin/index.js +152 -0
- package/web/panel.html +105 -21
- package/web/panel.js +2 -2
package/README.md
CHANGED
|
@@ -38,7 +38,8 @@ npm 官网和各类 stat 站能看数字,但看数字回答不了「我该装
|
|
|
38
38
|
dsh plugin --profile web add dsh-pick
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
装完重启 `dsh web
|
|
41
|
+
装完重启 `dsh web`,在**右侧栏**的引导页点「选插件」,就是完整的选插件面板(**设置 → dsh-pick** 里也暂时保留一份)。
|
|
42
|
+
面板顶部一行:插件名、当前版本号、更新按钮,最右侧是卸载按钮——更新和卸载都交给 DSH 自己的插件管理器,完成后重启 DSH 生效。
|
|
42
43
|
|
|
43
44
|
首次使用要先生成目录(在 dsh-pick 的安装目录下,或任意目录):
|
|
44
45
|
|
|
@@ -95,8 +96,8 @@ dsh-pick/
|
|
|
95
96
|
├── data/catalog.json 目录产物
|
|
96
97
|
├── plugin/
|
|
97
98
|
│ ├── index.js DSH 宿主端:挂 /api-dsh-pick/* 路由
|
|
98
|
-
│ ├── client.js 设置页面板(iframe 复用 web/panel.html)
|
|
99
|
-
│ └── cordis.patch.yml
|
|
99
|
+
│ ├── client.js 右侧栏页签 + 设置页面板(iframe 复用 web/panel.html)
|
|
100
|
+
│ └── cordis.patch.yml 插进 DSH
|
|
100
101
|
└── web/
|
|
101
102
|
├── panel.html 选插件面板(独立调试用,也是插件内嵌的同一份)
|
|
102
103
|
└── panel.js 面板逻辑
|
package/package.json
CHANGED
package/plugin/client.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// plugin/client.js — dsh-pick 的设置页
|
|
3
3
|
//
|
|
4
4
|
// 手写单文件 bundle,没有构建链:由 dsh web 客户端的 ModuleLoader 注入
|
|
5
|
-
// (写法照 dsh-model / dsh-vps-manager
|
|
5
|
+
// (写法照 dsh-model / dsh-vps-manager)。挂两处:DSH 右侧栏的一个页签(主入口),
|
|
6
|
+
// 和「设置 → dsh-pick」(暂时保留,内容相同)。
|
|
6
7
|
//
|
|
7
8
|
// 界面本身就是一个 iframe,指向宿主路由 /api-dsh-pick/panel —— 面板那套 UI
|
|
8
9
|
// 是独立调试过的(dsh-pick serve 直接能开),这里原样复用,不再用 React 重写一遍。
|
|
@@ -29,9 +30,118 @@ window.__ModuleLoader__.load({
|
|
|
29
30
|
sub: 'var(--dsw-alias-label-secondary, #888)',
|
|
30
31
|
faint: 'var(--dsw-alias-label-tertiary, #999)',
|
|
31
32
|
border: 'var(--dsw-alias-border-l3, rgba(127,127,127,.25))',
|
|
33
|
+
accent: 'var(--dsw-alias-link, #2f6bff)',
|
|
34
|
+
danger: '#c94040',
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
// 和宿主通信:会改东西的请求用 JSON POST(宿主只收同源 JSON)
|
|
38
|
+
async function api(path, method = 'GET') {
|
|
39
|
+
const r = await fetch('/api-dsh-pick/' + path, {
|
|
40
|
+
method,
|
|
41
|
+
credentials: 'same-origin',
|
|
42
|
+
headers: method === 'POST' ? { 'content-type': 'application/json' } : undefined,
|
|
43
|
+
body: method === 'POST' ? '{}' : undefined,
|
|
44
|
+
})
|
|
45
|
+
return r.json()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function Btn({ onClick, disabled, danger, primary, title, children }) {
|
|
49
|
+
return h('button', {
|
|
50
|
+
type: 'button', onClick, disabled, title,
|
|
51
|
+
style: {
|
|
52
|
+
appearance: 'none', fontFamily: 'inherit', fontSize: 12, lineHeight: '18px',
|
|
53
|
+
padding: '2px 10px', borderRadius: 6, cursor: disabled ? 'default' : 'pointer',
|
|
54
|
+
opacity: disabled ? 0.6 : 1, whiteSpace: 'nowrap',
|
|
55
|
+
border: '1px solid ' + (danger ? C.danger : primary ? C.accent : C.border),
|
|
56
|
+
background: primary ? C.accent : 'transparent',
|
|
57
|
+
color: primary ? '#fff' : danger ? C.danger : C.text,
|
|
58
|
+
},
|
|
59
|
+
}, children)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** 标题行:dsh-pick · 版本号 · 更新 ……(最右)卸载 */
|
|
63
|
+
function HeaderBar() {
|
|
64
|
+
const [info, setInfo] = useState(null)
|
|
65
|
+
const [phase, setPhase] = useState('checking') // checking | idle | updating | updated | removing | removed
|
|
66
|
+
const [confirm, setConfirm] = useState(false)
|
|
67
|
+
const [msg, setMsg] = useState(null) // { text, command? }
|
|
68
|
+
|
|
69
|
+
const check = (force) => {
|
|
70
|
+
setPhase('checking')
|
|
71
|
+
api('update' + (force ? '?force=1' : ''))
|
|
72
|
+
.then(j => { setInfo(j); setPhase('idle') })
|
|
73
|
+
.catch(() => setPhase('idle'))
|
|
74
|
+
}
|
|
75
|
+
useEffect(() => { check(false) }, [])
|
|
76
|
+
|
|
77
|
+
const update = async () => {
|
|
78
|
+
setPhase('updating'); setMsg(null)
|
|
79
|
+
try {
|
|
80
|
+
const j = await api('update', 'POST')
|
|
81
|
+
if (j.ok) { setPhase('updated'); return }
|
|
82
|
+
setMsg({ text: j.message, command: j.command })
|
|
83
|
+
} catch (e) {
|
|
84
|
+
setMsg({ text: L('更新请求失败:', 'Update failed: ') + e.message })
|
|
85
|
+
}
|
|
86
|
+
setPhase('idle')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const uninstall = async () => {
|
|
90
|
+
setConfirm(false); setPhase('removing'); setMsg(null)
|
|
91
|
+
try {
|
|
92
|
+
const j = await api('uninstall', 'POST')
|
|
93
|
+
if (j.ok) { setPhase('removed'); return }
|
|
94
|
+
setMsg({ text: j.message, command: j.command })
|
|
95
|
+
setPhase('idle')
|
|
96
|
+
} catch {
|
|
97
|
+
// DSH 卸下插件时自己的接口也随之消失,请求多半就是这么断的
|
|
98
|
+
setPhase('removed')
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let upd
|
|
103
|
+
if (phase === 'updating') upd = { label: L('正在更新…', 'Updating…'), disabled: true }
|
|
104
|
+
else if (phase === 'updated') upd = { label: L('已更新,重启 DSH 生效', 'Updated; restart DSH'), disabled: true }
|
|
105
|
+
else if (info && info.restartPending) upd = { label: L(`v${info.restartPending} 已装好,重启 DSH 生效`, `v${info.restartPending} installed; restart DSH`), disabled: true }
|
|
106
|
+
else if (info && info.available) upd = { label: L(`更新到 v${info.latest}`, `Update to v${info.latest}`), primary: true, onClick: update }
|
|
107
|
+
else if (phase === 'checking') upd = { label: L('检查更新…', 'Checking…'), disabled: true }
|
|
108
|
+
else upd = {
|
|
109
|
+
label: info && info.latest ? L('已是最新', 'Up to date') : L('检查更新', 'Check for updates'),
|
|
110
|
+
onClick: () => check(true),
|
|
111
|
+
title: L('点一下重新检查', 'Click to check again'),
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const busy = phase === 'updating' || phase === 'removing' || phase === 'removed'
|
|
115
|
+
|
|
116
|
+
return h('div', { style: { marginBottom: 8 } },
|
|
117
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
|
|
118
|
+
h('span', { style: { fontSize: 15, fontWeight: 650 } }, 'dsh-pick'),
|
|
119
|
+
info && info.running ? h('span', { style: { fontSize: 12, color: C.sub, fontVariantNumeric: 'tabular-nums' } }, 'v' + info.running) : null,
|
|
120
|
+
h(Btn, { onClick: upd.onClick, disabled: upd.disabled || busy, primary: upd.primary, title: upd.title }, upd.label),
|
|
121
|
+
h('span', { style: { flex: 1 } }),
|
|
122
|
+
phase === 'removed'
|
|
123
|
+
? h('span', { style: { fontSize: 12, color: C.sub } }, L('已卸载,重启 DSH 后彻底移除', 'Uninstalled; restart DSH to finish'))
|
|
124
|
+
: phase === 'removing'
|
|
125
|
+
? h('span', { style: { fontSize: 12, color: C.sub } }, L('正在卸载…', 'Uninstalling…'))
|
|
126
|
+
: confirm
|
|
127
|
+
? h('span', { style: { display: 'inline-flex', gap: 6, alignItems: 'center' } },
|
|
128
|
+
h('span', { style: { fontSize: 12, color: C.sub } }, L('确定卸载?', 'Uninstall?')),
|
|
129
|
+
h(Btn, { danger: true, onClick: uninstall }, L('确认卸载', 'Confirm')),
|
|
130
|
+
h(Btn, { onClick: () => setConfirm(false) }, L('取消', 'Cancel')))
|
|
131
|
+
: h(Btn, { danger: true, disabled: busy, onClick: () => setConfirm(true) }, L('卸载', 'Uninstall')),
|
|
132
|
+
),
|
|
133
|
+
msg ? h('div', { style: { fontSize: 12, color: C.danger, marginTop: 6, lineHeight: 1.6 } },
|
|
134
|
+
msg.text,
|
|
135
|
+
msg.command ? h('code', { style: { display: 'block', marginTop: 4, color: C.text, userSelect: 'all' } }, msg.command) : null,
|
|
136
|
+
) : null,
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 面板本体。fill = 放在右侧栏里:占满栏高,iframe 自己滚动;
|
|
142
|
+
* 否则(设置页)iframe 跟着内容长高,由设置页滚动
|
|
143
|
+
*/
|
|
144
|
+
function PickPanel({ fill }) {
|
|
35
145
|
const frame = useRef(null)
|
|
36
146
|
const [meta, setMeta] = useState(null)
|
|
37
147
|
const [frameH, setFrameH] = useState(720)
|
|
@@ -46,6 +156,7 @@ window.__ModuleLoader__.load({
|
|
|
46
156
|
}, [])
|
|
47
157
|
|
|
48
158
|
useEffect(() => {
|
|
159
|
+
if (fill) return undefined
|
|
49
160
|
// iframe 里改不了高度(跨文档),用一个粗策略:内容高差太多就跟着长
|
|
50
161
|
const t = setInterval(() => {
|
|
51
162
|
try {
|
|
@@ -57,7 +168,7 @@ window.__ModuleLoader__.load({
|
|
|
57
168
|
} catch { /* 跨域就不管,保持默认高度 */ }
|
|
58
169
|
}, 1500)
|
|
59
170
|
return () => clearInterval(t)
|
|
60
|
-
}, [frameH])
|
|
171
|
+
}, [frameH, fill])
|
|
61
172
|
|
|
62
173
|
const tip = !meta
|
|
63
174
|
? L('正在读取目录…', 'Loading catalog…')
|
|
@@ -67,7 +178,12 @@ window.__ModuleLoader__.load({
|
|
|
67
178
|
`${meta.total.toLocaleString()} plugins · ${meta.deepCount} with denoised metrics · as of ${meta.anchor}`)
|
|
68
179
|
: L('目录未生成:在 dsh-pick 目录跑一次 dsh-pick build', 'Catalog not built yet: run `dsh-pick build`')
|
|
69
180
|
|
|
70
|
-
return h('div', {
|
|
181
|
+
return h('div', {
|
|
182
|
+
style: fill
|
|
183
|
+
? { color: C.text, height: '100%', display: 'flex', flexDirection: 'column', padding: '10px 12px', boxSizing: 'border-box' }
|
|
184
|
+
: { color: C.text },
|
|
185
|
+
},
|
|
186
|
+
h(HeaderBar),
|
|
71
187
|
h('div', {
|
|
72
188
|
style: {
|
|
73
189
|
fontSize: 12, color: C.faint, margin: '2px 0 10px', lineHeight: 1.6,
|
|
@@ -80,7 +196,9 @@ window.__ModuleLoader__.load({
|
|
|
80
196
|
title: 'dsh-pick',
|
|
81
197
|
style: {
|
|
82
198
|
width: '100%',
|
|
83
|
-
height: frameH + 'px',
|
|
199
|
+
height: fill ? 'auto' : frameH + 'px',
|
|
200
|
+
flex: fill ? '1 1 0' : undefined,
|
|
201
|
+
minHeight: fill ? 0 : undefined,
|
|
84
202
|
border: '1px solid ' + C.border,
|
|
85
203
|
borderRadius: '10px',
|
|
86
204
|
background: 'transparent',
|
|
@@ -89,7 +207,7 @@ window.__ModuleLoader__.load({
|
|
|
89
207
|
}),
|
|
90
208
|
|
|
91
209
|
h('div', {
|
|
92
|
-
style: { fontSize: 11, color: C.faint, marginTop: 8, lineHeight: 1.7 },
|
|
210
|
+
style: { fontSize: 11, color: C.faint, marginTop: 8, lineHeight: 1.7, display: fill ? 'none' : undefined },
|
|
93
211
|
},
|
|
94
212
|
L(
|
|
95
213
|
'排名按周下载;日常基线已扣掉版本发布日与次日的拉取虚高,比原始下载量更接近真实使用量。' +
|
|
@@ -100,8 +218,44 @@ window.__ModuleLoader__.load({
|
|
|
100
218
|
)
|
|
101
219
|
}
|
|
102
220
|
|
|
221
|
+
// 右侧栏页签(DSH 0.2 起有右侧栏;老版本没有这个服务就只在设置页里)
|
|
222
|
+
const SIDEBAR_TAB_ID = 'dsh-pick/panel'
|
|
223
|
+
const SIDEBAR_KIND = 'dsh-pick'
|
|
224
|
+
const SidebarBody = () => h(PickPanel, { fill: true })
|
|
225
|
+
|
|
226
|
+
function PickIcon({ size = 16 }) {
|
|
227
|
+
return h('svg', { width: size, height: size, viewBox: '0 0 32 32', fill: 'none' },
|
|
228
|
+
h('path', { d: 'M6 22l6-7 5 5 9-11', stroke: 'currentColor', strokeWidth: 2.6, strokeLinecap: 'round', strokeLinejoin: 'round' }))
|
|
229
|
+
}
|
|
230
|
+
|
|
103
231
|
const injectSlots = ['slots']
|
|
104
232
|
function apply(ctx) {
|
|
233
|
+
try {
|
|
234
|
+
ctx.inject && ctx.inject(['sidebarRight', 'sidebarRightTabs'], (scope) => {
|
|
235
|
+
const tabs = (scope.get && scope.get('sidebarRightTabs')) || scope.sidebarRightTabs
|
|
236
|
+
if (!tabs || typeof tabs.register !== 'function') return
|
|
237
|
+
const effect = (fn, label) => (scope.effect ? scope.effect(fn, label) : fn())
|
|
238
|
+
effect(() => tabs.register({
|
|
239
|
+
id: SIDEBAR_TAB_ID,
|
|
240
|
+
kind: SIDEBAR_KIND,
|
|
241
|
+
priority: 'extension',
|
|
242
|
+
keepMounted: true,
|
|
243
|
+
title: () => 'dsh-pick',
|
|
244
|
+
guide: [{
|
|
245
|
+
id: 'dsh-pick',
|
|
246
|
+
order: 70,
|
|
247
|
+
title: () => L('选插件', 'Pick a plugin'),
|
|
248
|
+
description: () => L('说需求 → 找候选 → 多维比较 → 出结论', 'Describe a need, compare candidates, get a verdict'),
|
|
249
|
+
icon: PickIcon,
|
|
250
|
+
}],
|
|
251
|
+
}), 'dsh-pick: sidebar type')
|
|
252
|
+
const slots = scope.slots || ctx.slots
|
|
253
|
+
const body = () => slots.register({ name: 'sidebar.right.pane.tab', key: SIDEBAR_TAB_ID }, SidebarBody)
|
|
254
|
+
effect(() => (slots.inject ? slots.inject('sidebar.right.pane.tab', body) : body()), 'dsh-pick: sidebar body')
|
|
255
|
+
})
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.warn('[dsh-pick] 右侧栏注册失败', error)
|
|
258
|
+
}
|
|
105
259
|
try {
|
|
106
260
|
ctx.slots.inject('settings.section', () =>
|
|
107
261
|
ctx.slots.register(
|
package/plugin/index.js
CHANGED
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
// GET /api-dsh-pick/words.js 搜索词典
|
|
10
10
|
// GET /api-dsh-pick/catalog.json 目录(含排名、链接、去噪指标)
|
|
11
11
|
// GET /api-dsh-pick/meta 目录概要(更新时间、包数)
|
|
12
|
+
// GET /api-dsh-pick/update 本插件版本 + npm 上的最新版本
|
|
13
|
+
// POST /api-dsh-pick/update 更新到 npm 最新版(交给 DSH 的插件管理器)
|
|
14
|
+
// POST /api-dsh-pick/uninstall 从 DSH 卸载本插件
|
|
12
15
|
//
|
|
13
16
|
// 写法照 dsh-model(同机参考)与 dsh-vps-manager(同作者)的 plugin/index.js。
|
|
14
17
|
|
|
@@ -38,7 +41,82 @@ async function readPkgJson() {
|
|
|
38
41
|
return JSON.parse(await readFile(join(PKG_ROOT, 'package.json'), 'utf8'))
|
|
39
42
|
} catch {
|
|
40
43
|
return {}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const PACKAGE = 'dsh-pick'
|
|
48
|
+
// npm 官方源连不上(国内常见)就问镜像
|
|
49
|
+
const NPM_REGISTRIES = ['https://registry.npmjs.org', 'https://registry.npmmirror.com']
|
|
50
|
+
const VERSION_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/
|
|
51
|
+
|
|
52
|
+
/** a 比 b 新返回正数(x.y.z,预发布版比同号正式版旧) */
|
|
53
|
+
function compareVersions(a, b) {
|
|
54
|
+
const parse = v => {
|
|
55
|
+
const [core, pre = ''] = String(v || '').replace(/^v/, '').split('-', 2)
|
|
56
|
+
return { nums: core.split('.').map(n => parseInt(n, 10) || 0), pre }
|
|
57
|
+
}
|
|
58
|
+
const x = parse(a), y = parse(b)
|
|
59
|
+
for (let i = 0; i < 3; i++) {
|
|
60
|
+
const d = (x.nums[i] || 0) - (y.nums[i] || 0)
|
|
61
|
+
if (d) return d
|
|
62
|
+
}
|
|
63
|
+
if (x.pre === y.pre) return 0
|
|
64
|
+
if (!x.pre) return 1
|
|
65
|
+
if (!y.pre) return -1
|
|
66
|
+
return x.pre < y.pre ? -1 : 1
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** npm 上 latest 是哪个版本;10 分钟内复用上次的结果 */
|
|
70
|
+
let npmCache = null
|
|
71
|
+
async function latestOnNpm(force) {
|
|
72
|
+
if (!force && npmCache && Date.now() - npmCache.at < 10 * 60 * 1000) return npmCache.version
|
|
73
|
+
for (const registry of NPM_REGISTRIES) {
|
|
74
|
+
try {
|
|
75
|
+
const r = await fetch(`${registry}/${PACKAGE}/latest`, { signal: AbortSignal.timeout(6000) })
|
|
76
|
+
if (!r.ok) continue
|
|
77
|
+
const { version } = await r.json()
|
|
78
|
+
if (VERSION_RE.test(String(version || ''))) {
|
|
79
|
+
npmCache = { version, at: Date.now() }
|
|
80
|
+
return version
|
|
81
|
+
}
|
|
82
|
+
} catch { /* 换下一个源 */ }
|
|
83
|
+
}
|
|
84
|
+
return ''
|
|
41
85
|
}
|
|
86
|
+
|
|
87
|
+
/** 给用户自己在终端执行的命令:DSH 0.2 起 --profile 必填,且要写在 add / remove 前面 */
|
|
88
|
+
function pluginCommand(args, profile) {
|
|
89
|
+
return /^[A-Za-z0-9._-]+$/.test(profile || '') ? `dsh plugin --profile ${profile} ${args}` : `dsh plugin ${args}`
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** 插件管理器的失败结果 → 一行人话(取诊断输出的最后几行) */
|
|
93
|
+
function managerError(result) {
|
|
94
|
+
if (!(result && (result.application === 'failed' || result.application === 'cancelled' || result.error))) return ''
|
|
95
|
+
const code = (result.error && result.error.code) || result.application || 'failed'
|
|
96
|
+
const detail = String((result.error && result.error.diagnostic) || (result.packageResult && result.packageResult.output) || '')
|
|
97
|
+
.trim().split('\n').slice(-3).join(' ').slice(-300)
|
|
98
|
+
return detail ? `${code}:${detail}` : code
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function sendJson(res, status, body) {
|
|
102
|
+
res.writeHead(status, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' })
|
|
103
|
+
res.end(JSON.stringify(body))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 会改东西的请求(更新、卸载)只收同源的 JSON POST:
|
|
108
|
+
* 别的网站发不出带 application/json 的跨站请求(要预检),Origin 也对不上
|
|
109
|
+
*/
|
|
110
|
+
function isSafePost(req) {
|
|
111
|
+
if (req.method !== 'POST') return false
|
|
112
|
+
if (!String(req.headers['content-type'] || '').startsWith('application/json')) return false
|
|
113
|
+
const origin = req.headers.origin
|
|
114
|
+
if (!origin) return true
|
|
115
|
+
try {
|
|
116
|
+
return new URL(origin).host === req.headers.host
|
|
117
|
+
} catch {
|
|
118
|
+
return false
|
|
119
|
+
}
|
|
42
120
|
}
|
|
43
121
|
|
|
44
122
|
/** 目录概要:给面板顶部显示「更新时间 / 包数」用 */
|
|
@@ -61,6 +139,21 @@ export const name = 'dsh-pick'
|
|
|
61
139
|
export const inject = []
|
|
62
140
|
|
|
63
141
|
export function apply(ctx) {
|
|
142
|
+
// 启动时加载的版本;磁盘上的可能更新(更新了还没重启)
|
|
143
|
+
let running = ''
|
|
144
|
+
readPkgJson().then(p => { running = p.version || '' })
|
|
145
|
+
|
|
146
|
+
// DSH 自己的插件管理器(和 DSH「插件」页同一套:带锁跑 pnpm、失败自动还原)。老版本 DSH 没有
|
|
147
|
+
let pluginManager
|
|
148
|
+
ctx.inject(['pluginManager'], (pmCtx) => {
|
|
149
|
+
pluginManager = pmCtx.pluginManager || (pmCtx.get && pmCtx.get('pluginManager'))
|
|
150
|
+
})
|
|
151
|
+
// 当前 profile(官方桌面版 desktop,dsh web 是 web),只用来拼给用户手动执行的命令
|
|
152
|
+
let profile
|
|
153
|
+
try {
|
|
154
|
+
profile = ctx.get && ctx.get('profileContext') && ctx.get('profileContext').name
|
|
155
|
+
} catch { profile = undefined }
|
|
156
|
+
|
|
64
157
|
ctx.inject(['webServer'], (webCtx) => {
|
|
65
158
|
const ws = webCtx.webServer
|
|
66
159
|
if (!ws || typeof ws.register !== 'function') return
|
|
@@ -101,6 +194,65 @@ export function apply(ctx) {
|
|
|
101
194
|
},
|
|
102
195
|
}))
|
|
103
196
|
|
|
197
|
+
// 版本与更新
|
|
198
|
+
track(ws.register({
|
|
199
|
+
kind: 'exact',
|
|
200
|
+
path: '/api-dsh-pick/update',
|
|
201
|
+
handler: async (req, res) => {
|
|
202
|
+
if (req.method === 'GET') {
|
|
203
|
+
const force = /[?&]force=1/.test(req.url || '')
|
|
204
|
+
const [pkg, latest] = await Promise.all([readPkgJson(), latestOnNpm(force)])
|
|
205
|
+
const installed = pkg.version || ''
|
|
206
|
+
const current = compareVersions(installed, running) > 0 ? installed : running
|
|
207
|
+
return sendJson(res, 200, {
|
|
208
|
+
running,
|
|
209
|
+
restartPending: installed && running && compareVersions(installed, running) > 0 ? installed : '',
|
|
210
|
+
latest,
|
|
211
|
+
available: Boolean(latest) && compareVersions(latest, current) > 0,
|
|
212
|
+
canInstall: Boolean(pluginManager && typeof pluginManager.installBundle === 'function'),
|
|
213
|
+
command: pluginCommand(`add ${PACKAGE}@${latest || 'latest'}`, profile),
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
if (!isSafePost(req)) return sendJson(res, 403, { ok: false, message: '只接受本页面发出的请求' })
|
|
217
|
+
const latest = await latestOnNpm(true)
|
|
218
|
+
const command = pluginCommand(`add ${PACKAGE}@${latest || 'latest'}`, profile)
|
|
219
|
+
if (!latest) return sendJson(res, 200, { ok: false, message: '查不到 npm 上的最新版本,检查网络后再试', command })
|
|
220
|
+
if (compareVersions(latest, running) <= 0) return sendJson(res, 200, { ok: false, message: `已经是最新版 v${running}` })
|
|
221
|
+
if (!pluginManager || typeof pluginManager.installBundle !== 'function') {
|
|
222
|
+
return sendJson(res, 200, { ok: false, message: '这个版本的 DSH 不能在这里装插件,请在终端执行命令', command })
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
const result = await pluginManager.installBundle(`${PACKAGE}@${latest}`, { enabled: true })
|
|
226
|
+
const err = managerError(result)
|
|
227
|
+
if (err) return sendJson(res, 200, { ok: false, message: `更新失败(${err})`, command })
|
|
228
|
+
return sendJson(res, 200, { ok: true, version: latest })
|
|
229
|
+
} catch (e) {
|
|
230
|
+
return sendJson(res, 200, { ok: false, message: `更新失败:${e.message}`, command })
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
}))
|
|
234
|
+
|
|
235
|
+
// 卸载本插件
|
|
236
|
+
track(ws.register({
|
|
237
|
+
kind: 'exact',
|
|
238
|
+
path: '/api-dsh-pick/uninstall',
|
|
239
|
+
handler: async (req, res) => {
|
|
240
|
+
if (!isSafePost(req)) return sendJson(res, 403, { ok: false, message: '只接受本页面发出的请求' })
|
|
241
|
+
const command = pluginCommand(`remove ${PACKAGE}`, profile)
|
|
242
|
+
if (!pluginManager || typeof pluginManager.removeBundle !== 'function') {
|
|
243
|
+
return sendJson(res, 200, { ok: false, message: '这里没法直接卸载:完全退出 DSH 后在终端执行命令', command })
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
const result = await pluginManager.removeBundle(PACKAGE)
|
|
247
|
+
const err = managerError(result)
|
|
248
|
+
if (err) return sendJson(res, 200, { ok: false, message: `卸载失败(${err}),可完全退出 DSH 后在终端执行命令`, command })
|
|
249
|
+
return sendJson(res, 200, { ok: true })
|
|
250
|
+
} catch (e) {
|
|
251
|
+
return sendJson(res, 200, { ok: false, message: `卸载失败:${e.message}`, command })
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
}))
|
|
255
|
+
|
|
104
256
|
// 面板是内嵌在 dsh 设置页里的 iframe,同源即可,不需要额外令牌:
|
|
105
257
|
// 这些路由全都先过 dsh 的登录校验(挂在 dsh 自己的 webServer 上)。
|
|
106
258
|
})
|
package/web/panel.html
CHANGED
|
@@ -13,6 +13,41 @@
|
|
|
13
13
|
--ok:#0f9d58; --ok-bg:#e7f6ee;
|
|
14
14
|
--warn:#d97a06; --warn-bg:#fdf3e3;
|
|
15
15
|
--bad:#c94040; --bad-bg:#fdecec;
|
|
16
|
+
--input:#fcfcfd; --mute:#b9c2ce; --row-hover:#fafbfc; --accent-line:#c6d4f5;
|
|
17
|
+
--bar-bg:rgba(245,246,248,.92); --shadow:rgba(16,24,40,.09); --focus:rgba(47,107,255,.12);
|
|
18
|
+
--ok-text:#0b7a45; --warn-text:#a8620a; --bad-text:#a52f2f;
|
|
19
|
+
--ok-line:#bfe6d1; --warn-line:#f2ddb6; --bad-line:#f2cccc;
|
|
20
|
+
color-scheme:light;
|
|
21
|
+
}
|
|
22
|
+
/* 暗色:嵌在 DSH 里时由下面的脚本按 DSH 主题设 data-theme(并把 DSH 的颜色变量覆盖上来);
|
|
23
|
+
单独打开(dsh-pick serve)时跟随系统 */
|
|
24
|
+
:root[data-theme="dark"]{
|
|
25
|
+
--bg:#17181c; --panel:#212228; --line:rgba(255,255,255,.12); --soft:#2a2c33;
|
|
26
|
+
--text:#e9ebf0; --t2:#b3b9c4; --t3:#868d99;
|
|
27
|
+
--accent:#5b8cff; --accent-bg:rgba(91,140,255,.16);
|
|
28
|
+
--ok:#3ccf7f; --ok-bg:rgba(60,207,127,.13);
|
|
29
|
+
--warn:#f0a43a; --warn-bg:rgba(240,164,58,.13);
|
|
30
|
+
--bad:#f06b6b; --bad-bg:rgba(240,107,107,.13);
|
|
31
|
+
--input:#1b1c21; --mute:#5c626d; --row-hover:rgba(255,255,255,.04); --accent-line:rgba(91,140,255,.45);
|
|
32
|
+
--bar-bg:rgba(23,24,28,.9); --shadow:rgba(0,0,0,.4); --focus:rgba(91,140,255,.25);
|
|
33
|
+
--ok-text:#5fd99a; --warn-text:#f3b65e; --bad-text:#f58a8a;
|
|
34
|
+
--ok-line:rgba(60,207,127,.3); --warn-line:rgba(240,164,58,.3); --bad-line:rgba(240,107,107,.3);
|
|
35
|
+
color-scheme:dark;
|
|
36
|
+
}
|
|
37
|
+
@media (prefers-color-scheme: dark){
|
|
38
|
+
:root:not([data-theme="light"]){
|
|
39
|
+
--bg:#17181c; --panel:#212228; --line:rgba(255,255,255,.12); --soft:#2a2c33;
|
|
40
|
+
--text:#e9ebf0; --t2:#b3b9c4; --t3:#868d99;
|
|
41
|
+
--accent:#5b8cff; --accent-bg:rgba(91,140,255,.16);
|
|
42
|
+
--ok:#3ccf7f; --ok-bg:rgba(60,207,127,.13);
|
|
43
|
+
--warn:#f0a43a; --warn-bg:rgba(240,164,58,.13);
|
|
44
|
+
--bad:#f06b6b; --bad-bg:rgba(240,107,107,.13);
|
|
45
|
+
--input:#1b1c21; --mute:#5c626d; --row-hover:rgba(255,255,255,.04); --accent-line:rgba(91,140,255,.45);
|
|
46
|
+
--bar-bg:rgba(23,24,28,.9); --shadow:rgba(0,0,0,.4); --focus:rgba(91,140,255,.25);
|
|
47
|
+
--ok-text:#5fd99a; --warn-text:#f3b65e; --bad-text:#f58a8a;
|
|
48
|
+
--ok-line:rgba(60,207,127,.3); --warn-line:rgba(240,164,58,.3); --bad-line:rgba(240,107,107,.3);
|
|
49
|
+
color-scheme:dark;
|
|
50
|
+
}
|
|
16
51
|
}
|
|
17
52
|
*{box-sizing:border-box}
|
|
18
53
|
body{
|
|
@@ -24,7 +59,7 @@ body{
|
|
|
24
59
|
a{color:var(--accent);text-decoration:none}
|
|
25
60
|
|
|
26
61
|
/* ---------- 顶栏 ---------- */
|
|
27
|
-
.bar{position:sticky;top:0;z-index:40;background:
|
|
62
|
+
.bar{position:sticky;top:0;z-index:40;background:var(--bar-bg);backdrop-filter:blur(8px);
|
|
28
63
|
padding:16px 0 12px;border-bottom:1px solid var(--line);margin-bottom:22px}
|
|
29
64
|
.bar .top{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
|
|
30
65
|
.logo{width:38px;height:38px;border-radius:10px;background:var(--accent);color:#fff;
|
|
@@ -36,7 +71,7 @@ h1{margin:0;font-size:19px;font-weight:650;letter-spacing:-.2px}
|
|
|
36
71
|
.tabs{display:flex;gap:2px;margin-top:14px;background:var(--soft);border-radius:9px;padding:3px;width:max-content}
|
|
37
72
|
.tabs button{appearance:none;border:none;background:transparent;font-family:inherit;font-size:12.5px;
|
|
38
73
|
font-weight:600;color:var(--t3);padding:7px 16px;border-radius:6px;cursor:pointer}
|
|
39
|
-
.tabs button.on{background
|
|
74
|
+
.tabs button.on{background:var(--panel);color:var(--text);box-shadow:0 1px 2px var(--shadow)}
|
|
40
75
|
|
|
41
76
|
/* ---------- 选插件 ---------- */
|
|
42
77
|
.ask{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:22px;margin-bottom:18px}
|
|
@@ -44,24 +79,24 @@ h1{margin:0;font-size:19px;font-weight:650;letter-spacing:-.2px}
|
|
|
44
79
|
.ask .row{display:flex;gap:10px}
|
|
45
80
|
.ask input{
|
|
46
81
|
flex:1;appearance:none;border:1px solid var(--line);border-radius:10px;padding:13px 16px;
|
|
47
|
-
font-size:14.5px;font-family:inherit;background
|
|
82
|
+
font-size:14.5px;font-family:inherit;background:var(--input);color:var(--text)
|
|
48
83
|
}
|
|
49
|
-
.ask input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px
|
|
84
|
+
.ask input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--focus);background:var(--panel)}
|
|
50
85
|
.btn{appearance:none;border:1px solid var(--accent);background:var(--accent);color:#fff;font-family:inherit;
|
|
51
86
|
font-size:13.5px;font-weight:600;padding:0 22px;border-radius:10px;cursor:pointer;white-space:nowrap}
|
|
52
87
|
.btn:hover{filter:brightness(1.07)}
|
|
53
|
-
.btn.ghost{background
|
|
88
|
+
.btn.ghost{background:var(--panel);color:var(--accent)}
|
|
54
89
|
.btn.ghost:hover{background:var(--accent-bg);filter:none}
|
|
55
90
|
.btn:disabled{opacity:.5;cursor:default}
|
|
56
|
-
.cand .ok{font-size:9.5px;background:var(--ok-bg);color
|
|
57
|
-
.cand .nook{font-size:9.5px;background
|
|
91
|
+
.cand .ok{font-size:9.5px;background:var(--ok-bg);color:var(--ok-text);border-radius:20px;padding:1px 6px;font-weight:700;flex:none}
|
|
92
|
+
.cand .nook{font-size:9.5px;background:var(--soft);color:var(--t3);border-radius:20px;padding:1px 6px;flex:none}
|
|
58
93
|
.cand .rk{font-size:10.5px;color:var(--t3);margin:-2px 0 5px;font-variant-numeric:tabular-nums}
|
|
59
94
|
.cand .rk b{color:var(--t2);font-weight:700}
|
|
60
95
|
.cand .d{font-size:11.5px;color:var(--t2);margin:5px 0 8px;line-height:1.5;
|
|
61
96
|
display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
|
|
62
97
|
.links{display:flex;gap:6px;margin-top:9px;padding-top:9px;border-top:1px dashed var(--line)}
|
|
63
98
|
.lk{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;color:var(--t2);text-decoration:none;
|
|
64
|
-
border:1px solid var(--line);border-radius:6px;padding:2px 8px;background
|
|
99
|
+
border:1px solid var(--line);border-radius:6px;padding:2px 8px;background:var(--panel);transition:.15s}
|
|
65
100
|
.lk:hover{border-color:var(--accent);color:var(--accent);background:var(--accent-bg)}
|
|
66
101
|
.lk svg{flex:none}
|
|
67
102
|
.examples{display:flex;gap:8px;flex-wrap:wrap;margin-top:13px}
|
|
@@ -77,13 +112,13 @@ h1{margin:0;font-size:19px;font-weight:650;letter-spacing:-.2px}
|
|
|
77
112
|
.section .cap{margin:0 0 15px;font-size:12px;color:var(--t3)}
|
|
78
113
|
|
|
79
114
|
/* ---------- 候选卡 ---------- */
|
|
80
|
-
.cands{display:grid;grid-template-columns:repeat(auto-fill,minmax(330px,1fr));gap:11px}
|
|
81
|
-
.cand{border:1px solid var(--line);border-radius:11px;padding:13px 14px;background
|
|
115
|
+
.cands{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(330px,100%),1fr));gap:11px}
|
|
116
|
+
.cand{border:1px solid var(--line);border-radius:11px;padding:13px 14px;background:var(--input);
|
|
82
117
|
display:flex;gap:11px;cursor:pointer;transition:border-color .15s,background .15s;position:relative}
|
|
83
|
-
.cand:hover{border-color
|
|
118
|
+
.cand:hover{border-color:var(--accent-line)}
|
|
84
119
|
.cand.on{border-color:var(--accent);background:var(--accent-bg)}
|
|
85
|
-
.cand .box{width:17px;height:17px;border:1.5px solid
|
|
86
|
-
display:flex;align-items:center;justify-content:center;font-size:11px;color:#fff;background
|
|
120
|
+
.cand .box{width:17px;height:17px;border:1.5px solid var(--mute);border-radius:5px;flex:none;margin-top:2px;
|
|
121
|
+
display:flex;align-items:center;justify-content:center;font-size:11px;color:#fff;background:var(--panel)}
|
|
87
122
|
.cand.on .box{background:var(--accent);border-color:var(--accent)}
|
|
88
123
|
.cand .body{min-width:0;flex:1}
|
|
89
124
|
.cand .nm{font-size:13.5px;font-weight:650;display:flex;align-items:center;gap:7px;flex-wrap:wrap}
|
|
@@ -106,16 +141,16 @@ table.cmp thead th i{display:inline-block;width:8px;height:8px;border-radius:2px
|
|
|
106
141
|
table.cmp tbody tr:last-child td{border-bottom:none}
|
|
107
142
|
td.best{color:var(--ok);font-weight:700}
|
|
108
143
|
td.best::after{content:' ★';font-size:9px}
|
|
109
|
-
.miss{color
|
|
144
|
+
.miss{color:var(--mute)}
|
|
110
145
|
.num{font-variant-numeric:tabular-nums}
|
|
111
146
|
|
|
112
147
|
/* ---------- 结论 ---------- */
|
|
113
148
|
.verdict{border-radius:11px;padding:14px 16px;margin-bottom:11px;border:1px solid}
|
|
114
|
-
.verdict.win{background:var(--ok-bg);border-color
|
|
115
|
-
.verdict.alt{background:var(--warn-bg);border-color
|
|
116
|
-
.verdict.no{background:var(--bad-bg);border-color
|
|
149
|
+
.verdict.win{background:var(--ok-bg);border-color:var(--ok-line)}
|
|
150
|
+
.verdict.alt{background:var(--warn-bg);border-color:var(--warn-line)}
|
|
151
|
+
.verdict.no{background:var(--bad-bg);border-color:var(--bad-line)}
|
|
117
152
|
.verdict h4{margin:0 0 6px;font-size:13px;display:flex;align-items:center;gap:7px}
|
|
118
|
-
.verdict.win h4{color
|
|
153
|
+
.verdict.win h4{color:var(--ok-text)}.verdict.alt h4{color:var(--warn-text)}.verdict.no h4{color:var(--bad-text)}
|
|
119
154
|
.verdict p{margin:0;font-size:12.5px;color:var(--t2);line-height:1.7}
|
|
120
155
|
.verdict p b{color:var(--text);font-weight:650}
|
|
121
156
|
.rule{font-size:11.5px;color:var(--t3);margin-top:12px;padding-top:11px;border-top:1px dashed var(--line);line-height:1.8}
|
|
@@ -123,11 +158,11 @@ td.best::after{content:' ★';font-size:9px}
|
|
|
123
158
|
/* ---------- 排行榜 ---------- */
|
|
124
159
|
.filters{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:14px}
|
|
125
160
|
.filters select{appearance:none;border:1px solid var(--line);border-radius:8px;padding:7px 11px;
|
|
126
|
-
font-family:inherit;font-size:12.5px;background
|
|
161
|
+
font-family:inherit;font-size:12.5px;background:var(--panel);color:var(--t2);cursor:pointer}
|
|
127
162
|
table.rank{width:100%;border-collapse:collapse;font-size:12.5px}
|
|
128
163
|
table.rank th{text-align:left;font-size:11px;color:var(--t3);font-weight:600;padding:0 10px 9px;border-bottom:1px solid var(--line)}
|
|
129
164
|
table.rank td{padding:9px 10px;border-bottom:1px solid var(--soft);color:var(--t2);font-variant-numeric:tabular-nums}
|
|
130
|
-
table.rank tbody tr:hover td{background
|
|
165
|
+
table.rank tbody tr:hover td{background:var(--row-hover)}
|
|
131
166
|
table.rank td.nm{color:var(--text);font-weight:650;font-variant-numeric:normal}
|
|
132
167
|
td.r,th.r{text-align:right}
|
|
133
168
|
td.up{color:var(--ok);font-weight:600}
|
|
@@ -147,14 +182,63 @@ td.down{color:var(--bad);font-weight:600}
|
|
|
147
182
|
.foot{font-size:11.5px;color:var(--t3);line-height:1.9;margin-top:6px}
|
|
148
183
|
.foot b{color:var(--t2);font-weight:650}
|
|
149
184
|
.spark{display:inline-flex;align-items:flex-end;gap:1px;height:16px;vertical-align:middle}
|
|
150
|
-
.spark i{width:3px;background
|
|
185
|
+
.spark i{width:3px;background:var(--mute);border-radius:1px;display:block}
|
|
151
186
|
.hidden{display:none!important}
|
|
152
187
|
@media(max-width:720px){
|
|
153
188
|
body{padding:0 12px 48px}
|
|
154
189
|
.meta{margin-left:0;text-align:left;width:100%}
|
|
155
190
|
.ask{padding:17px}
|
|
156
191
|
}
|
|
192
|
+
/* 右侧栏这种窄宽度 */
|
|
193
|
+
@media(max-width:480px){
|
|
194
|
+
body{padding:0 8px 40px}
|
|
195
|
+
.tagline{display:none}
|
|
196
|
+
.tabs{width:auto}
|
|
197
|
+
.tabs button{padding:7px 10px}
|
|
198
|
+
.ask .row{flex-direction:column}
|
|
199
|
+
.ask .row .btn{padding:10px 0}
|
|
200
|
+
.section{padding:15px 13px}
|
|
201
|
+
}
|
|
157
202
|
</style>
|
|
203
|
+
<script>
|
|
204
|
+
// 嵌在 DSH 里(同源 iframe)时跟着 DSH 的主题走:
|
|
205
|
+
// DSH 暗色时在 body 上挂 data-ds-dark-theme,颜色变量(--dsw-alias-*)也写在 body 上。
|
|
206
|
+
// 这里把明暗同步过来,再把 DSH 的底色、文字、边框、链接色覆盖到面板自己的变量上;DSH 一切换就跟着重算。
|
|
207
|
+
(function () {
|
|
208
|
+
var host
|
|
209
|
+
try { host = window.parent !== window && window.parent.document && window.parent.document.body } catch (e) { host = null }
|
|
210
|
+
if (!host) return
|
|
211
|
+
var MAP = {
|
|
212
|
+
'--bg': '--dsw-alias-bg-base',
|
|
213
|
+
'--panel': '--dsw-alias-bg-layer-2',
|
|
214
|
+
'--soft': '--dsw-alias-bg-module-platform',
|
|
215
|
+
'--line': '--dsw-alias-border-l2',
|
|
216
|
+
'--text': '--dsw-alias-label-primary',
|
|
217
|
+
'--t2': '--dsw-alias-label-secondary',
|
|
218
|
+
'--t3': '--dsw-alias-label-tertiary',
|
|
219
|
+
'--accent': '--dsw-alias-link',
|
|
220
|
+
}
|
|
221
|
+
var root = document.documentElement
|
|
222
|
+
function sync() {
|
|
223
|
+
var dark = host.hasAttribute('data-ds-dark-theme')
|
|
224
|
+
root.setAttribute('data-theme', dark ? 'dark' : 'light')
|
|
225
|
+
var cs = window.parent.getComputedStyle(host)
|
|
226
|
+
for (var k in MAP) {
|
|
227
|
+
var v = cs.getPropertyValue(MAP[k]).trim()
|
|
228
|
+
if (v) root.style.setProperty(k, v)
|
|
229
|
+
else root.style.removeProperty(k)
|
|
230
|
+
}
|
|
231
|
+
// 顶栏半透明底色跟着底色走
|
|
232
|
+
var bg = cs.getPropertyValue(MAP['--bg']).trim()
|
|
233
|
+
if (bg) root.style.setProperty('--bar-bg', 'color-mix(in srgb, ' + bg + ' 92%, transparent)')
|
|
234
|
+
else root.style.removeProperty('--bar-bg')
|
|
235
|
+
}
|
|
236
|
+
sync()
|
|
237
|
+
try {
|
|
238
|
+
new window.parent.MutationObserver(sync).observe(host, { attributes: true, attributeFilter: ['data-ds-dark-theme', 'style', 'class'] })
|
|
239
|
+
} catch (e) { /* 观察不了就只在打开时同步一次 */ }
|
|
240
|
+
})()
|
|
241
|
+
</script>
|
|
158
242
|
</head>
|
|
159
243
|
<body>
|
|
160
244
|
<div class="wrap">
|
package/web/panel.js
CHANGED
|
@@ -223,7 +223,7 @@ function renderCompare() {
|
|
|
223
223
|
|
|
224
224
|
$('#cmpNote').innerHTML =
|
|
225
225
|
`健康度 = 日常基线 40% + 增速 25% + 新鲜度 20% + 版本节奏 15%,满分 100。` +
|
|
226
|
-
(missingDeep ? `<br><span style="color
|
|
226
|
+
(missingDeep ? `<br><span style="color:var(--warn-text)">其中 ${missingDeep} 个未进入深挖范围(周下载 Top 榜外),去噪指标缺失,无法参与健康度比较。</span>` : '')
|
|
227
227
|
|
|
228
228
|
sec.classList.remove('hidden')
|
|
229
229
|
renderVerdict()
|
|
@@ -375,7 +375,7 @@ function renderWatch() {
|
|
|
375
375
|
const w = Math.max(Math.log10(r.w + 1) / Math.log10(max + 1) * 100, 1.5)
|
|
376
376
|
return `<div class="hrow" style="display:grid;grid-template-columns:210px 1fr 78px;align-items:center;gap:12px;padding:6px 0">` +
|
|
377
377
|
`<div style="font-size:12px;color:var(--t2);text-align:right;white-space:nowrap;overflow:hidden;text-overflow:ellipsis"><i style="display:inline-block;width:8px;height:8px;border-radius:2px;background:${colorOf(i)};margin-right:6px"></i>${esc(r.n)} <span style="color:var(--t3);font-size:10px">#${num(r.rank)}</span></div>` +
|
|
378
|
-
`<div style="height:14px;background
|
|
378
|
+
`<div style="height:14px;background:var(--soft);border-radius:4px"><div style="height:100%;width:${w}%;background:${colorOf(i)};border-radius:4px"></div></div>` +
|
|
379
379
|
`<div style="font-size:12px;font-weight:650;text-align:right">${num(r.w)}</div></div>`
|
|
380
380
|
}).join('')
|
|
381
381
|
}
|