dsh-plugin-discovery 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +70 -3
- package/client.js +1409 -0
- package/cordis.patch.yml +10 -0
- package/docs/articles/csdn.md +59 -0
- package/docs/articles/juejin.md +52 -0
- package/docs/articles/zhihu.md +50 -0
- package/docs/images/discover-installed.jpg +0 -0
- package/docs/images/discover-search.png +0 -0
- package/docs/images/discover-status.jpg +0 -0
- package/icon.svg +5 -0
- package/index.js +528 -0
- package/locale/en.json +22 -0
- package/locale/zh.json +22 -0
- package/mark-remote.js +48 -0
- package/package.json +70 -6
- package/skill/SKILL.md +24 -0
package/client.js
ADDED
|
@@ -0,0 +1,1409 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-plugin-discovery",
|
|
3
|
+
factory(require) {
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const h = React.createElement;
|
|
6
|
+
const NS = "pluginDiscoveryUi";
|
|
7
|
+
const PANEL_ID = "plugin-discovery";
|
|
8
|
+
const PAGE_SIZE = 8;
|
|
9
|
+
const DEFAULT_QUERY = "dsh-pet";
|
|
10
|
+
|
|
11
|
+
const zh = {
|
|
12
|
+
panel: "发现插件",
|
|
13
|
+
intro: "社区插件非 DeepSeek 官方维护,安装前请自行审阅仓库与权限。",
|
|
14
|
+
searchPlaceholder: "搜索关键词,例如:网采、壁纸、dsh",
|
|
15
|
+
search: "搜索",
|
|
16
|
+
searching: "正在加载…",
|
|
17
|
+
searchCardTitle: "关键词搜索",
|
|
18
|
+
searchCardDesc: "按关键词浏览社区候选;安装前会校验是否为 DSH Bundle。",
|
|
19
|
+
sourceAll: "全部",
|
|
20
|
+
sourceNpm: "npm",
|
|
21
|
+
sourceGithub: "GitHub",
|
|
22
|
+
noResults: "未找到相关插件,试试换个关键词。",
|
|
23
|
+
browseHint: "浏览社区候选包;安装前会自动校验是否为 DSH Bundle。",
|
|
24
|
+
install: "安装",
|
|
25
|
+
installing: "安装中…",
|
|
26
|
+
installedBadge: "已安装",
|
|
27
|
+
installingBadge: "安装中",
|
|
28
|
+
notInstalledBadge: "未安装",
|
|
29
|
+
alreadyInstalled: "已安装",
|
|
30
|
+
open: "打开",
|
|
31
|
+
inspectFailed: "无法校验或不是 DSH Bundle",
|
|
32
|
+
resolvePlaceholder: "粘贴完整链接,如 https://github.com/user/repo",
|
|
33
|
+
resolve: "解析安装",
|
|
34
|
+
resolveCardTitle: "链接安装",
|
|
35
|
+
resolveCardDesc: "粘贴已知 npm / GitHub 地址直接解析安装;关键词请用上方搜索。",
|
|
36
|
+
resolveHint: "下方仅用于安装已知仓库;关键词请点上方「搜索」",
|
|
37
|
+
pagePrev: "上一页",
|
|
38
|
+
pageNext: "下一页",
|
|
39
|
+
pageStatus: "第 {page} / {pages} 页 · 共 {total} 项",
|
|
40
|
+
sourceNpmBadge: "npm",
|
|
41
|
+
sourceGithubBadge: "GitHub",
|
|
42
|
+
stars: "{n} stars",
|
|
43
|
+
emptyTitle: "还没有列表",
|
|
44
|
+
loadFailed: "加载失败",
|
|
45
|
+
installed: "安装完成,请到「插件」页查看。",
|
|
46
|
+
installProgress: "正在安装 {spec}…",
|
|
47
|
+
installPhase: "安装进度:{phase}",
|
|
48
|
+
installLog: "安装输出:{text}",
|
|
49
|
+
installFailed: "安装失败",
|
|
50
|
+
retry: "重试",
|
|
51
|
+
};
|
|
52
|
+
const en = {
|
|
53
|
+
panel: "Discover",
|
|
54
|
+
intro: "Community plugins are not official; review the repo before installing.",
|
|
55
|
+
searchPlaceholder: "Keywords, e.g. scraping, wallpaper, dsh",
|
|
56
|
+
search: "Search",
|
|
57
|
+
searching: "Loading…",
|
|
58
|
+
searchCardTitle: "Keyword search",
|
|
59
|
+
searchCardDesc: "Browse community candidates; install verifies DSH Bundle metadata.",
|
|
60
|
+
sourceAll: "All",
|
|
61
|
+
sourceNpm: "npm",
|
|
62
|
+
sourceGithub: "GitHub",
|
|
63
|
+
noResults: "No plugins matched. Try another keyword.",
|
|
64
|
+
browseHint: "Browse community packages; install verifies DSH Bundle metadata.",
|
|
65
|
+
install: "Install",
|
|
66
|
+
installing: "Installing…",
|
|
67
|
+
installedBadge: "Installed",
|
|
68
|
+
installingBadge: "Installing",
|
|
69
|
+
notInstalledBadge: "Not installed",
|
|
70
|
+
alreadyInstalled: "Installed",
|
|
71
|
+
open: "Open",
|
|
72
|
+
inspectFailed: "Not a DSH Bundle or inspect failed",
|
|
73
|
+
resolvePlaceholder: "Paste full URL, e.g. https://github.com/user/repo",
|
|
74
|
+
resolve: "Install",
|
|
75
|
+
resolveCardTitle: "Install from link",
|
|
76
|
+
resolveCardDesc: "Paste a known npm / GitHub URL to resolve and install.",
|
|
77
|
+
resolveHint: "Bottom row installs a known repo; use Search above for keywords",
|
|
78
|
+
pagePrev: "Previous",
|
|
79
|
+
pageNext: "Next",
|
|
80
|
+
pageStatus: "Page {page} / {pages} · {total} items",
|
|
81
|
+
sourceNpmBadge: "npm",
|
|
82
|
+
sourceGithubBadge: "GitHub",
|
|
83
|
+
stars: "{n} stars",
|
|
84
|
+
emptyTitle: "Nothing here yet",
|
|
85
|
+
loadFailed: "Failed to load",
|
|
86
|
+
installed: "Install finished. Check the Plugins panel.",
|
|
87
|
+
installProgress: "Installing {spec}…",
|
|
88
|
+
installPhase: "Progress: {phase}",
|
|
89
|
+
installLog: "Output: {text}",
|
|
90
|
+
installFailed: "Install failed",
|
|
91
|
+
retry: "Retry",
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
function format(template, vars) {
|
|
95
|
+
return String(template).replace(/\{(\w+)\}/g, (_, key) => (vars[key] == null ? "" : String(vars[key])));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function candidateKeys(item) {
|
|
99
|
+
// 仅保留精确标识,不把 @scope/name 拆成短名,避免 dsh-pet 与 @linxin666/dsh-pet 状态串线
|
|
100
|
+
const keys = [];
|
|
101
|
+
const push = (value) => {
|
|
102
|
+
if (!value) return;
|
|
103
|
+
const text = String(value).trim();
|
|
104
|
+
if (!text || keys.includes(text)) return;
|
|
105
|
+
keys.push(text);
|
|
106
|
+
const bare = text.replace(/^github:/i, "");
|
|
107
|
+
if (bare !== text && !keys.includes(bare)) keys.push(bare);
|
|
108
|
+
};
|
|
109
|
+
push(item.spec);
|
|
110
|
+
push(item.installSpec);
|
|
111
|
+
push(item.title);
|
|
112
|
+
push(item.name);
|
|
113
|
+
push(item.packageName);
|
|
114
|
+
return keys;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function isInstalledItem(item, installedNames) {
|
|
118
|
+
if (!installedNames || !installedNames.size) return false;
|
|
119
|
+
return candidateKeys(item).some((key) => installedNames.has(key));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const INSTALLED_CACHE_KEY = "dsh.pluginDiscovery.installedNames";
|
|
123
|
+
const JOB_CACHE_KEY = "dsh.pluginDiscovery.installJobs";
|
|
124
|
+
|
|
125
|
+
function readInstalledCache() {
|
|
126
|
+
try {
|
|
127
|
+
const raw = window.localStorage.getItem(INSTALLED_CACHE_KEY);
|
|
128
|
+
const list = raw ? JSON.parse(raw) : [];
|
|
129
|
+
return new Set(Array.isArray(list) ? list.filter(Boolean) : []);
|
|
130
|
+
} catch {
|
|
131
|
+
return new Set();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function writeInstalledCache(names) {
|
|
136
|
+
try {
|
|
137
|
+
window.localStorage.setItem(INSTALLED_CACHE_KEY, JSON.stringify([...names]));
|
|
138
|
+
} catch {
|
|
139
|
+
/* ignore */
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function readJobCache() {
|
|
144
|
+
try {
|
|
145
|
+
const raw = window.localStorage.getItem(JOB_CACHE_KEY);
|
|
146
|
+
const obj = raw ? JSON.parse(raw) : {};
|
|
147
|
+
return obj && typeof obj === "object" ? obj : {};
|
|
148
|
+
} catch {
|
|
149
|
+
return {};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function writeJobCache(jobs) {
|
|
154
|
+
try {
|
|
155
|
+
window.localStorage.setItem(JOB_CACHE_KEY, JSON.stringify(jobs));
|
|
156
|
+
} catch {
|
|
157
|
+
/* ignore */
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function newRequestId() {
|
|
162
|
+
return globalThis.crypto?.randomUUID?.() || `pd-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function jobMatchesItem(job, item) {
|
|
166
|
+
if (!job) return false;
|
|
167
|
+
const keys = new Set([...(job.keys || []), job.spec, job.packageName].filter(Boolean));
|
|
168
|
+
return candidateKeys(item).some((key) => keys.has(key));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function resolveItemStatus(item, installedNames, jobs) {
|
|
172
|
+
if (isInstalledItem(item, installedNames)) return { status: "installed", job: null };
|
|
173
|
+
const job = Object.values(jobs || {}).find((row) => jobMatchesItem(row, item));
|
|
174
|
+
if (job && job.status === "installing") return { status: "installing", job };
|
|
175
|
+
if (job && job.status === "failed") return { status: "failed", job };
|
|
176
|
+
return { status: "none", job: null };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function identitySchema() {
|
|
180
|
+
return {
|
|
181
|
+
parse(value) {
|
|
182
|
+
return value;
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function strictJson(typeSymbol) {
|
|
188
|
+
return {
|
|
189
|
+
mode: "strict",
|
|
190
|
+
typeSymbol,
|
|
191
|
+
create: identitySchema,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function PanelIcon(props) {
|
|
196
|
+
const size = props.size ?? 18;
|
|
197
|
+
return h(
|
|
198
|
+
"svg",
|
|
199
|
+
{
|
|
200
|
+
width: size,
|
|
201
|
+
height: size,
|
|
202
|
+
viewBox: "0 0 24 24",
|
|
203
|
+
fill: "none",
|
|
204
|
+
stroke: "currentColor",
|
|
205
|
+
strokeWidth: "1.8",
|
|
206
|
+
"aria-hidden": "true",
|
|
207
|
+
},
|
|
208
|
+
h("circle", { cx: "11", cy: "11", r: "7" }),
|
|
209
|
+
h("path", { d: "M20 20l-3.5-3.5" }),
|
|
210
|
+
h("path", { d: "M8 11h6M11 8v6" }),
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const styles = {
|
|
215
|
+
page: {
|
|
216
|
+
boxSizing: "border-box",
|
|
217
|
+
height: "100%",
|
|
218
|
+
fontFamily: "var(--dsw-font-family)",
|
|
219
|
+
color: "var(--dsw-alias-label-primary)",
|
|
220
|
+
display: "flex",
|
|
221
|
+
flexDirection: "column",
|
|
222
|
+
alignItems: "center",
|
|
223
|
+
gap: "24px",
|
|
224
|
+
padding: "0 clamp(24px, 4vw, 48px) 48px",
|
|
225
|
+
overflow: "auto",
|
|
226
|
+
},
|
|
227
|
+
inner: {
|
|
228
|
+
width: "100%",
|
|
229
|
+
maxWidth: "960px",
|
|
230
|
+
display: "flex",
|
|
231
|
+
flexDirection: "column",
|
|
232
|
+
gap: "16px",
|
|
233
|
+
},
|
|
234
|
+
head: {
|
|
235
|
+
paddingTop: "28px",
|
|
236
|
+
display: "flex",
|
|
237
|
+
flexDirection: "column",
|
|
238
|
+
gap: "4px",
|
|
239
|
+
},
|
|
240
|
+
title: {
|
|
241
|
+
margin: 0,
|
|
242
|
+
fontFamily: "var(--dsw-font-family)",
|
|
243
|
+
fontSize: "20px",
|
|
244
|
+
fontWeight: 500,
|
|
245
|
+
lineHeight: "28px",
|
|
246
|
+
color: "var(--dsw-alias-label-primary)",
|
|
247
|
+
},
|
|
248
|
+
intro: {
|
|
249
|
+
margin: 0,
|
|
250
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
251
|
+
fontSize: "13px",
|
|
252
|
+
lineHeight: "20px",
|
|
253
|
+
},
|
|
254
|
+
card: {
|
|
255
|
+
boxSizing: "border-box",
|
|
256
|
+
display: "flex",
|
|
257
|
+
flexDirection: "column",
|
|
258
|
+
gap: "12px",
|
|
259
|
+
padding: "16px 18px",
|
|
260
|
+
borderRadius: "var(--dsw-radius-md, 12px)",
|
|
261
|
+
border: "1px solid var(--dsw-alias-border-l2, var(--dsw-alias-border-l4, #d8dde6))",
|
|
262
|
+
background: "var(--dsw-alias-bg-module-platform, var(--dsw-alias-bg-layer-1, #f5f6f7))",
|
|
263
|
+
boxShadow: "var(--dsw-elevation-soft, var(--dsw-shadow-lv1, 0 2px 8px rgba(0,0,0,0.04)))",
|
|
264
|
+
},
|
|
265
|
+
cardHead: {
|
|
266
|
+
display: "flex",
|
|
267
|
+
flexDirection: "column",
|
|
268
|
+
gap: "2px",
|
|
269
|
+
},
|
|
270
|
+
cardTitle: {
|
|
271
|
+
margin: 0,
|
|
272
|
+
fontSize: "14px",
|
|
273
|
+
fontWeight: 500,
|
|
274
|
+
lineHeight: "22px",
|
|
275
|
+
color: "var(--dsw-alias-label-primary)",
|
|
276
|
+
},
|
|
277
|
+
cardDesc: {
|
|
278
|
+
margin: 0,
|
|
279
|
+
fontSize: "12px",
|
|
280
|
+
fontWeight: 400,
|
|
281
|
+
lineHeight: "18px",
|
|
282
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
283
|
+
},
|
|
284
|
+
toolbar: {
|
|
285
|
+
display: "flex",
|
|
286
|
+
flexWrap: "wrap",
|
|
287
|
+
gap: "10px",
|
|
288
|
+
alignItems: "center",
|
|
289
|
+
},
|
|
290
|
+
searchGrow: {
|
|
291
|
+
flex: "1 1 240px",
|
|
292
|
+
minWidth: "200px",
|
|
293
|
+
},
|
|
294
|
+
field: {
|
|
295
|
+
boxSizing: "border-box",
|
|
296
|
+
width: "100%",
|
|
297
|
+
height: "40px",
|
|
298
|
+
padding: "0 14px",
|
|
299
|
+
borderRadius: "var(--dsw-radius-sm, 8px)",
|
|
300
|
+
border: "1px solid var(--dsw-alias-border-l1, var(--dsw-alias-border-l2, #c8ced6))",
|
|
301
|
+
background: "var(--dsw-alias-bg-base, #ffffff)",
|
|
302
|
+
color: "var(--dsw-alias-label-primary)",
|
|
303
|
+
fontFamily: "var(--dsw-font-family)",
|
|
304
|
+
fontSize: "14px",
|
|
305
|
+
lineHeight: "22px",
|
|
306
|
+
outline: "none",
|
|
307
|
+
boxShadow: "inset 0 1px 2px rgba(16, 24, 40, 0.04)",
|
|
308
|
+
},
|
|
309
|
+
btn: {
|
|
310
|
+
display: "inline-flex",
|
|
311
|
+
alignItems: "center",
|
|
312
|
+
justifyContent: "center",
|
|
313
|
+
height: "40px",
|
|
314
|
+
padding: "0 16px",
|
|
315
|
+
borderRadius: "var(--dsw-radius-sm, 8px)",
|
|
316
|
+
border: "1px solid transparent",
|
|
317
|
+
fontFamily: "var(--dsw-font-family)",
|
|
318
|
+
fontSize: "14px",
|
|
319
|
+
fontWeight: 500,
|
|
320
|
+
lineHeight: "22px",
|
|
321
|
+
cursor: "pointer",
|
|
322
|
+
whiteSpace: "nowrap",
|
|
323
|
+
},
|
|
324
|
+
btnPrimary: {
|
|
325
|
+
background: "var(--dsw-alias-state-business-primary, var(--dsw-static-deepseek-500, #4176e6))",
|
|
326
|
+
color: "#ffffff",
|
|
327
|
+
},
|
|
328
|
+
btnOutline: {
|
|
329
|
+
background: "var(--dsw-alias-bg-base, #ffffff)",
|
|
330
|
+
borderColor: "var(--dsw-alias-border-l1, #c8ced6)",
|
|
331
|
+
color: "var(--dsw-alias-label-primary)",
|
|
332
|
+
},
|
|
333
|
+
btnSm: {
|
|
334
|
+
height: "28px",
|
|
335
|
+
padding: "0 10px",
|
|
336
|
+
fontSize: "12px",
|
|
337
|
+
lineHeight: "18px",
|
|
338
|
+
},
|
|
339
|
+
btnDisabled: {
|
|
340
|
+
opacity: 0.45,
|
|
341
|
+
cursor: "not-allowed",
|
|
342
|
+
},
|
|
343
|
+
seg: {
|
|
344
|
+
display: "inline-flex",
|
|
345
|
+
padding: "3px",
|
|
346
|
+
gap: "2px",
|
|
347
|
+
borderRadius: "var(--dsw-radius-sm, 8px)",
|
|
348
|
+
border: "0.5px solid var(--dsw-alias-border-l2, #d0d5dd)",
|
|
349
|
+
background: "var(--dsw-alias-bg-module-platform, #f5f6f7)",
|
|
350
|
+
},
|
|
351
|
+
segItem: {
|
|
352
|
+
height: "32px",
|
|
353
|
+
padding: "0 12px",
|
|
354
|
+
border: "none",
|
|
355
|
+
borderRadius: "6px",
|
|
356
|
+
background: "transparent",
|
|
357
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
358
|
+
fontFamily: "var(--dsw-font-family)",
|
|
359
|
+
fontSize: "13px",
|
|
360
|
+
cursor: "pointer",
|
|
361
|
+
},
|
|
362
|
+
segItemActive: {
|
|
363
|
+
background: "var(--dsw-alias-bg-layer-2, #ffffff)",
|
|
364
|
+
color: "var(--dsw-alias-label-primary)",
|
|
365
|
+
boxShadow: "0 0 0 0.5px var(--dsw-alias-border-l2, #d0d5dd)",
|
|
366
|
+
fontWeight: 500,
|
|
367
|
+
},
|
|
368
|
+
list: {
|
|
369
|
+
display: "flex",
|
|
370
|
+
flexDirection: "column",
|
|
371
|
+
gap: "8px",
|
|
372
|
+
},
|
|
373
|
+
row: {
|
|
374
|
+
display: "flex",
|
|
375
|
+
alignItems: "flex-start",
|
|
376
|
+
justifyContent: "space-between",
|
|
377
|
+
gap: "16px",
|
|
378
|
+
padding: "14px 16px",
|
|
379
|
+
borderRadius: "var(--dsw-radius-md, 12px)",
|
|
380
|
+
border: "0.5px solid var(--dsw-alias-border-l4, #e5e7eb)",
|
|
381
|
+
background: "var(--dsw-alias-settings-card-fill, var(--dsw-alias-bg-layer-2, #ffffff))",
|
|
382
|
+
boxShadow: "var(--dsw-shadow-lv1, 0 2px 4px 0 rgba(0,0,0,0.05))",
|
|
383
|
+
},
|
|
384
|
+
rowMain: {
|
|
385
|
+
minWidth: 0,
|
|
386
|
+
flex: "1 1 auto",
|
|
387
|
+
display: "grid",
|
|
388
|
+
gap: "4px",
|
|
389
|
+
},
|
|
390
|
+
rowTitle: {
|
|
391
|
+
margin: 0,
|
|
392
|
+
fontFamily: "var(--dsw-font-family)",
|
|
393
|
+
fontSize: "14px",
|
|
394
|
+
fontWeight: 500,
|
|
395
|
+
lineHeight: "22px",
|
|
396
|
+
color: "var(--dsw-alias-label-primary)",
|
|
397
|
+
overflow: "hidden",
|
|
398
|
+
textOverflow: "ellipsis",
|
|
399
|
+
whiteSpace: "nowrap",
|
|
400
|
+
},
|
|
401
|
+
rowDesc: {
|
|
402
|
+
margin: 0,
|
|
403
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
404
|
+
fontSize: "13px",
|
|
405
|
+
lineHeight: "20px",
|
|
406
|
+
display: "-webkit-box",
|
|
407
|
+
WebkitLineClamp: 2,
|
|
408
|
+
WebkitBoxOrient: "vertical",
|
|
409
|
+
overflow: "hidden",
|
|
410
|
+
},
|
|
411
|
+
meta: {
|
|
412
|
+
display: "flex",
|
|
413
|
+
flexWrap: "wrap",
|
|
414
|
+
gap: "8px",
|
|
415
|
+
alignItems: "center",
|
|
416
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
417
|
+
fontSize: "12px",
|
|
418
|
+
lineHeight: "18px",
|
|
419
|
+
},
|
|
420
|
+
badge: {
|
|
421
|
+
display: "inline-flex",
|
|
422
|
+
alignItems: "center",
|
|
423
|
+
padding: "0 8px",
|
|
424
|
+
height: "20px",
|
|
425
|
+
borderRadius: "999px",
|
|
426
|
+
border: "0.5px solid var(--dsw-alias-border-l2, #d0d5dd)",
|
|
427
|
+
background: "var(--dsw-alias-bg-module-platform, #f5f6f7)",
|
|
428
|
+
fontSize: "11px",
|
|
429
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
430
|
+
},
|
|
431
|
+
badgeInstalled: {
|
|
432
|
+
display: "inline-flex",
|
|
433
|
+
alignItems: "center",
|
|
434
|
+
padding: "0 8px",
|
|
435
|
+
height: "20px",
|
|
436
|
+
borderRadius: "999px",
|
|
437
|
+
border: "0.5px solid var(--dsw-alias-state-success-primary, #4ed17e)",
|
|
438
|
+
background: "var(--dsw-static-green-100, #e6faed)",
|
|
439
|
+
fontSize: "11px",
|
|
440
|
+
color: "var(--dsw-alias-state-success-primary, #2f9e44)",
|
|
441
|
+
},
|
|
442
|
+
badgeInstalling: {
|
|
443
|
+
display: "inline-flex",
|
|
444
|
+
alignItems: "center",
|
|
445
|
+
padding: "0 8px",
|
|
446
|
+
height: "20px",
|
|
447
|
+
borderRadius: "999px",
|
|
448
|
+
border: "0.5px solid var(--dsw-alias-state-business-primary, #4176e6)",
|
|
449
|
+
background: "var(--dsw-static-blue-50, #eff6ff)",
|
|
450
|
+
fontSize: "11px",
|
|
451
|
+
color: "var(--dsw-alias-state-business-primary, #4176e6)",
|
|
452
|
+
},
|
|
453
|
+
btnInstalled: {
|
|
454
|
+
background: "var(--dsw-alias-bg-module-platform, #f5f6f7)",
|
|
455
|
+
borderColor: "var(--dsw-alias-border-l2, #d0d5dd)",
|
|
456
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
457
|
+
cursor: "default",
|
|
458
|
+
},
|
|
459
|
+
btnInstalling: {
|
|
460
|
+
background: "var(--dsw-static-blue-50, #eff6ff)",
|
|
461
|
+
borderColor: "var(--dsw-alias-state-business-primary, #4176e6)",
|
|
462
|
+
color: "var(--dsw-alias-state-business-primary, #4176e6)",
|
|
463
|
+
cursor: "wait",
|
|
464
|
+
},
|
|
465
|
+
actions: {
|
|
466
|
+
display: "flex",
|
|
467
|
+
flexDirection: "column",
|
|
468
|
+
gap: "8px",
|
|
469
|
+
flex: "0 0 auto",
|
|
470
|
+
},
|
|
471
|
+
empty: {
|
|
472
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
473
|
+
margin: "40px 0",
|
|
474
|
+
fontSize: "13px",
|
|
475
|
+
lineHeight: "20px",
|
|
476
|
+
textAlign: "center",
|
|
477
|
+
},
|
|
478
|
+
status: {
|
|
479
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
480
|
+
fontSize: "13px",
|
|
481
|
+
lineHeight: "20px",
|
|
482
|
+
margin: 0,
|
|
483
|
+
},
|
|
484
|
+
errorBox: {
|
|
485
|
+
display: "flex",
|
|
486
|
+
alignItems: "center",
|
|
487
|
+
justifyContent: "space-between",
|
|
488
|
+
gap: "12px",
|
|
489
|
+
padding: "12px 14px",
|
|
490
|
+
borderRadius: "var(--dsw-radius-sm, 8px)",
|
|
491
|
+
border: "0.5px solid var(--dsw-alias-border-l2, #d0d5dd)",
|
|
492
|
+
background: "var(--dsw-alias-settings-card-fill, #ffffff)",
|
|
493
|
+
color: "var(--dsw-alias-state-warn-primary, var(--dsw-alias-label-secondary))",
|
|
494
|
+
fontSize: "13px",
|
|
495
|
+
},
|
|
496
|
+
pager: {
|
|
497
|
+
display: "flex",
|
|
498
|
+
alignItems: "center",
|
|
499
|
+
justifyContent: "space-between",
|
|
500
|
+
gap: "12px",
|
|
501
|
+
flexWrap: "wrap",
|
|
502
|
+
paddingTop: "4px",
|
|
503
|
+
},
|
|
504
|
+
pagerButtons: {
|
|
505
|
+
display: "flex",
|
|
506
|
+
gap: "8px",
|
|
507
|
+
},
|
|
508
|
+
link: {
|
|
509
|
+
color: "var(--dsw-alias-brand-primary, var(--dsw-alias-label-secondary))",
|
|
510
|
+
textDecoration: "none",
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
function Field(props) {
|
|
515
|
+
return h("input", {
|
|
516
|
+
type: "text",
|
|
517
|
+
style: styles.field,
|
|
518
|
+
value: props.value,
|
|
519
|
+
placeholder: props.placeholder,
|
|
520
|
+
disabled: props.disabled,
|
|
521
|
+
onChange: props.onChange,
|
|
522
|
+
onKeyDown: props.onKeyDown,
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function Btn(props) {
|
|
527
|
+
const style = Object.assign(
|
|
528
|
+
{},
|
|
529
|
+
styles.btn,
|
|
530
|
+
props.variant === "outline"
|
|
531
|
+
? styles.btnOutline
|
|
532
|
+
: props.variant === "installed"
|
|
533
|
+
? styles.btnInstalled
|
|
534
|
+
: props.variant === "installing"
|
|
535
|
+
? styles.btnInstalling
|
|
536
|
+
: styles.btnPrimary,
|
|
537
|
+
props.size === "sm" ? styles.btnSm : null,
|
|
538
|
+
props.disabled ? styles.btnDisabled : null,
|
|
539
|
+
props.style || null,
|
|
540
|
+
);
|
|
541
|
+
return h(
|
|
542
|
+
"button",
|
|
543
|
+
{
|
|
544
|
+
type: "button",
|
|
545
|
+
style,
|
|
546
|
+
disabled: props.disabled,
|
|
547
|
+
onClick: props.onClick,
|
|
548
|
+
},
|
|
549
|
+
props.children,
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function SourceSeg(props) {
|
|
554
|
+
return h(
|
|
555
|
+
"div",
|
|
556
|
+
{ style: styles.seg, role: "group", "aria-label": "source" },
|
|
557
|
+
props.options.map((opt) =>
|
|
558
|
+
h(
|
|
559
|
+
"button",
|
|
560
|
+
{
|
|
561
|
+
key: opt.value,
|
|
562
|
+
type: "button",
|
|
563
|
+
disabled: props.disabled,
|
|
564
|
+
style: Object.assign(
|
|
565
|
+
{},
|
|
566
|
+
styles.segItem,
|
|
567
|
+
props.value === opt.value ? styles.segItemActive : null,
|
|
568
|
+
props.disabled ? styles.btnDisabled : null,
|
|
569
|
+
),
|
|
570
|
+
onClick: () => props.onChange(opt.value),
|
|
571
|
+
},
|
|
572
|
+
opt.label,
|
|
573
|
+
),
|
|
574
|
+
),
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function unwrapRemote(result, fallbackMessage) {
|
|
579
|
+
if (!result) return { ok: false, message: fallbackMessage };
|
|
580
|
+
if (result.ok === false) {
|
|
581
|
+
const err = result.error;
|
|
582
|
+
return {
|
|
583
|
+
ok: false,
|
|
584
|
+
message: (err && (err.message || err.code)) || fallbackMessage,
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
return result.value;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function Panel(props) {
|
|
591
|
+
const api = props.api;
|
|
592
|
+
const t = props.t;
|
|
593
|
+
const [query, setQuery] = React.useState(DEFAULT_QUERY);
|
|
594
|
+
const [source, setSource] = React.useState("all");
|
|
595
|
+
const [results, setResults] = React.useState([]);
|
|
596
|
+
const [message, setMessage] = React.useState("");
|
|
597
|
+
const [error, setError] = React.useState("");
|
|
598
|
+
const [busy, setBusy] = React.useState(false);
|
|
599
|
+
const [resolveInput, setResolveInput] = React.useState("");
|
|
600
|
+
const [installDetail, setInstallDetail] = React.useState("");
|
|
601
|
+
const [installedNames, setInstalledNames] = React.useState(() => readInstalledCache());
|
|
602
|
+
const [jobs, setJobs] = React.useState(() => readJobCache());
|
|
603
|
+
const [page, setPage] = React.useState(1);
|
|
604
|
+
const jobsRef = React.useRef(jobs);
|
|
605
|
+
React.useEffect(() => {
|
|
606
|
+
jobsRef.current = jobs;
|
|
607
|
+
writeJobCache(jobs);
|
|
608
|
+
}, [jobs]);
|
|
609
|
+
|
|
610
|
+
const refreshInstalled = React.useCallback(async () => {
|
|
611
|
+
if (!api || typeof api.listInstalled !== "function") return;
|
|
612
|
+
try {
|
|
613
|
+
const res = await api.listInstalled();
|
|
614
|
+
if (res && res.ok && Array.isArray(res.names)) {
|
|
615
|
+
// 以服务端名单为准整体覆盖,卸载后才能从「已安装」恢复为「未安装」
|
|
616
|
+
const nextNames = new Set();
|
|
617
|
+
for (const name of res.names) {
|
|
618
|
+
if (!name) continue;
|
|
619
|
+
nextNames.add(name);
|
|
620
|
+
}
|
|
621
|
+
writeInstalledCache(nextNames);
|
|
622
|
+
setInstalledNames(nextNames);
|
|
623
|
+
|
|
624
|
+
setJobs((prev) => {
|
|
625
|
+
const next = { ...prev };
|
|
626
|
+
let changed = false;
|
|
627
|
+
for (const [id, job] of Object.entries(next)) {
|
|
628
|
+
const keys = [job.spec, job.packageName, ...(job.keys || [])].filter(Boolean);
|
|
629
|
+
const present = keys.some((key) => nextNames.has(key));
|
|
630
|
+
if (present) {
|
|
631
|
+
if (job.status !== "installed") {
|
|
632
|
+
next[id] = { ...job, status: "installed", detail: "", updatedAt: Date.now() };
|
|
633
|
+
changed = true;
|
|
634
|
+
}
|
|
635
|
+
} else if (job.status === "installed" || job.status === "failed") {
|
|
636
|
+
// 已卸载或过期的终态任务从缓存移除
|
|
637
|
+
delete next[id];
|
|
638
|
+
changed = true;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return changed ? next : prev;
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
} catch {
|
|
645
|
+
/* ignore */
|
|
646
|
+
}
|
|
647
|
+
}, [api]);
|
|
648
|
+
|
|
649
|
+
const markInstalled = React.useCallback((name) => {
|
|
650
|
+
if (!name) return;
|
|
651
|
+
setInstalledNames((prev) => {
|
|
652
|
+
const next = new Set(prev);
|
|
653
|
+
next.add(name);
|
|
654
|
+
writeInstalledCache(next);
|
|
655
|
+
return next;
|
|
656
|
+
});
|
|
657
|
+
}, []);
|
|
658
|
+
|
|
659
|
+
const upsertJob = React.useCallback((requestId, patch) => {
|
|
660
|
+
if (!requestId) return;
|
|
661
|
+
setJobs((prev) => {
|
|
662
|
+
const current = prev[requestId] || { requestId, status: "installing", keys: [] };
|
|
663
|
+
return {
|
|
664
|
+
...prev,
|
|
665
|
+
[requestId]: {
|
|
666
|
+
...current,
|
|
667
|
+
...patch,
|
|
668
|
+
requestId,
|
|
669
|
+
updatedAt: Date.now(),
|
|
670
|
+
},
|
|
671
|
+
};
|
|
672
|
+
});
|
|
673
|
+
}, []);
|
|
674
|
+
|
|
675
|
+
const finishJob = React.useCallback(
|
|
676
|
+
(requestId, outcome) => {
|
|
677
|
+
if (!requestId) return;
|
|
678
|
+
setJobs((prev) => {
|
|
679
|
+
const current = prev[requestId];
|
|
680
|
+
if (!current) return prev;
|
|
681
|
+
if (outcome.status === "installed") {
|
|
682
|
+
for (const key of [current.spec, current.packageName, outcome.packageName, ...(current.keys || [])]) {
|
|
683
|
+
if (key) markInstalled(key);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
return {
|
|
687
|
+
...prev,
|
|
688
|
+
[requestId]: {
|
|
689
|
+
...current,
|
|
690
|
+
...outcome,
|
|
691
|
+
updatedAt: Date.now(),
|
|
692
|
+
},
|
|
693
|
+
};
|
|
694
|
+
});
|
|
695
|
+
},
|
|
696
|
+
[markInstalled],
|
|
697
|
+
);
|
|
698
|
+
|
|
699
|
+
const runSearch = React.useCallback(
|
|
700
|
+
async (nextQuery, nextSource) => {
|
|
701
|
+
setBusy(true);
|
|
702
|
+
setMessage("");
|
|
703
|
+
setError("");
|
|
704
|
+
try {
|
|
705
|
+
if (!api || typeof api.search !== "function") {
|
|
706
|
+
setResults([]);
|
|
707
|
+
setError(t("loadFailed") + ": api unavailable");
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
const [res] = await Promise.all([
|
|
711
|
+
api.search(nextQuery, { source: nextSource, verify: false }),
|
|
712
|
+
refreshInstalled(),
|
|
713
|
+
]);
|
|
714
|
+
if (!res || !res.ok) {
|
|
715
|
+
setResults([]);
|
|
716
|
+
setError((res && res.message) || t("loadFailed"));
|
|
717
|
+
} else {
|
|
718
|
+
const list = res.results || [];
|
|
719
|
+
setResults(list);
|
|
720
|
+
setPage(1);
|
|
721
|
+
if (!list.length) setMessage(t("noResults"));
|
|
722
|
+
}
|
|
723
|
+
} catch (e) {
|
|
724
|
+
setResults([]);
|
|
725
|
+
setError((e && e.message) || String(e));
|
|
726
|
+
} finally {
|
|
727
|
+
setBusy(false);
|
|
728
|
+
}
|
|
729
|
+
},
|
|
730
|
+
[api, t, refreshInstalled],
|
|
731
|
+
);
|
|
732
|
+
|
|
733
|
+
React.useEffect(() => {
|
|
734
|
+
void refreshInstalled();
|
|
735
|
+
}, [refreshInstalled]);
|
|
736
|
+
|
|
737
|
+
React.useEffect(() => {
|
|
738
|
+
if (!api) return undefined;
|
|
739
|
+
const offs = [];
|
|
740
|
+
if (typeof api.subscribePluginChanged === "function") {
|
|
741
|
+
offs.push(
|
|
742
|
+
api.subscribePluginChanged(() => {
|
|
743
|
+
void refreshInstalled();
|
|
744
|
+
}),
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
if (typeof api.subscribeInstallState === "function") {
|
|
748
|
+
offs.push(
|
|
749
|
+
api.subscribeInstallState((progress) => {
|
|
750
|
+
if (!progress || !progress.requestId) return;
|
|
751
|
+
const job = jobsRef.current[progress.requestId];
|
|
752
|
+
if (!job) return;
|
|
753
|
+
const phase = progress.phase || "installing";
|
|
754
|
+
const attempt = progress.attempt
|
|
755
|
+
? ` · registry ${progress.attempt.index}/${progress.attempt.total}`
|
|
756
|
+
: "";
|
|
757
|
+
upsertJob(progress.requestId, {
|
|
758
|
+
status: "installing",
|
|
759
|
+
detail: `${phase}${attempt}`,
|
|
760
|
+
});
|
|
761
|
+
setInstallDetail(format(t("installPhase"), { phase: `${phase}${attempt}` }));
|
|
762
|
+
}),
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
if (typeof api.subscribeInstallLog === "function") {
|
|
766
|
+
offs.push(
|
|
767
|
+
api.subscribeInstallLog((chunk) => {
|
|
768
|
+
if (!chunk || !chunk.requestId) return;
|
|
769
|
+
const job = jobsRef.current[chunk.requestId];
|
|
770
|
+
if (!job) return;
|
|
771
|
+
const text = String(chunk.text || "").trim();
|
|
772
|
+
if (!text) return;
|
|
773
|
+
const line = text.split("\n").filter(Boolean).slice(-1)[0] || text;
|
|
774
|
+
upsertJob(chunk.requestId, {
|
|
775
|
+
status: "installing",
|
|
776
|
+
detail: line.slice(0, 160),
|
|
777
|
+
});
|
|
778
|
+
setInstallDetail(format(t("installLog"), { text: line.slice(0, 160) }));
|
|
779
|
+
}),
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
return () => {
|
|
783
|
+
for (const off of offs) {
|
|
784
|
+
try {
|
|
785
|
+
off();
|
|
786
|
+
} catch {
|
|
787
|
+
/* ignore */
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
}, [api, refreshInstalled, upsertJob, t]);
|
|
792
|
+
|
|
793
|
+
// 刷新后恢复未完成的安装任务
|
|
794
|
+
React.useEffect(() => {
|
|
795
|
+
if (!api || typeof api.waitInstall !== "function") return undefined;
|
|
796
|
+
let cancelled = false;
|
|
797
|
+
const pending = Object.values(jobsRef.current).filter((job) => job && job.status === "installing" && job.requestId);
|
|
798
|
+
for (const job of pending) {
|
|
799
|
+
void (async () => {
|
|
800
|
+
setInstallDetail(format(t("installProgress"), { spec: job.spec || job.requestId }));
|
|
801
|
+
try {
|
|
802
|
+
const res = await api.waitInstall(job.requestId);
|
|
803
|
+
if (cancelled) return;
|
|
804
|
+
if (res && res.pending) return;
|
|
805
|
+
if (res && res.ok) {
|
|
806
|
+
finishJob(job.requestId, {
|
|
807
|
+
status: "installed",
|
|
808
|
+
packageName: res.packageName || job.packageName,
|
|
809
|
+
detail: res.message || "",
|
|
810
|
+
});
|
|
811
|
+
setMessage(res.message || t("installed"));
|
|
812
|
+
await refreshInstalled();
|
|
813
|
+
} else {
|
|
814
|
+
finishJob(job.requestId, {
|
|
815
|
+
status: "failed",
|
|
816
|
+
detail: (res && res.message) || t("installFailed"),
|
|
817
|
+
});
|
|
818
|
+
setError((res && res.message) || t("installFailed"));
|
|
819
|
+
}
|
|
820
|
+
} catch (e) {
|
|
821
|
+
if (cancelled) return;
|
|
822
|
+
finishJob(job.requestId, {
|
|
823
|
+
status: "failed",
|
|
824
|
+
detail: (e && e.message) || String(e),
|
|
825
|
+
});
|
|
826
|
+
} finally {
|
|
827
|
+
if (!cancelled) setInstallDetail("");
|
|
828
|
+
}
|
|
829
|
+
})();
|
|
830
|
+
}
|
|
831
|
+
return () => {
|
|
832
|
+
cancelled = true;
|
|
833
|
+
};
|
|
834
|
+
}, [api, finishJob, refreshInstalled, t]);
|
|
835
|
+
|
|
836
|
+
React.useEffect(() => {
|
|
837
|
+
void runSearch(query.trim() || DEFAULT_QUERY, source);
|
|
838
|
+
}, [source, runSearch]);
|
|
839
|
+
|
|
840
|
+
const pages = Math.max(1, Math.ceil(results.length / PAGE_SIZE));
|
|
841
|
+
const safePage = Math.min(page, pages);
|
|
842
|
+
const pageItems = results.slice((safePage - 1) * PAGE_SIZE, safePage * PAGE_SIZE);
|
|
843
|
+
|
|
844
|
+
const onSearch = () => {
|
|
845
|
+
void runSearch(query.trim() || DEFAULT_QUERY, source);
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
const onResolve = async () => {
|
|
849
|
+
const raw = resolveInput.trim();
|
|
850
|
+
// 关键词误填到解析框时,自动走搜索
|
|
851
|
+
if (raw && !/^https?:\/\//i.test(raw) && !/^(github:|gitlab:|bitbucket:)/i.test(raw) && !/^[@a-z0-9_.-]+\/[a-z0-9_.-]+$/i.test(raw) && (/\s/.test(raw) || /[\u4e00-\u9fff]/.test(raw))) {
|
|
852
|
+
setQuery(raw);
|
|
853
|
+
setResolveInput("");
|
|
854
|
+
void runSearch(raw, source);
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
setBusy(true);
|
|
858
|
+
setMessage("");
|
|
859
|
+
setError("");
|
|
860
|
+
try {
|
|
861
|
+
const res = await api.resolve(raw);
|
|
862
|
+
if (res && res.ok && res.inspection && res.inspection.bundle) {
|
|
863
|
+
const item = {
|
|
864
|
+
spec: res.spec,
|
|
865
|
+
installSpec: res.spec,
|
|
866
|
+
title: res.inspection.name || res.spec,
|
|
867
|
+
description: res.inspection.description || "",
|
|
868
|
+
source: res.source || "resolve",
|
|
869
|
+
bundle: true,
|
|
870
|
+
};
|
|
871
|
+
setResults([item]);
|
|
872
|
+
setPage(1);
|
|
873
|
+
if (isInstalledItem(item, installedNames)) {
|
|
874
|
+
setMessage(t("alreadyInstalled"));
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
const requestId = newRequestId();
|
|
878
|
+
upsertJob(requestId, {
|
|
879
|
+
status: "installing",
|
|
880
|
+
spec: res.spec,
|
|
881
|
+
keys: candidateKeys(item),
|
|
882
|
+
packageName: res.inspection.name || "",
|
|
883
|
+
detail: "",
|
|
884
|
+
});
|
|
885
|
+
setInstallDetail(format(t("installProgress"), { spec: res.spec }));
|
|
886
|
+
const installed = await api.install(res.spec, { requestId });
|
|
887
|
+
if (installed && installed.alreadyInstalled) {
|
|
888
|
+
finishJob(requestId, {
|
|
889
|
+
status: "installed",
|
|
890
|
+
packageName: installed.packageName || res.inspection.name || res.spec,
|
|
891
|
+
detail: installed.message || "",
|
|
892
|
+
});
|
|
893
|
+
setMessage(installed.message || t("alreadyInstalled"));
|
|
894
|
+
} else if (installed && installed.ok) {
|
|
895
|
+
finishJob(requestId, {
|
|
896
|
+
status: "installed",
|
|
897
|
+
packageName: installed.packageName || res.inspection.name || res.spec,
|
|
898
|
+
detail: installed.message || "",
|
|
899
|
+
});
|
|
900
|
+
setMessage(installed.message || t("installed"));
|
|
901
|
+
await refreshInstalled();
|
|
902
|
+
} else {
|
|
903
|
+
finishJob(requestId, {
|
|
904
|
+
status: "failed",
|
|
905
|
+
detail: (installed && installed.message) || t("inspectFailed"),
|
|
906
|
+
});
|
|
907
|
+
setError((installed && installed.message) || t("inspectFailed"));
|
|
908
|
+
}
|
|
909
|
+
} else {
|
|
910
|
+
setResults([]);
|
|
911
|
+
setError((res && res.message) || t("inspectFailed"));
|
|
912
|
+
}
|
|
913
|
+
} catch (e) {
|
|
914
|
+
setError((e && e.message) || String(e));
|
|
915
|
+
} finally {
|
|
916
|
+
setInstallDetail("");
|
|
917
|
+
setBusy(false);
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
const onInstall = async (item) => {
|
|
922
|
+
const spec = item.installSpec || item.spec;
|
|
923
|
+
const current = resolveItemStatus(item, installedNames, jobs);
|
|
924
|
+
if (!spec || current.status === "installed" || current.status === "installing") return;
|
|
925
|
+
const requestId = newRequestId();
|
|
926
|
+
upsertJob(requestId, {
|
|
927
|
+
status: "installing",
|
|
928
|
+
spec,
|
|
929
|
+
keys: candidateKeys(item),
|
|
930
|
+
packageName: item.title || "",
|
|
931
|
+
detail: "",
|
|
932
|
+
});
|
|
933
|
+
setInstallDetail(format(t("installProgress"), { spec }));
|
|
934
|
+
setMessage("");
|
|
935
|
+
setError("");
|
|
936
|
+
try {
|
|
937
|
+
const res = await api.install(spec, { requestId });
|
|
938
|
+
if (res && res.alreadyInstalled) {
|
|
939
|
+
finishJob(requestId, {
|
|
940
|
+
status: "installed",
|
|
941
|
+
packageName: res.packageName || item.title || spec,
|
|
942
|
+
detail: res.message || "",
|
|
943
|
+
});
|
|
944
|
+
setMessage(res.message || t("alreadyInstalled"));
|
|
945
|
+
await refreshInstalled();
|
|
946
|
+
} else if (res && res.ok) {
|
|
947
|
+
finishJob(requestId, {
|
|
948
|
+
status: "installed",
|
|
949
|
+
packageName: res.packageName || item.title || spec,
|
|
950
|
+
detail: res.message || "",
|
|
951
|
+
});
|
|
952
|
+
for (const key of candidateKeys(item)) markInstalled(key);
|
|
953
|
+
await refreshInstalled();
|
|
954
|
+
setMessage(res.message || t("installed"));
|
|
955
|
+
} else {
|
|
956
|
+
finishJob(requestId, {
|
|
957
|
+
status: "failed",
|
|
958
|
+
detail: (res && res.message) || t("installFailed"),
|
|
959
|
+
});
|
|
960
|
+
setError((res && res.message) || t("installFailed"));
|
|
961
|
+
}
|
|
962
|
+
} catch (e) {
|
|
963
|
+
finishJob(requestId, {
|
|
964
|
+
status: "failed",
|
|
965
|
+
detail: (e && e.message) || String(e),
|
|
966
|
+
});
|
|
967
|
+
setError((e && e.message) || String(e));
|
|
968
|
+
} finally {
|
|
969
|
+
setInstallDetail("");
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
const sourceOptions = [
|
|
974
|
+
{ value: "all", label: t("sourceAll") },
|
|
975
|
+
{ value: "npm", label: t("sourceNpm") },
|
|
976
|
+
{ value: "github", label: t("sourceGithub") },
|
|
977
|
+
];
|
|
978
|
+
|
|
979
|
+
return h(
|
|
980
|
+
"div",
|
|
981
|
+
{ style: styles.page },
|
|
982
|
+
h(
|
|
983
|
+
"div",
|
|
984
|
+
{ style: styles.inner },
|
|
985
|
+
h(
|
|
986
|
+
"div",
|
|
987
|
+
{ style: styles.head },
|
|
988
|
+
h("h1", { style: styles.title }, t("panel")),
|
|
989
|
+
h("p", { style: styles.intro }, t("intro")),
|
|
990
|
+
),
|
|
991
|
+
h(
|
|
992
|
+
"div",
|
|
993
|
+
{ style: styles.card },
|
|
994
|
+
h(
|
|
995
|
+
"div",
|
|
996
|
+
{ style: styles.cardHead },
|
|
997
|
+
h("h2", { style: styles.cardTitle }, t("searchCardTitle")),
|
|
998
|
+
h("p", { style: styles.cardDesc }, t("searchCardDesc")),
|
|
999
|
+
),
|
|
1000
|
+
h(
|
|
1001
|
+
"div",
|
|
1002
|
+
{ style: styles.toolbar },
|
|
1003
|
+
h(
|
|
1004
|
+
"div",
|
|
1005
|
+
{ style: styles.searchGrow },
|
|
1006
|
+
h(Field, {
|
|
1007
|
+
value: query,
|
|
1008
|
+
placeholder: t("searchPlaceholder"),
|
|
1009
|
+
disabled: busy,
|
|
1010
|
+
onChange: (e) => setQuery(e.target.value),
|
|
1011
|
+
onKeyDown: (e) => {
|
|
1012
|
+
if (e.key === "Enter") onSearch();
|
|
1013
|
+
},
|
|
1014
|
+
}),
|
|
1015
|
+
),
|
|
1016
|
+
h(SourceSeg, {
|
|
1017
|
+
value: source,
|
|
1018
|
+
options: sourceOptions,
|
|
1019
|
+
disabled: busy,
|
|
1020
|
+
onChange: (next) => setSource(next),
|
|
1021
|
+
}),
|
|
1022
|
+
h(Btn, { disabled: busy, onClick: onSearch }, busy ? t("searching") : t("search")),
|
|
1023
|
+
),
|
|
1024
|
+
),
|
|
1025
|
+
h(
|
|
1026
|
+
"div",
|
|
1027
|
+
{ style: styles.card },
|
|
1028
|
+
h(
|
|
1029
|
+
"div",
|
|
1030
|
+
{ style: styles.cardHead },
|
|
1031
|
+
h("h2", { style: styles.cardTitle }, t("resolveCardTitle")),
|
|
1032
|
+
h("p", { style: styles.cardDesc }, t("resolveCardDesc")),
|
|
1033
|
+
),
|
|
1034
|
+
h(
|
|
1035
|
+
"div",
|
|
1036
|
+
{ style: styles.toolbar },
|
|
1037
|
+
h(
|
|
1038
|
+
"div",
|
|
1039
|
+
{ style: styles.searchGrow },
|
|
1040
|
+
h(Field, {
|
|
1041
|
+
value: resolveInput,
|
|
1042
|
+
placeholder: t("resolvePlaceholder"),
|
|
1043
|
+
disabled: busy,
|
|
1044
|
+
onChange: (e) => setResolveInput(e.target.value),
|
|
1045
|
+
onKeyDown: (e) => {
|
|
1046
|
+
if (e.key === "Enter") void onResolve();
|
|
1047
|
+
},
|
|
1048
|
+
}),
|
|
1049
|
+
),
|
|
1050
|
+
h(
|
|
1051
|
+
Btn,
|
|
1052
|
+
{
|
|
1053
|
+
variant: "outline",
|
|
1054
|
+
disabled: busy || !resolveInput.trim(),
|
|
1055
|
+
onClick: () => void onResolve(),
|
|
1056
|
+
},
|
|
1057
|
+
t("resolve"),
|
|
1058
|
+
),
|
|
1059
|
+
),
|
|
1060
|
+
),
|
|
1061
|
+
error
|
|
1062
|
+
? h(
|
|
1063
|
+
"div",
|
|
1064
|
+
{ style: styles.errorBox },
|
|
1065
|
+
h("span", null, error),
|
|
1066
|
+
h(
|
|
1067
|
+
Btn,
|
|
1068
|
+
{
|
|
1069
|
+
size: "sm",
|
|
1070
|
+
variant: "outline",
|
|
1071
|
+
disabled: busy,
|
|
1072
|
+
onClick: onSearch,
|
|
1073
|
+
},
|
|
1074
|
+
t("retry"),
|
|
1075
|
+
),
|
|
1076
|
+
)
|
|
1077
|
+
: null,
|
|
1078
|
+
installDetail ? h("p", { style: styles.status }, installDetail) : null,
|
|
1079
|
+
message && !error ? h("p", { style: styles.status }, message) : null,
|
|
1080
|
+
busy && !results.length
|
|
1081
|
+
? h("p", { style: styles.empty }, t("searching"))
|
|
1082
|
+
: !results.length
|
|
1083
|
+
? h("p", { style: styles.empty }, error ? "" : message || t("emptyTitle"))
|
|
1084
|
+
: h(
|
|
1085
|
+
"div",
|
|
1086
|
+
{ style: styles.list },
|
|
1087
|
+
pageItems.map((item) => {
|
|
1088
|
+
const spec = item.installSpec || item.spec;
|
|
1089
|
+
const current = resolveItemStatus(item, installedNames, jobs);
|
|
1090
|
+
const already = current.status === "installed";
|
|
1091
|
+
const installing = current.status === "installing";
|
|
1092
|
+
const sourceBadge =
|
|
1093
|
+
item.source === "github"
|
|
1094
|
+
? t("sourceGithubBadge")
|
|
1095
|
+
: item.source === "npm"
|
|
1096
|
+
? t("sourceNpmBadge")
|
|
1097
|
+
: item.source || "";
|
|
1098
|
+
const statusBadge = already
|
|
1099
|
+
? h("span", { style: styles.badgeInstalled }, t("installedBadge"))
|
|
1100
|
+
: installing
|
|
1101
|
+
? h("span", { style: styles.badgeInstalling }, t("installingBadge"))
|
|
1102
|
+
: h("span", { style: styles.badge }, t("notInstalledBadge"));
|
|
1103
|
+
return h(
|
|
1104
|
+
"div",
|
|
1105
|
+
{ key: spec, style: styles.row },
|
|
1106
|
+
h(
|
|
1107
|
+
"div",
|
|
1108
|
+
{ style: styles.rowMain },
|
|
1109
|
+
h("h3", { style: styles.rowTitle }, item.title || spec),
|
|
1110
|
+
item.description ? h("p", { style: styles.rowDesc }, item.description) : null,
|
|
1111
|
+
h(
|
|
1112
|
+
"div",
|
|
1113
|
+
{ style: styles.meta },
|
|
1114
|
+
sourceBadge ? h("span", { style: styles.badge }, sourceBadge) : null,
|
|
1115
|
+
statusBadge,
|
|
1116
|
+
item.stars != null ? h("span", null, format(t("stars"), { n: item.stars })) : null,
|
|
1117
|
+
item.url
|
|
1118
|
+
? h(
|
|
1119
|
+
"a",
|
|
1120
|
+
{
|
|
1121
|
+
href: item.url,
|
|
1122
|
+
target: "_blank",
|
|
1123
|
+
rel: "noreferrer",
|
|
1124
|
+
style: styles.link,
|
|
1125
|
+
},
|
|
1126
|
+
t("open"),
|
|
1127
|
+
)
|
|
1128
|
+
: null,
|
|
1129
|
+
),
|
|
1130
|
+
),
|
|
1131
|
+
h(
|
|
1132
|
+
"div",
|
|
1133
|
+
{ style: styles.actions },
|
|
1134
|
+
h(
|
|
1135
|
+
Btn,
|
|
1136
|
+
{
|
|
1137
|
+
size: "sm",
|
|
1138
|
+
variant: already ? "installed" : installing ? "installing" : "primary",
|
|
1139
|
+
disabled: already || installing || busy,
|
|
1140
|
+
onClick: () => void onInstall(item),
|
|
1141
|
+
},
|
|
1142
|
+
installing
|
|
1143
|
+
? t("installing")
|
|
1144
|
+
: already
|
|
1145
|
+
? t("alreadyInstalled")
|
|
1146
|
+
: t("install"),
|
|
1147
|
+
),
|
|
1148
|
+
),
|
|
1149
|
+
);
|
|
1150
|
+
}),
|
|
1151
|
+
),
|
|
1152
|
+
results.length
|
|
1153
|
+
? h(
|
|
1154
|
+
"div",
|
|
1155
|
+
{ style: styles.pager },
|
|
1156
|
+
h(
|
|
1157
|
+
"p",
|
|
1158
|
+
{ style: styles.status },
|
|
1159
|
+
format(t("pageStatus"), {
|
|
1160
|
+
page: safePage,
|
|
1161
|
+
pages,
|
|
1162
|
+
total: results.length,
|
|
1163
|
+
}),
|
|
1164
|
+
),
|
|
1165
|
+
h(
|
|
1166
|
+
"div",
|
|
1167
|
+
{ style: styles.pagerButtons },
|
|
1168
|
+
h(
|
|
1169
|
+
Btn,
|
|
1170
|
+
{
|
|
1171
|
+
variant: "outline",
|
|
1172
|
+
size: "sm",
|
|
1173
|
+
disabled: safePage <= 1 || busy,
|
|
1174
|
+
onClick: () => setPage((p) => Math.max(1, p - 1)),
|
|
1175
|
+
},
|
|
1176
|
+
t("pagePrev"),
|
|
1177
|
+
),
|
|
1178
|
+
h(
|
|
1179
|
+
Btn,
|
|
1180
|
+
{
|
|
1181
|
+
variant: "outline",
|
|
1182
|
+
size: "sm",
|
|
1183
|
+
disabled: safePage >= pages || busy,
|
|
1184
|
+
onClick: () => setPage((p) => Math.min(pages, p + 1)),
|
|
1185
|
+
},
|
|
1186
|
+
t("pageNext"),
|
|
1187
|
+
),
|
|
1188
|
+
),
|
|
1189
|
+
)
|
|
1190
|
+
: null,
|
|
1191
|
+
),
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
const QUERY_CODEC = strictJson("dsh-plugin-discovery#pluginDiscovery/search:query");
|
|
1196
|
+
const OPTIONS_CODEC = strictJson("dsh-plugin-discovery#pluginDiscovery/search:options");
|
|
1197
|
+
const SEARCH_RESULT = strictJson("dsh-plugin-discovery#pluginDiscovery/search:result");
|
|
1198
|
+
const INPUT_CODEC = strictJson("dsh-plugin-discovery#pluginDiscovery/resolve:input");
|
|
1199
|
+
const RESOLVE_RESULT = strictJson("dsh-plugin-discovery#pluginDiscovery/resolve:result");
|
|
1200
|
+
const SPEC_CODEC = strictJson("dsh-plugin-discovery#pluginDiscovery/installPlugin:spec");
|
|
1201
|
+
const INSTALL_OPTIONS_CODEC = strictJson("dsh-plugin-discovery#pluginDiscovery/installPlugin:options");
|
|
1202
|
+
const INSTALL_RESULT = strictJson("dsh-plugin-discovery#pluginDiscovery/installPlugin:result");
|
|
1203
|
+
const LIST_INSTALLED_RESULT = strictJson("dsh-plugin-discovery#pluginDiscovery/listInstalled:result");
|
|
1204
|
+
const WAIT_REQUEST_ID = strictJson("dsh-plugin-discovery#pluginDiscovery/waitInstall:requestId");
|
|
1205
|
+
const WAIT_RESULT = strictJson("dsh-plugin-discovery#pluginDiscovery/waitInstall:result");
|
|
1206
|
+
|
|
1207
|
+
const TYPERT_REMOTE = {
|
|
1208
|
+
package: "dsh-plugin-discovery",
|
|
1209
|
+
descriptors: [
|
|
1210
|
+
{
|
|
1211
|
+
id: "dsh-plugin-discovery#pluginDiscovery/search",
|
|
1212
|
+
service: "pluginDiscovery",
|
|
1213
|
+
namespace: "pluginDiscovery",
|
|
1214
|
+
method: "search",
|
|
1215
|
+
invocation: { kind: "direct" },
|
|
1216
|
+
parameters: [
|
|
1217
|
+
{ name: "query", wire: "query", source: "json", codec: QUERY_CODEC },
|
|
1218
|
+
{
|
|
1219
|
+
name: "options",
|
|
1220
|
+
wire: "options",
|
|
1221
|
+
source: "json",
|
|
1222
|
+
acceptsUndefined: true,
|
|
1223
|
+
codec: OPTIONS_CODEC,
|
|
1224
|
+
},
|
|
1225
|
+
],
|
|
1226
|
+
result: SEARCH_RESULT,
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
id: "dsh-plugin-discovery#pluginDiscovery/resolve",
|
|
1230
|
+
service: "pluginDiscovery",
|
|
1231
|
+
namespace: "pluginDiscovery",
|
|
1232
|
+
method: "resolve",
|
|
1233
|
+
invocation: { kind: "direct" },
|
|
1234
|
+
parameters: [{ name: "input", wire: "input", source: "json", codec: INPUT_CODEC }],
|
|
1235
|
+
result: RESOLVE_RESULT,
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
id: "dsh-plugin-discovery#pluginDiscovery/installPlugin",
|
|
1239
|
+
service: "pluginDiscovery",
|
|
1240
|
+
namespace: "pluginDiscovery",
|
|
1241
|
+
method: "installPlugin",
|
|
1242
|
+
invocation: { kind: "direct" },
|
|
1243
|
+
parameters: [
|
|
1244
|
+
{ name: "spec", wire: "spec", source: "json", codec: SPEC_CODEC },
|
|
1245
|
+
{
|
|
1246
|
+
name: "options",
|
|
1247
|
+
wire: "options",
|
|
1248
|
+
source: "json",
|
|
1249
|
+
acceptsUndefined: true,
|
|
1250
|
+
codec: INSTALL_OPTIONS_CODEC,
|
|
1251
|
+
},
|
|
1252
|
+
],
|
|
1253
|
+
result: INSTALL_RESULT,
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
id: "dsh-plugin-discovery#pluginDiscovery/listInstalled",
|
|
1257
|
+
service: "pluginDiscovery",
|
|
1258
|
+
namespace: "pluginDiscovery",
|
|
1259
|
+
method: "listInstalled",
|
|
1260
|
+
invocation: { kind: "direct" },
|
|
1261
|
+
parameters: [],
|
|
1262
|
+
result: LIST_INSTALLED_RESULT,
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
id: "dsh-plugin-discovery#pluginDiscovery/waitInstall",
|
|
1266
|
+
service: "pluginDiscovery",
|
|
1267
|
+
namespace: "pluginDiscovery",
|
|
1268
|
+
method: "waitInstall",
|
|
1269
|
+
invocation: { kind: "direct" },
|
|
1270
|
+
parameters: [{ name: "requestId", wire: "requestId", source: "json", codec: WAIT_REQUEST_ID }],
|
|
1271
|
+
result: WAIT_RESULT,
|
|
1272
|
+
},
|
|
1273
|
+
],
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
const inject = ["slots", "locale", "remote"];
|
|
1277
|
+
async function apply(ctx) {
|
|
1278
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "plugin-discovery-ui: dictionaries");
|
|
1279
|
+
let mountError = "";
|
|
1280
|
+
try {
|
|
1281
|
+
const unmount = await ctx.remote.$mount(TYPERT_REMOTE);
|
|
1282
|
+
ctx.effect(
|
|
1283
|
+
() => () => {
|
|
1284
|
+
void unmount();
|
|
1285
|
+
},
|
|
1286
|
+
"plugin-discovery-ui: remote",
|
|
1287
|
+
);
|
|
1288
|
+
} catch (error) {
|
|
1289
|
+
mountError = error && error.message ? error.message : String(error);
|
|
1290
|
+
console.error("[plugin-discovery-ui] remote mount failed", error);
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
const remoteNs = () => ctx.get("remote.pluginDiscovery", false);
|
|
1294
|
+
const api = {
|
|
1295
|
+
search: async (q, opts) => {
|
|
1296
|
+
if (mountError) return { ok: false, message: mountError, results: [] };
|
|
1297
|
+
const remote = remoteNs();
|
|
1298
|
+
if (!remote || typeof remote.search !== "function") {
|
|
1299
|
+
return { ok: false, message: "remote.pluginDiscovery.search unavailable", results: [] };
|
|
1300
|
+
}
|
|
1301
|
+
const wire = await remote.search(q, opts);
|
|
1302
|
+
const value = unwrapRemote(wire, "search failed");
|
|
1303
|
+
if (value && value.ok === false && value.message && !value.results) return value;
|
|
1304
|
+
if (wire && wire.ok === false) return { ok: false, message: value.message, results: [] };
|
|
1305
|
+
return value;
|
|
1306
|
+
},
|
|
1307
|
+
resolve: async (input) => {
|
|
1308
|
+
if (mountError) return { ok: false, message: mountError };
|
|
1309
|
+
const remote = remoteNs();
|
|
1310
|
+
if (!remote || typeof remote.resolve !== "function") {
|
|
1311
|
+
return { ok: false, message: "remote.pluginDiscovery.resolve unavailable" };
|
|
1312
|
+
}
|
|
1313
|
+
const wire = await remote.resolve(input);
|
|
1314
|
+
const value = unwrapRemote(wire, "resolve failed");
|
|
1315
|
+
if (wire && wire.ok === false) return { ok: false, message: value.message };
|
|
1316
|
+
return value;
|
|
1317
|
+
},
|
|
1318
|
+
install: async (spec, options) => {
|
|
1319
|
+
if (mountError) return { ok: false, message: mountError };
|
|
1320
|
+
const remote = remoteNs();
|
|
1321
|
+
if (!remote || typeof remote.installPlugin !== "function") {
|
|
1322
|
+
return { ok: false, message: "remote.pluginDiscovery.installPlugin unavailable" };
|
|
1323
|
+
}
|
|
1324
|
+
const wire = await remote.installPlugin(spec, options);
|
|
1325
|
+
const value = unwrapRemote(wire, "install failed");
|
|
1326
|
+
if (wire && wire.ok === false) {
|
|
1327
|
+
return {
|
|
1328
|
+
ok: false,
|
|
1329
|
+
alreadyInstalled: !!(value && value.alreadyInstalled),
|
|
1330
|
+
packageName: value && value.packageName,
|
|
1331
|
+
requestId: value && value.requestId,
|
|
1332
|
+
message: value && value.message,
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
return value;
|
|
1336
|
+
},
|
|
1337
|
+
listInstalled: async () => {
|
|
1338
|
+
if (mountError) return { ok: false, names: [] };
|
|
1339
|
+
const remote = remoteNs();
|
|
1340
|
+
if (!remote || typeof remote.listInstalled !== "function") {
|
|
1341
|
+
return { ok: false, names: [] };
|
|
1342
|
+
}
|
|
1343
|
+
const wire = await remote.listInstalled();
|
|
1344
|
+
const value = unwrapRemote(wire, "listInstalled failed");
|
|
1345
|
+
if (wire && wire.ok === false) return { ok: false, names: [] };
|
|
1346
|
+
return value;
|
|
1347
|
+
},
|
|
1348
|
+
waitInstall: async (requestId) => {
|
|
1349
|
+
if (mountError) return { ok: false, message: mountError };
|
|
1350
|
+
const remote = remoteNs();
|
|
1351
|
+
if (!remote || typeof remote.waitInstall !== "function") {
|
|
1352
|
+
return { ok: false, message: "remote.pluginDiscovery.waitInstall unavailable" };
|
|
1353
|
+
}
|
|
1354
|
+
const wire = await remote.waitInstall(requestId);
|
|
1355
|
+
const value = unwrapRemote(wire, "waitInstall failed");
|
|
1356
|
+
if (wire && wire.ok === false) return { ok: false, message: value.message || "waitInstall failed" };
|
|
1357
|
+
return value;
|
|
1358
|
+
},
|
|
1359
|
+
subscribePluginChanged: (listener) => {
|
|
1360
|
+
try {
|
|
1361
|
+
return ctx.remote.$on("plugin-manager/changed", listener);
|
|
1362
|
+
} catch {
|
|
1363
|
+
return () => {};
|
|
1364
|
+
}
|
|
1365
|
+
},
|
|
1366
|
+
subscribeInstallState: (listener) => {
|
|
1367
|
+
try {
|
|
1368
|
+
return ctx.remote.$on("plugin-manager/install-state", listener);
|
|
1369
|
+
} catch {
|
|
1370
|
+
return () => {};
|
|
1371
|
+
}
|
|
1372
|
+
},
|
|
1373
|
+
subscribeInstallLog: (listener) => {
|
|
1374
|
+
try {
|
|
1375
|
+
return ctx.remote.$on("plugin-manager/install-log", listener);
|
|
1376
|
+
} catch {
|
|
1377
|
+
return () => {};
|
|
1378
|
+
}
|
|
1379
|
+
},
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1382
|
+
ctx.slots.inject("main", () =>
|
|
1383
|
+
ctx.slots.register(
|
|
1384
|
+
{
|
|
1385
|
+
name: "main",
|
|
1386
|
+
key: PANEL_ID,
|
|
1387
|
+
locale: NS,
|
|
1388
|
+
inject: () => ({ api }),
|
|
1389
|
+
},
|
|
1390
|
+
Panel,
|
|
1391
|
+
),
|
|
1392
|
+
);
|
|
1393
|
+
ctx.slots.inject("sidebar.panellist", () =>
|
|
1394
|
+
ctx.slots.register(
|
|
1395
|
+
{
|
|
1396
|
+
name: "sidebar.panellist",
|
|
1397
|
+
id: PANEL_ID,
|
|
1398
|
+
order: 16,
|
|
1399
|
+
locale: NS,
|
|
1400
|
+
label: () => ctx.locale.bind(NS)("panel"),
|
|
1401
|
+
},
|
|
1402
|
+
PanelIcon,
|
|
1403
|
+
),
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
return { inject, apply };
|
|
1408
|
+
},
|
|
1409
|
+
});
|