dsh-pick 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 +3 -2
- package/package.json +1 -1
- package/plugin/client.js +78 -67
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`,在**右侧栏**的引导页点「选插件」,就是完整的选插件面板。
|
|
42
|
+
**设置 → dsh-pick** 是精简页:版本 / 更新 / 卸载、怎么打开面板、数据口径。
|
|
42
43
|
面板顶部一行:插件名、当前版本号、更新按钮,最右侧是卸载按钮——更新和卸载都交给 DSH 自己的插件管理器,完成后重启 DSH 生效。
|
|
43
44
|
|
|
44
45
|
首次使用要先生成目录(在 dsh-pick 的安装目录下,或任意目录):
|
|
@@ -96,7 +97,7 @@ dsh-pick/
|
|
|
96
97
|
├── data/catalog.json 目录产物
|
|
97
98
|
├── plugin/
|
|
98
99
|
│ ├── index.js DSH 宿主端:挂 /api-dsh-pick/* 路由
|
|
99
|
-
│ ├── client.js
|
|
100
|
+
│ ├── client.js 右侧栏页签(iframe 复用 web/panel.html)+ 设置页精简版
|
|
100
101
|
│ └── cordis.patch.yml 插进 DSH
|
|
101
102
|
└── web/
|
|
102
103
|
├── panel.html 选插件面板(独立调试用,也是插件内嵌的同一份)
|
package/package.json
CHANGED
package/plugin/client.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// plugin/client.js — dsh-pick 的设置页
|
|
3
3
|
//
|
|
4
4
|
// 手写单文件 bundle,没有构建链:由 dsh web 客户端的 ModuleLoader 注入
|
|
5
|
-
// (写法照 dsh-model / dsh-vps-manager)。挂两处:DSH
|
|
6
|
-
// 和「设置 → dsh-pick
|
|
5
|
+
// (写法照 dsh-model / dsh-vps-manager)。挂两处:DSH 右侧栏的一个页签(完整面板),
|
|
6
|
+
// 和「设置 → dsh-pick」(精简版:版本 / 更新 / 卸载、怎么打开、数据口径)。
|
|
7
7
|
//
|
|
8
8
|
// 界面本身就是一个 iframe,指向宿主路由 /api-dsh-pick/panel —— 面板那套 UI
|
|
9
9
|
// 是独立调试过的(dsh-pick serve 直接能开),这里原样复用,不再用 React 重写一遍。
|
|
@@ -15,7 +15,7 @@ window.__ModuleLoader__.load({
|
|
|
15
15
|
const module = { exports: {} }
|
|
16
16
|
const React = require('react')
|
|
17
17
|
const h = React.createElement
|
|
18
|
-
const { useEffect,
|
|
18
|
+
const { useEffect, useState } = React
|
|
19
19
|
|
|
20
20
|
// 语言:跟着页面(dsh 只有中、英两种)
|
|
21
21
|
const isZh = () => {
|
|
@@ -137,83 +137,90 @@ window.__ModuleLoader__.load({
|
|
|
137
137
|
)
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
/**
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
/** 右侧栏里的完整面板:标题行 + 占满栏高的 iframe(iframe 自己滚动;目录信息面板里自带) */
|
|
141
|
+
function PickPanel() {
|
|
142
|
+
return h('div', {
|
|
143
|
+
style: { color: C.text, height: '100%', display: 'flex', flexDirection: 'column', padding: '10px 12px', boxSizing: 'border-box' },
|
|
144
|
+
},
|
|
145
|
+
h(HeaderBar),
|
|
146
|
+
h('iframe', {
|
|
147
|
+
src: '/api-dsh-pick/panel',
|
|
148
|
+
title: 'dsh-pick',
|
|
149
|
+
style: {
|
|
150
|
+
width: '100%',
|
|
151
|
+
flex: '1 1 0',
|
|
152
|
+
minHeight: 0,
|
|
153
|
+
border: '1px solid ' + C.border,
|
|
154
|
+
borderRadius: '10px',
|
|
155
|
+
background: 'transparent',
|
|
156
|
+
display: 'block',
|
|
157
|
+
},
|
|
158
|
+
}),
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 数据口径说明:面板底部原来那段,现在放在设置页
|
|
163
|
+
const DATA_NOTE = () => L(
|
|
164
|
+
'排名按周下载;日常基线已扣掉版本发布日与次日的拉取虚高,比原始下载量更接近真实使用量。' +
|
|
165
|
+
'下载量含 CI / 镜像 / 爬虫流量,不等于用户数。npm 统计约滞后 5 天。',
|
|
166
|
+
'Ranks are weekly downloads; daily baseline strips the publish-day spike and is closer to real use. ' +
|
|
167
|
+
'Download counts include CI/mirror/crawler traffic, not real users. npm stats lag about 5 days.')
|
|
168
|
+
|
|
169
|
+
/** 右侧栏的服务(apply 里拿到);老版本 DSH 没有 */
|
|
170
|
+
let sidebarRightApi = null
|
|
171
|
+
|
|
172
|
+
function Section({ title, children }) {
|
|
173
|
+
return h('div', { style: { marginTop: 18 } },
|
|
174
|
+
h('div', { style: { fontSize: 13, fontWeight: 600, marginBottom: 6 } }, title),
|
|
175
|
+
h('div', { style: { fontSize: 12.5, color: C.sub, lineHeight: 1.7 } }, children))
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** 设置页:完整面板在右侧栏,这里只放管理和说明 */
|
|
179
|
+
function SettingsSection() {
|
|
146
180
|
const [meta, setMeta] = useState(null)
|
|
147
|
-
const [
|
|
181
|
+
const [openMsg, setOpenMsg] = useState('')
|
|
148
182
|
|
|
149
183
|
useEffect(() => {
|
|
150
184
|
let alive = true
|
|
151
|
-
|
|
152
|
-
.then(r => r.json())
|
|
153
|
-
.then(j => { if (alive) setMeta(j) })
|
|
154
|
-
.catch(() => {})
|
|
185
|
+
api('meta').then(j => { if (alive) setMeta(j) }).catch(() => {})
|
|
155
186
|
return () => { alive = false }
|
|
156
187
|
}, [])
|
|
157
188
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
} catch { /* 跨域就不管,保持默认高度 */ }
|
|
169
|
-
}, 1500)
|
|
170
|
-
return () => clearInterval(t)
|
|
171
|
-
}, [frameH, fill])
|
|
189
|
+
const openSidebar = () => {
|
|
190
|
+
try {
|
|
191
|
+
sidebarRightApi.openTab(SIDEBAR_KIND)
|
|
192
|
+
setOpenMsg(L('已在右侧栏打开,关闭设置就能看到', 'Opened in the right sidebar; close Settings to see it'))
|
|
193
|
+
} catch {
|
|
194
|
+
// 右侧栏是跟着对话走的:没有打开的对话时开不了
|
|
195
|
+
setOpenMsg(L('先回到一个对话,再从右侧栏打开', 'Go back to a conversation first, then open it from the right sidebar'))
|
|
196
|
+
}
|
|
197
|
+
}
|
|
172
198
|
|
|
173
|
-
const
|
|
199
|
+
const catalog = !meta
|
|
174
200
|
? L('正在读取目录…', 'Loading catalog…')
|
|
175
201
|
: meta.total
|
|
176
202
|
? L(
|
|
177
|
-
|
|
178
|
-
`${meta.total.toLocaleString()} plugins
|
|
203
|
+
`目录收录 ${meta.total.toLocaleString()} 个插件,其中 ${meta.deepCount} 个有去噪指标;数据截止 ${meta.anchor}。`,
|
|
204
|
+
`${meta.total.toLocaleString()} plugins in the catalog, ${meta.deepCount} with denoised metrics; data as of ${meta.anchor}.`)
|
|
179
205
|
: L('目录未生成:在 dsh-pick 目录跑一次 dsh-pick build', 'Catalog not built yet: run `dsh-pick build`')
|
|
180
206
|
|
|
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
|
-
},
|
|
207
|
+
return h('div', { style: { color: C.text } },
|
|
186
208
|
h(HeaderBar),
|
|
187
|
-
h('div', {
|
|
188
|
-
style: {
|
|
189
|
-
fontSize: 12, color: C.faint, margin: '2px 0 10px', lineHeight: 1.6,
|
|
190
|
-
},
|
|
191
|
-
}, tip),
|
|
192
209
|
|
|
193
|
-
h('
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
borderRadius: '10px',
|
|
204
|
-
background: 'transparent',
|
|
205
|
-
display: 'block',
|
|
206
|
-
},
|
|
207
|
-
}),
|
|
210
|
+
h(Section, { title: L('怎么打开', 'How to open') },
|
|
211
|
+
h('div', null, L(
|
|
212
|
+
'选插件面板在对话页的右侧栏:打开右侧栏,在引导页里点「选插件」。',
|
|
213
|
+
'The picker lives in the conversation\'s right sidebar: open the sidebar and choose "Pick a plugin" on its guide page.')),
|
|
214
|
+
sidebarRightApi
|
|
215
|
+
? h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 8, flexWrap: 'wrap' } },
|
|
216
|
+
h(Btn, { onClick: openSidebar }, L('在右侧栏打开', 'Open in right sidebar')),
|
|
217
|
+
openMsg ? h('span', { style: { fontSize: 12, color: C.faint } }, openMsg) : null)
|
|
218
|
+
: null,
|
|
219
|
+
),
|
|
208
220
|
|
|
209
|
-
h('
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
L(
|
|
213
|
-
'排名按周下载;日常基线已扣掉版本发布日与次日的拉取虚高,比原始下载量更接近真实使用量。' +
|
|
214
|
-
'下载量含 CI / 镜像 / 爬虫流量,不等于用户数。',
|
|
215
|
-
'Ranks are weekly downloads; daily baseline strips the publish-day spike. ' +
|
|
216
|
-
'Download counts include CI/mirror traffic, not real users.'),
|
|
221
|
+
h(Section, { title: L('数据口径', 'About the data') },
|
|
222
|
+
h('div', null, catalog),
|
|
223
|
+
h('div', { style: { marginTop: 4 } }, DATA_NOTE()),
|
|
217
224
|
),
|
|
218
225
|
)
|
|
219
226
|
}
|
|
@@ -221,7 +228,6 @@ window.__ModuleLoader__.load({
|
|
|
221
228
|
// 右侧栏页签(DSH 0.2 起有右侧栏;老版本没有这个服务就只在设置页里)
|
|
222
229
|
const SIDEBAR_TAB_ID = 'dsh-pick/panel'
|
|
223
230
|
const SIDEBAR_KIND = 'dsh-pick'
|
|
224
|
-
const SidebarBody = () => h(PickPanel, { fill: true })
|
|
225
231
|
|
|
226
232
|
function PickIcon({ size = 16 }) {
|
|
227
233
|
return h('svg', { width: size, height: size, viewBox: '0 0 32 32', fill: 'none' },
|
|
@@ -232,6 +238,7 @@ window.__ModuleLoader__.load({
|
|
|
232
238
|
function apply(ctx) {
|
|
233
239
|
try {
|
|
234
240
|
ctx.inject && ctx.inject(['sidebarRight', 'sidebarRightTabs'], (scope) => {
|
|
241
|
+
const right = (scope.get && scope.get('sidebarRight')) || scope.sidebarRight
|
|
235
242
|
const tabs = (scope.get && scope.get('sidebarRightTabs')) || scope.sidebarRightTabs
|
|
236
243
|
if (!tabs || typeof tabs.register !== 'function') return
|
|
237
244
|
const effect = (fn, label) => (scope.effect ? scope.effect(fn, label) : fn())
|
|
@@ -250,8 +257,12 @@ window.__ModuleLoader__.load({
|
|
|
250
257
|
}],
|
|
251
258
|
}), 'dsh-pick: sidebar type')
|
|
252
259
|
const slots = scope.slots || ctx.slots
|
|
253
|
-
const body = () => slots.register({ name: 'sidebar.right.pane.tab', key: SIDEBAR_TAB_ID },
|
|
260
|
+
const body = () => slots.register({ name: 'sidebar.right.pane.tab', key: SIDEBAR_TAB_ID }, PickPanel)
|
|
254
261
|
effect(() => (slots.inject ? slots.inject('sidebar.right.pane.tab', body) : body()), 'dsh-pick: sidebar body')
|
|
262
|
+
if (right && typeof right.openTab === 'function') {
|
|
263
|
+
sidebarRightApi = right
|
|
264
|
+
effect(() => () => { if (sidebarRightApi === right) sidebarRightApi = null }, 'dsh-pick: sidebar api')
|
|
265
|
+
}
|
|
255
266
|
})
|
|
256
267
|
} catch (error) {
|
|
257
268
|
console.warn('[dsh-pick] 右侧栏注册失败', error)
|
|
@@ -260,7 +271,7 @@ window.__ModuleLoader__.load({
|
|
|
260
271
|
ctx.slots.inject('settings.section', () =>
|
|
261
272
|
ctx.slots.register(
|
|
262
273
|
{ name: 'settings.section', id: 'dsh-pick', order: 30, label: () => 'dsh-pick' },
|
|
263
|
-
|
|
274
|
+
SettingsSection,
|
|
264
275
|
))
|
|
265
276
|
} catch (error) {
|
|
266
277
|
console.warn('[dsh-pick] 设置页注册失败', error)
|