@ququ-jiaxk/dsh-plugin-center 0.1.43 → 0.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +264 -46
- package/lib/index.js +73 -3
- package/logo.svg +15 -0
- package/package.json +4 -2
package/lib/client.js
CHANGED
|
@@ -24,13 +24,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
24
24
|
// src/client.tsx
|
|
25
25
|
var client_exports = {};
|
|
26
26
|
__export(client_exports, {
|
|
27
|
+
__testMarkdown: () => __testMarkdown,
|
|
27
28
|
apply: () => apply,
|
|
28
29
|
inject: () => inject
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(client_exports);
|
|
31
32
|
var import_react = require("react");
|
|
33
|
+
|
|
34
|
+
// logo.svg
|
|
35
|
+
var logo_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">%0A <defs>%0A <linearGradient id="g" x1="8" y1="4" x2="56" y2="60" gradientUnits="userSpaceOnUse">%0A <stop stop-color="%232E9BFF" />%0A <stop offset="0.55" stop-color="%230071E3" />%0A <stop offset="1" stop-color="%235E5CE6" />%0A </linearGradient>%0A </defs>%0A <rect width="64" height="64" rx="16" fill="url(%23g)" />%0A <g fill="none" stroke="%23fff" stroke-width="4.5" stroke-linecap="round">%0A <path d="M24 17v9M40 17v9" />%0A <path d="M19 28h26v7.5C45 43 39.2 48 32 48s-13-5-13-12.5V28Z" />%0A </g>%0A <circle cx="32" cy="55" r="2.5" fill="%23fff" opacity=".75" />%0A</svg>%0A';
|
|
36
|
+
|
|
37
|
+
// src/client.tsx
|
|
32
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
-
var PLUGIN_VERSION = true ? "0.1.
|
|
39
|
+
var PLUGIN_VERSION = true ? "0.1.45" : "0.0.0";
|
|
34
40
|
var PANEL_ID = "plugin-center";
|
|
35
41
|
var inject = ["slots", "remote", "remote.pluginManager"];
|
|
36
42
|
var hostCtx = null;
|
|
@@ -155,15 +161,13 @@ function apply(ctx) {
|
|
|
155
161
|
});
|
|
156
162
|
startSelfUpdateWatcher();
|
|
157
163
|
}
|
|
164
|
+
function BrandMark() {
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-logo", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: logo_default, alt: "" }) });
|
|
166
|
+
}
|
|
158
167
|
function PanelIcon({ size = 16 }) {
|
|
159
168
|
const { latest } = useSelfUpdateInfo();
|
|
160
169
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "pcx-sidebar-icon", children: [
|
|
161
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
162
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "1.75", y: "1.75", width: "5", height: "5", rx: "1.2", stroke: "currentColor", strokeWidth: "1.3" }),
|
|
163
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "9.25", y: "1.75", width: "5", height: "5", rx: "1.2", stroke: "currentColor", strokeWidth: "1.3" }),
|
|
164
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "1.75", y: "9.25", width: "5", height: "5", rx: "1.2", stroke: "currentColor", strokeWidth: "1.3" }),
|
|
165
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M11.75 9.5v4.25M9.63 11.63h4.25", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
|
|
166
|
-
] }),
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { className: "pcx-sidebar-logo", src: logo_default, width: size, height: size, alt: "" }),
|
|
167
171
|
latest ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-sidebar-dot", "aria-hidden": "true" }) : null
|
|
168
172
|
] });
|
|
169
173
|
}
|
|
@@ -184,6 +188,158 @@ function isNewer(latest, installed) {
|
|
|
184
188
|
if (!a.pre && b.pre) return true;
|
|
185
189
|
return false;
|
|
186
190
|
}
|
|
191
|
+
function escapeHtml(value) {
|
|
192
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
193
|
+
}
|
|
194
|
+
function safeLinkUrl(url) {
|
|
195
|
+
const value = url.trim();
|
|
196
|
+
return /^(https?:|mailto:)/iu.test(value) ? value : null;
|
|
197
|
+
}
|
|
198
|
+
function safeImageUrl(url) {
|
|
199
|
+
const value = url.trim();
|
|
200
|
+
return /^(https?:\/\/|data:image\/)/iu.test(value) ? value : null;
|
|
201
|
+
}
|
|
202
|
+
function renderInline(raw) {
|
|
203
|
+
let text = escapeHtml(String(raw ?? ""));
|
|
204
|
+
const codes = [];
|
|
205
|
+
text = text.replace(/`([^`]+)`/gu, (_match, code) => {
|
|
206
|
+
codes.push(code);
|
|
207
|
+
return `@@CODE${codes.length - 1}@@`;
|
|
208
|
+
});
|
|
209
|
+
text = text.replace(
|
|
210
|
+
/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^&]*?")?\)/gu,
|
|
211
|
+
(_match, alt, url) => {
|
|
212
|
+
const src = safeImageUrl(url);
|
|
213
|
+
return src ? `<img src="${src}" alt="${alt}" loading="lazy">` : alt;
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
text = text.replace(
|
|
217
|
+
/\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^&]*?")?\)/gu,
|
|
218
|
+
(_match, label, url) => {
|
|
219
|
+
const href = safeLinkUrl(url);
|
|
220
|
+
return href ? `<a href="${href}" target="_blank" rel="noopener noreferrer">${label}</a>` : label;
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
text = text.replace(/\*\*([^*]+)\*\*/gu, "<strong>$1</strong>");
|
|
224
|
+
text = text.replace(/__([^_]+)__/gu, "<strong>$1</strong>");
|
|
225
|
+
text = text.replace(/(^|[^*])\*([^*\n]+)\*/gu, "$1<em>$2</em>");
|
|
226
|
+
text = text.replace(/~~([^~]+)~~/gu, "<del>$1</del>");
|
|
227
|
+
text = text.replace(/@@CODE(\d+)@@/gu, (_match, index) => {
|
|
228
|
+
return `<code>${escapeHtml(codes[Number(index)] ?? "")}</code>`;
|
|
229
|
+
});
|
|
230
|
+
return text;
|
|
231
|
+
}
|
|
232
|
+
function renderMarkdown(source) {
|
|
233
|
+
const lines = String(source ?? "").replace(/\r\n?/gu, "\n").split("\n");
|
|
234
|
+
const out = [];
|
|
235
|
+
let index = 0;
|
|
236
|
+
let paragraph = [];
|
|
237
|
+
let list = null;
|
|
238
|
+
const flushParagraph = () => {
|
|
239
|
+
if (paragraph.length === 0) return;
|
|
240
|
+
out.push(`<p>${paragraph.map((line) => renderInline(line)).join("<br>")}</p>`);
|
|
241
|
+
paragraph = [];
|
|
242
|
+
};
|
|
243
|
+
const closeList = () => {
|
|
244
|
+
if (list === null) return;
|
|
245
|
+
out.push(`</${list}>`);
|
|
246
|
+
list = null;
|
|
247
|
+
};
|
|
248
|
+
const flush = () => {
|
|
249
|
+
flushParagraph();
|
|
250
|
+
closeList();
|
|
251
|
+
};
|
|
252
|
+
while (index < lines.length) {
|
|
253
|
+
const line = lines[index];
|
|
254
|
+
const trimmed = line.trim();
|
|
255
|
+
if (trimmed.startsWith("```")) {
|
|
256
|
+
flush();
|
|
257
|
+
const language = trimmed.slice(3).trim();
|
|
258
|
+
const code = [];
|
|
259
|
+
index += 1;
|
|
260
|
+
while (index < lines.length && !lines[index].trim().startsWith("```")) {
|
|
261
|
+
code.push(lines[index]);
|
|
262
|
+
index += 1;
|
|
263
|
+
}
|
|
264
|
+
index += 1;
|
|
265
|
+
out.push(
|
|
266
|
+
`<pre class="pcx-md-pre"><code${language ? ` class="language-${escapeHtml(language)}"` : ""}>${escapeHtml(
|
|
267
|
+
code.join("\n")
|
|
268
|
+
)}</code></pre>`
|
|
269
|
+
);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (!trimmed) {
|
|
273
|
+
flush();
|
|
274
|
+
index += 1;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
const heading = /^(#{1,6})\s+(.*)$/u.exec(trimmed);
|
|
278
|
+
if (heading) {
|
|
279
|
+
flush();
|
|
280
|
+
const level = heading[1].length;
|
|
281
|
+
out.push(`<h${level}>${renderInline(heading[2])}</h${level}>`);
|
|
282
|
+
index += 1;
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
if (/^(-{3,}|\*{3,}|_{3,})$/u.test(trimmed)) {
|
|
286
|
+
flush();
|
|
287
|
+
out.push("<hr>");
|
|
288
|
+
index += 1;
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (/^>\s?/u.test(trimmed)) {
|
|
292
|
+
flush();
|
|
293
|
+
const quote = [];
|
|
294
|
+
while (index < lines.length && /^>\s?/u.test(lines[index].trim())) {
|
|
295
|
+
quote.push(lines[index].trim().replace(/^>\s?/u, ""));
|
|
296
|
+
index += 1;
|
|
297
|
+
}
|
|
298
|
+
out.push(`<blockquote>${quote.map((item) => renderInline(item)).join("<br>")}</blockquote>`);
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (trimmed.startsWith("|") && index + 1 < lines.length && /^\|?[\s:|-]+\|?$/u.test(lines[index + 1].trim()) && lines[index + 1].includes("-")) {
|
|
302
|
+
flush();
|
|
303
|
+
const cellsOf = (row) => {
|
|
304
|
+
return row.trim().replace(/^\|/u, "").replace(/\|$/u, "").split("|").map((cell) => cell.trim());
|
|
305
|
+
};
|
|
306
|
+
const rows = [cellsOf(trimmed)];
|
|
307
|
+
index += 2;
|
|
308
|
+
while (index < lines.length && lines[index].trim().startsWith("|")) {
|
|
309
|
+
rows.push(cellsOf(lines[index].trim()));
|
|
310
|
+
index += 1;
|
|
311
|
+
}
|
|
312
|
+
const head = rows.shift() ?? [];
|
|
313
|
+
out.push(
|
|
314
|
+
`<table class="pcx-md-table"><thead><tr>${head.map((cell) => `<th>${renderInline(cell)}</th>`).join("")}</tr></thead><tbody>${rows.map((row) => `<tr>${row.map((cell) => `<td>${renderInline(cell)}</td>`).join("")}</tr>`).join("")}</tbody></table>`
|
|
315
|
+
);
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
const unordered = /^[-*+]\s+(.*)$/u.exec(trimmed);
|
|
319
|
+
const ordered = /^\d+[.)]\s+(.*)$/u.exec(trimmed);
|
|
320
|
+
if (unordered || ordered) {
|
|
321
|
+
flushParagraph();
|
|
322
|
+
const kind = unordered ? "ul" : "ol";
|
|
323
|
+
if (list !== kind) {
|
|
324
|
+
closeList();
|
|
325
|
+
out.push(`<${kind}>`);
|
|
326
|
+
list = kind;
|
|
327
|
+
}
|
|
328
|
+
out.push(`<li>${renderInline((unordered ?? ordered)[1])}</li>`);
|
|
329
|
+
index += 1;
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
closeList();
|
|
333
|
+
paragraph.push(line);
|
|
334
|
+
index += 1;
|
|
335
|
+
}
|
|
336
|
+
flush();
|
|
337
|
+
return out.join("\n");
|
|
338
|
+
}
|
|
339
|
+
function Markdown({ text }) {
|
|
340
|
+
const html = (0, import_react.useMemo)(() => renderMarkdown(text), [text]);
|
|
341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-md", dangerouslySetInnerHTML: { __html: html } });
|
|
342
|
+
}
|
|
187
343
|
function Badges({ plugin }) {
|
|
188
344
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
189
345
|
plugin.visibility === "private" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge pcx-badge-private", children: "\u79C1\u6709" }) : null,
|
|
@@ -214,44 +370,63 @@ function InstalledList({
|
|
|
214
370
|
centerItems,
|
|
215
371
|
query,
|
|
216
372
|
onOpen,
|
|
217
|
-
onUninstall
|
|
373
|
+
onUninstall,
|
|
374
|
+
onToggle,
|
|
375
|
+
onInstall
|
|
218
376
|
}) {
|
|
219
377
|
const center = new Map(centerItems.map((item) => [item.packageName, item]));
|
|
220
378
|
const keyword = query.trim().toLowerCase();
|
|
221
|
-
const list = bundles.filter((bundle) => {
|
|
379
|
+
const list = bundles.filter((bundle) => bundle.listedByDefault !== false || bundle.enabled).filter((bundle) => {
|
|
222
380
|
if (!keyword) return true;
|
|
223
381
|
const display = center.get(bundle.name)?.displayName ?? "";
|
|
224
382
|
return bundle.name.toLowerCase().includes(keyword) || display.toLowerCase().includes(keyword);
|
|
225
|
-
});
|
|
383
|
+
}).sort((left, right) => Number(right.enabled) - Number(left.enabled) || left.name.localeCompare(right.name));
|
|
226
384
|
if (list.length === 0) {
|
|
227
385
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-empty", children: [
|
|
228
386
|
keyword ? "\u6CA1\u6709\u5339\u914D\u7684\u672C\u673A\u63D2\u4EF6" : "\u672C\u673A\u8FD8\u6CA1\u6709\u5B89\u88C5\u63D2\u4EF6",
|
|
229
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-empty-hint", children: "\u8FD9\u91CC\u5217\u51FA DSH \u63D2\u4EF6\u7BA1\u7406\u5668\u626B\u63CF\u5230\u7684\u672C\u673A\u63D2\u4EF6\uFF0C\u5305\u542B\u672A\u5728\u4E2D\u5FC3\u4E0A\u67B6\u7684" })
|
|
387
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-empty-hint", children: "\u8FD9\u91CC\u5217\u51FA DSH \u63D2\u4EF6\u7BA1\u7406\u5668\u626B\u63CF\u5230\u7684\u672C\u673A\u63D2\u4EF6\uFF0C\u5305\u542B\u5185\u7F6E\u3001\u5B9E\u9A8C\u6027\u548C\u672A\u5728\u4E2D\u5FC3\u4E0A\u67B6\u7684" })
|
|
230
388
|
] });
|
|
231
389
|
}
|
|
232
390
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-grid", children: list.map((bundle) => {
|
|
233
391
|
const item = center.get(bundle.name);
|
|
392
|
+
const missing = bundle.availability === "missing";
|
|
234
393
|
const localInstall = !bundle.source || /(?:^|[^a-z0-9])(?:file|link):/iu.test(bundle.source);
|
|
394
|
+
const experimental = bundle.name.includes("experimental") || Boolean(bundle.optional);
|
|
235
395
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: "pcx-card", children: [
|
|
236
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
396
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
397
|
+
"div",
|
|
398
|
+
{
|
|
399
|
+
className: "pcx-card-main",
|
|
400
|
+
style: missing ? { cursor: "default" } : void 0,
|
|
401
|
+
onClick: missing ? void 0 : () => onOpen(bundle.name),
|
|
402
|
+
children: [
|
|
403
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-top", children: [
|
|
404
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-icon", children: iconLetter(item?.displayName ?? bundle.name) }),
|
|
405
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-titles", children: [
|
|
406
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-row", children: [
|
|
407
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-name", children: item?.displayName ?? bundle.name }),
|
|
408
|
+
missing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u672A\u5B89\u88C5" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `pcx-badge ${bundle.enabled ? "pcx-badge-ok" : "pcx-badge-warn"}`, children: bundle.enabled ? "\u5DF2\u542F\u7528" : "\u5DF2\u505C\u7528" }),
|
|
409
|
+
bundle.availability === "installation" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u5185\u7F6E" }) : null,
|
|
410
|
+
experimental ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u5B9E\u9A8C\u6027" }) : null,
|
|
411
|
+
bundle.optional ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u53EF\u9009" }) : null,
|
|
412
|
+
bundle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge pcx-badge-danger", children: "\u8BFB\u53D6\u5F02\u5E38" }) : null,
|
|
413
|
+
item ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u672A\u4E0A\u67B6" })
|
|
414
|
+
] }),
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-pkg", children: bundle.name })
|
|
416
|
+
] })
|
|
245
417
|
] }),
|
|
246
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
418
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-foot", children: [
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-foot-owner", children: missing ? "DSH \u81EA\u5E26\uFF0C\u53EF\u5B89\u88C5" : bundle.official ? "\u968F DSH \u5B89\u88C5" : localInstall ? "\u672C\u5730\u5305\u5B89\u88C5" : "registry \u5B89\u88C5" }),
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-foot-meta", children: bundle.version ? `v${bundle.version}` : bundle.installTarget?.version ? `v${bundle.installTarget.version}` : "\u7248\u672C\u672A\u77E5" })
|
|
421
|
+
] })
|
|
422
|
+
]
|
|
423
|
+
}
|
|
424
|
+
),
|
|
425
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-actions", children: [
|
|
426
|
+
missing && bundle.installTarget ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "pcx-btn pcx-btn-primary pcx-btn-sm", onClick: () => onInstall(bundle.name), children: "\u5B89\u88C5" }) : null,
|
|
427
|
+
!missing && bundle.name !== "@ququ-jiaxk/dsh-plugin-center" && (bundle.optional || bundle.installed) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "pcx-btn pcx-btn-sm", onClick: () => onToggle(bundle.name, !bundle.enabled), children: bundle.enabled ? "\u505C\u7528" : "\u542F\u7528" }) : null,
|
|
428
|
+
bundle.removable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "pcx-btn pcx-btn-sm pcx-btn-danger", onClick: () => onUninstall(bundle.name), children: "\u5378\u8F7D" }) : null
|
|
429
|
+
] })
|
|
255
430
|
] }, bundle.name);
|
|
256
431
|
}) });
|
|
257
432
|
}
|
|
@@ -268,7 +443,7 @@ function LocalDetailView({
|
|
|
268
443
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-root", children: [
|
|
269
444
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "pcx-back", onClick: onBack, children: "\u2190 \u8FD4\u56DE\u5217\u8868" }),
|
|
270
445
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-detail-head", children: [
|
|
271
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-icon pcx-icon-lg", children: iconLetter(bundle.displayName ?? bundle.name) }),
|
|
446
|
+
bundle.icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { className: "pcx-detail-icon", src: bundle.icon, alt: "" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-icon pcx-icon-lg", children: iconLetter(bundle.displayName ?? bundle.name) }),
|
|
272
447
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-detail-titles", children: [
|
|
273
448
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-row", children: [
|
|
274
449
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "pcx-title", children: bundle.displayName ?? bundle.name }),
|
|
@@ -292,7 +467,7 @@ function LocalDetailView({
|
|
|
292
467
|
] }),
|
|
293
468
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "pcx-section", children: [
|
|
294
469
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "pcx-h2", children: "\u63D2\u4EF6\u8BE6\u60C5" }),
|
|
295
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
470
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Markdown, { text: markdown || bundle.description || "\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B README \u6216 locale \u8BE6\u60C5\u3002" })
|
|
296
471
|
] }),
|
|
297
472
|
origin ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "pcx-section", children: [
|
|
298
473
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "pcx-h2", children: "\u8BE6\u60C5\u6765\u6E90" }),
|
|
@@ -626,6 +801,27 @@ function Panel() {
|
|
|
626
801
|
}
|
|
627
802
|
});
|
|
628
803
|
}
|
|
804
|
+
async function toggleBundle(packageName, enabled) {
|
|
805
|
+
setError("");
|
|
806
|
+
try {
|
|
807
|
+
await api("/bundle-enabled", { method: "POST", body: { name: packageName, enabled } });
|
|
808
|
+
setNotice(`${enabled ? "\u5DF2\u542F\u7528" : "\u5DF2\u505C\u7528"} ${packageName}`);
|
|
809
|
+
await load(scope, category, query);
|
|
810
|
+
} catch (err) {
|
|
811
|
+
setError(err.message);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
async function installDshBundle(packageName) {
|
|
815
|
+
setError("");
|
|
816
|
+
setNotice(`\u6B63\u5728\u5B89\u88C5 ${packageName}\u2026`);
|
|
817
|
+
try {
|
|
818
|
+
await api("/bundle-install", { method: "POST", body: { name: packageName } });
|
|
819
|
+
setNotice(`\u5DF2\u5B89\u88C5 ${packageName}`);
|
|
820
|
+
await load(scope, category, query);
|
|
821
|
+
} catch (err) {
|
|
822
|
+
setError(err.message);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
629
825
|
async function install(packageName, version) {
|
|
630
826
|
setNotice(`\u6B63\u5728\u5B89\u88C5 ${packageName}${version ? `@${version}` : ""}\u2026`);
|
|
631
827
|
setError("");
|
|
@@ -921,7 +1117,7 @@ function Panel() {
|
|
|
921
1117
|
children: [
|
|
922
1118
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "pcx-header", children: [
|
|
923
1119
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-brand", children: [
|
|
924
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BrandMark, {}),
|
|
925
1121
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
926
1122
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h1", { className: "pcx-title", children: [
|
|
927
1123
|
"\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3",
|
|
@@ -1088,11 +1284,11 @@ function Panel() {
|
|
|
1088
1284
|
"button",
|
|
1089
1285
|
{
|
|
1090
1286
|
className: `pcx-tab ${scope === "installed" ? "pcx-tab-active" : ""}`,
|
|
1091
|
-
title: "\u626B\u63CF\u672C\u673A DSH \
|
|
1287
|
+
title: "\u626B\u63CF\u672C\u673A DSH \u7684\u63D2\u4EF6\uFF1A\u5185\u7F6E\u3001\u5B9E\u9A8C\u6027\u3001\u53EF\u9009\u4E0E\u5DF2\u5B89\u88C5\u7684\u7B2C\u4E09\u65B9\u63D2\u4EF6",
|
|
1092
1288
|
onClick: () => applyFilters({ scope: "installed" }),
|
|
1093
1289
|
children: [
|
|
1094
|
-
"\
|
|
1095
|
-
state?.
|
|
1290
|
+
"\u672C\u673A",
|
|
1291
|
+
state?.bundles?.length ? ` \xB7 ${state.bundles.length}` : ""
|
|
1096
1292
|
]
|
|
1097
1293
|
}
|
|
1098
1294
|
)
|
|
@@ -1135,14 +1331,16 @@ function Panel() {
|
|
|
1135
1331
|
scope === "installed" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1136
1332
|
InstalledList,
|
|
1137
1333
|
{
|
|
1138
|
-
bundles: state?.installed ?? [],
|
|
1334
|
+
bundles: state?.bundles ?? state?.installed ?? [],
|
|
1139
1335
|
centerItems: items,
|
|
1140
1336
|
query,
|
|
1141
1337
|
onOpen: (name) => {
|
|
1142
1338
|
if (items.some((plugin) => plugin.packageName === name)) void openDetail(name);
|
|
1143
1339
|
else void openLocalDetail(name);
|
|
1144
1340
|
},
|
|
1145
|
-
onUninstall: uninstallLocal
|
|
1341
|
+
onUninstall: uninstallLocal,
|
|
1342
|
+
onToggle: (name, enabled) => void toggleBundle(name, enabled),
|
|
1343
|
+
onInstall: (name) => void installDshBundle(name)
|
|
1146
1344
|
}
|
|
1147
1345
|
) : loading && items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-empty", children: "\u6B63\u5728\u52A0\u8F7D\u2026" }) : items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-empty", children: [
|
|
1148
1346
|
scope === "mine" ? "\u4F60\u8FD8\u6CA1\u6709\u4E0A\u4F20\u8FC7\u63D2\u4EF6" : "\u6CA1\u6709\u627E\u5230\u63D2\u4EF6",
|
|
@@ -1250,7 +1448,7 @@ function UploadView({
|
|
|
1250
1448
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-root", children: [
|
|
1251
1449
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "pcx-header", children: [
|
|
1252
1450
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-brand", children: [
|
|
1253
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1451
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BrandMark, {}),
|
|
1254
1452
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
1255
1453
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "pcx-title", children: "\u4E0A\u4F20\u63D2\u4EF6" }),
|
|
1256
1454
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-sub", children: "\u6B63\u5728\u8BFB\u53D6\u767B\u5F55\u72B6\u6001\u2026" })
|
|
@@ -1265,7 +1463,7 @@ function UploadView({
|
|
|
1265
1463
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-root", children: [
|
|
1266
1464
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "pcx-header", children: [
|
|
1267
1465
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-brand", children: [
|
|
1268
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1466
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BrandMark, {}),
|
|
1269
1467
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
1270
1468
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "pcx-title", children: "\u4E0A\u4F20\u63D2\u4EF6" }),
|
|
1271
1469
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-sub", children: "\u767B\u5F55\u540E\u5373\u53EF\u53D1\u5E03\u63D2\u4EF6" })
|
|
@@ -1343,7 +1541,7 @@ function UploadView({
|
|
|
1343
1541
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-root", children: [
|
|
1344
1542
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "pcx-header", children: [
|
|
1345
1543
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-brand", children: [
|
|
1346
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1544
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BrandMark, {}),
|
|
1347
1545
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
1348
1546
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "pcx-title", children: "\u4E0A\u4F20\u63D2\u4EF6" }),
|
|
1349
1547
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-sub", children: "\u5FC5\u586B\uFF1A\u5305\u540D\u3001\u540D\u79F0\u3001\u63CF\u8FF0\u3001\u4F7F\u7528\u65B9\u6CD5\u3001\u5305\u6587\u4EF6\u3001\u7248\u672C\u53F7" })
|
|
@@ -1805,11 +2003,11 @@ function DetailView({
|
|
|
1805
2003
|
notice ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-alert pcx-alert-success", children: notice }) : null,
|
|
1806
2004
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "pcx-section", children: [
|
|
1807
2005
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "pcx-h2", children: "\u63D2\u4EF6\u63CF\u8FF0" }),
|
|
1808
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2006
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Markdown, { text: detail.descriptionMd || "\u6682\u65E0\u63CF\u8FF0" })
|
|
1809
2007
|
] }),
|
|
1810
2008
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "pcx-section", children: [
|
|
1811
2009
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "pcx-h2", children: "\u4F7F\u7528\u65B9\u6CD5" }),
|
|
1812
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2010
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Markdown, { text: detail.usageMd || "\u6682\u65E0" })
|
|
1813
2011
|
] }),
|
|
1814
2012
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "pcx-section", children: [
|
|
1815
2013
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { className: "pcx-h2", children: [
|
|
@@ -2468,7 +2666,7 @@ function AdminView({
|
|
|
2468
2666
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "pcx-back", onClick: onBack, children: "\u2190 \u8FD4\u56DE\u5217\u8868" }),
|
|
2469
2667
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "pcx-header", children: [
|
|
2470
2668
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-brand", children: [
|
|
2471
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2669
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BrandMark, {}),
|
|
2472
2670
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
2473
2671
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "pcx-title", children: "\u6CBB\u7406" }),
|
|
2474
2672
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-sub", children: "\u4E0B\u67B6\u53EF\u6062\u590D\uFF1B\u5C01\u7981\u9700\u5BA1\u6838\uFF1B\u7BA1\u7406\u5458\u4E0D\u80FD\u5220\u9664\u63D2\u4EF6" })
|
|
@@ -2805,11 +3003,30 @@ var CSS = `
|
|
|
2805
3003
|
}
|
|
2806
3004
|
.pcx-logo {
|
|
2807
3005
|
width: 28px; height: 28px; border-radius: 8px; flex: none;
|
|
2808
|
-
display: grid; place-items: center;
|
|
3006
|
+
display: grid; place-items: center; overflow: hidden;
|
|
2809
3007
|
background: var(--dsw-alias-button-primary-fill, #0f1115);
|
|
2810
|
-
color: var(--dsw-alias-label-primary-foreground, #fff);
|
|
2811
|
-
font-size: 13px; font-weight: 700;
|
|
2812
3008
|
}
|
|
3009
|
+
.pcx-logo img { width: 100%; height: 100%; display: block; }
|
|
3010
|
+
.pcx-sidebar-logo { display: block; border-radius: 5px; object-fit: cover; }
|
|
3011
|
+
.pcx-detail-icon { width: 44px; height: 44px; border-radius: 12px; flex: none; object-fit: cover; }
|
|
3012
|
+
.pcx-md { font-size: 12.5px; line-height: 1.65; color: var(--dsw-alias-label-primary, #1a1a1a); word-break: break-word; }
|
|
3013
|
+
.pcx-md > :first-child { margin-top: 0; }
|
|
3014
|
+
.pcx-md > :last-child { margin-bottom: 0; }
|
|
3015
|
+
.pcx-md h1, .pcx-md h2, .pcx-md h3, .pcx-md h4, .pcx-md h5, .pcx-md h6 { margin: 14px 0 6px; font-size: 13.5px; font-weight: 600; }
|
|
3016
|
+
.pcx-md h1 { font-size: 15px; }
|
|
3017
|
+
.pcx-md p { margin: 6px 0; }
|
|
3018
|
+
.pcx-md ul, .pcx-md ol { margin: 6px 0; padding-left: 20px; }
|
|
3019
|
+
.pcx-md li { margin: 2px 0; }
|
|
3020
|
+
.pcx-md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; padding: 1px 4px; border-radius: 4px; background: var(--dsw-alias-interactive-bg-hover, rgba(0,0,0,.06)); }
|
|
3021
|
+
.pcx-md pre { margin: 8px 0; padding: 10px 12px; border-radius: 8px; overflow: auto; background: var(--dsw-alias-interactive-bg-hover, rgba(0,0,0,.06)); }
|
|
3022
|
+
.pcx-md pre code { padding: 0; background: none; }
|
|
3023
|
+
.pcx-md blockquote { margin: 8px 0; padding: 2px 10px; border-left: 3px solid var(--dsw-alias-border-l3, rgba(0,0,0,.15)); color: var(--dsw-alias-label-secondary, #61666b); }
|
|
3024
|
+
.pcx-md img { max-width: 100%; border-radius: 6px; }
|
|
3025
|
+
.pcx-md table { border-collapse: collapse; margin: 8px 0; font-size: 12px; }
|
|
3026
|
+
.pcx-md th, .pcx-md td { border: 1px solid var(--dsw-alias-border-l2, rgba(0,0,0,.1)); padding: 5px 8px; text-align: left; }
|
|
3027
|
+
.pcx-md a { color: var(--dsw-alias-state-business-primary, #1f6feb); text-decoration: none; }
|
|
3028
|
+
.pcx-md a:hover { text-decoration: underline; }
|
|
3029
|
+
.pcx-md hr { border: 0; border-top: 1px solid var(--dsw-alias-border-l2, rgba(0,0,0,.1)); margin: 12px 0; }
|
|
2813
3030
|
.pcx-title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
|
|
2814
3031
|
.pcx-version-tag {
|
|
2815
3032
|
display: inline-flex; align-items: center; height: 18px; margin-left: 7px; padding: 0 6px;
|
|
@@ -3149,6 +3366,7 @@ var CSS = `
|
|
|
3149
3366
|
.pcx-trace { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,.04); font-size: 11px; }
|
|
3150
3367
|
.pcx-trace pre { margin: 6px 0 0; white-space: pre-wrap; font-family: ui-monospace, monospace; }
|
|
3151
3368
|
`;
|
|
3369
|
+
var __testMarkdown = renderMarkdown;
|
|
3152
3370
|
|
|
3153
3371
|
return module.exports;
|
|
3154
3372
|
}
|
package/lib/index.js
CHANGED
|
@@ -384,10 +384,11 @@ export function apply(ctx) {
|
|
|
384
384
|
source: null,
|
|
385
385
|
}
|
|
386
386
|
const manager = ctx.get('pluginManager')
|
|
387
|
+
let bundles = []
|
|
387
388
|
if (manager) {
|
|
388
389
|
try {
|
|
389
|
-
const
|
|
390
|
-
installed =
|
|
390
|
+
const list = await manager.listBundles()
|
|
391
|
+
installed = list
|
|
391
392
|
.filter((bundle) => bundle.installed)
|
|
392
393
|
.map((bundle) => ({
|
|
393
394
|
name: bundle.name,
|
|
@@ -399,7 +400,24 @@ export function apply(ctx) {
|
|
|
399
400
|
source: bundle.source ?? null,
|
|
400
401
|
error: bundle.error?.code ?? null,
|
|
401
402
|
}))
|
|
402
|
-
|
|
403
|
+
// DSH 内置 / 实验性 / 可选 bundle 不一定在 profile 依赖里(availability: installation),
|
|
404
|
+
// 单独给一份完整清单,供「本机」视图展示和启用。
|
|
405
|
+
bundles = list.map((bundle) => ({
|
|
406
|
+
name: bundle.name,
|
|
407
|
+
version: bundle.version ?? null,
|
|
408
|
+
enabled: bundle.enabled,
|
|
409
|
+
installed: Boolean(bundle.installed),
|
|
410
|
+
availability: bundle.availability ?? null,
|
|
411
|
+
official: Boolean(bundle.official),
|
|
412
|
+
optional: Boolean(bundle.optional),
|
|
413
|
+
removable: Boolean(bundle.removable),
|
|
414
|
+
source: bundle.source ?? null,
|
|
415
|
+
error: bundle.error?.code ?? null,
|
|
416
|
+
description: bundle.description ?? null,
|
|
417
|
+
listedByDefault: bundle.listedByDefault !== false,
|
|
418
|
+
installTarget: bundle.installTarget ?? null,
|
|
419
|
+
}))
|
|
420
|
+
const own = list.find((bundle) => bundle.name === SELF_PACKAGE)
|
|
403
421
|
if (own) {
|
|
404
422
|
self = {
|
|
405
423
|
name: own.name,
|
|
@@ -423,12 +441,63 @@ export function apply(ctx) {
|
|
|
423
441
|
hostVersion: HOST_VERSION,
|
|
424
442
|
user,
|
|
425
443
|
installed,
|
|
444
|
+
bundles,
|
|
426
445
|
self,
|
|
427
446
|
selfUpdate: readSelfUpdateRecord(),
|
|
428
447
|
selfUpdateSupported: selfUpdateCapability(manager).supported,
|
|
429
448
|
})
|
|
430
449
|
}
|
|
431
450
|
|
|
451
|
+
// 启用/停用本机 bundle(含 DSH 内置、实验性、可选插件)。
|
|
452
|
+
if (req.method === 'POST' && path === '/bundle-enabled') {
|
|
453
|
+
const body = await readJson(req)
|
|
454
|
+
const name = String(body.name ?? '')
|
|
455
|
+
if (!name) return send(res, 400, { error: '缺少 name 参数' })
|
|
456
|
+
const manager = ctx.get('pluginManager')
|
|
457
|
+
if (!manager) return send(res, 503, { error: 'DSH 插件管理器不可用' })
|
|
458
|
+
if (typeof manager.setBundleEnabled !== 'function') {
|
|
459
|
+
return send(res, 409, { error: '当前 DSH 版本不支持启用/停用 bundle' })
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
const result = await manager.setBundleEnabled(name, Boolean(body.enabled))
|
|
463
|
+
if (result?.error) {
|
|
464
|
+
const detail =
|
|
465
|
+
typeof result.error === 'string' ? result.error : (result.error.message ?? result.error.code)
|
|
466
|
+
return send(res, 400, { error: detail ?? '操作失败', code: result.error.code ?? null })
|
|
467
|
+
}
|
|
468
|
+
logInstall(`bundle-enabled name=${name} enabled=${Boolean(body.enabled)}`)
|
|
469
|
+
return send(res, 200, {
|
|
470
|
+
ok: true,
|
|
471
|
+
name,
|
|
472
|
+
enabled: Boolean(body.enabled),
|
|
473
|
+
application: result?.application ?? null,
|
|
474
|
+
})
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// 安装 DSH 自带的可选 / 实验性 bundle(listBundles 里带 installTarget 的条目)。
|
|
478
|
+
if (req.method === 'POST' && path === '/bundle-install') {
|
|
479
|
+
const body = await readJson(req)
|
|
480
|
+
const name = String(body.name ?? '')
|
|
481
|
+
if (!name) return send(res, 400, { error: '缺少 name 参数' })
|
|
482
|
+
const manager = ctx.get('pluginManager')
|
|
483
|
+
if (!manager) return send(res, 503, { error: 'DSH 插件管理器不可用' })
|
|
484
|
+
|
|
485
|
+
const list = await manager.listBundles()
|
|
486
|
+
const bundle = list.find((item) => item.name === name)
|
|
487
|
+
if (!bundle) return send(res, 404, { error: `没有找到 ${name}` })
|
|
488
|
+
const spec = bundle.installTarget?.spec
|
|
489
|
+
if (!spec) return send(res, 400, { error: '该插件没有可用的安装来源(不是 DSH 自带的可选插件)' })
|
|
490
|
+
|
|
491
|
+
const result = await manager.installBundle(spec, { enabled: true })
|
|
492
|
+
if (result?.error) {
|
|
493
|
+
const detail =
|
|
494
|
+
typeof result.error === 'string' ? result.error : (result.error.message ?? result.error.code)
|
|
495
|
+
return send(res, 400, { error: detail ?? '安装失败', code: result.error.code ?? null })
|
|
496
|
+
}
|
|
497
|
+
logInstall(`bundle-install name=${name} spec=${spec}`)
|
|
498
|
+
return send(res, 200, { ok: true, name, version: result?.version ?? bundle.installTarget?.version ?? null })
|
|
499
|
+
}
|
|
500
|
+
|
|
432
501
|
if (req.method === 'GET' && path === '/self/update-check') {
|
|
433
502
|
const manager = ctx.get('pluginManager')
|
|
434
503
|
if (!manager) return send(res, 503, { error: 'DSH 插件管理器不可用(当前不是 profile 模式)' })
|
|
@@ -944,6 +1013,7 @@ export function apply(ctx) {
|
|
|
944
1013
|
name: bundle.name,
|
|
945
1014
|
displayName: typeof meta.name === 'string' ? meta.name : bundle.name,
|
|
946
1015
|
summary: typeof meta.summary === 'string' ? meta.summary : (bundle.description ?? ''),
|
|
1016
|
+
icon: typeof meta.icon === 'string' ? meta.icon : null,
|
|
947
1017
|
description: bundle.description ?? null,
|
|
948
1018
|
version: bundle.version ?? null,
|
|
949
1019
|
enabled: bundle.enabled,
|
package/logo.svg
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="g" x1="8" y1="4" x2="56" y2="60" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop stop-color="#2E9BFF" />
|
|
5
|
+
<stop offset="0.55" stop-color="#0071E3" />
|
|
6
|
+
<stop offset="1" stop-color="#5E5CE6" />
|
|
7
|
+
</linearGradient>
|
|
8
|
+
</defs>
|
|
9
|
+
<rect width="64" height="64" rx="16" fill="url(#g)" />
|
|
10
|
+
<g fill="none" stroke="#fff" stroke-width="4.5" stroke-linecap="round">
|
|
11
|
+
<path d="M24 17v9M40 17v9" />
|
|
12
|
+
<path d="M19 28h26v7.5C45 43 39.2 48 32 48s-13-5-13-12.5V28Z" />
|
|
13
|
+
</g>
|
|
14
|
+
<circle cx="32" cy="55" r="2.5" fill="#fff" opacity=".75" />
|
|
15
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ququ-jiaxk/dsh-plugin-center",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
4
4
|
"description": "小趣插件中心:浏览、安装、更新和发布远端插件中心的插件",
|
|
5
|
+
"icon": "logo.svg",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "lib/index.js",
|
|
7
8
|
"exports": {
|
|
@@ -11,7 +12,8 @@
|
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
14
|
"lib",
|
|
14
|
-
"cordis.patch.yml"
|
|
15
|
+
"cordis.patch.yml",
|
|
16
|
+
"logo.svg"
|
|
15
17
|
],
|
|
16
18
|
"dsh": {
|
|
17
19
|
"bundle": {
|