@ququ-jiaxk/dsh-plugin-center 0.1.41 → 0.1.43
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 +113 -42
- package/lib/index.js +43 -5
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -30,7 +30,7 @@ __export(client_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(client_exports);
|
|
31
31
|
var import_react = require("react");
|
|
32
32
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
-
var PLUGIN_VERSION = true ? "0.1.
|
|
33
|
+
var PLUGIN_VERSION = true ? "0.1.43" : "0.0.0";
|
|
34
34
|
var PANEL_ID = "plugin-center";
|
|
35
35
|
var inject = ["slots", "remote", "remote.pluginManager"];
|
|
36
36
|
var hostCtx = null;
|
|
@@ -145,7 +145,7 @@ function apply(ctx) {
|
|
|
145
145
|
name: "sidebar.panellist",
|
|
146
146
|
id: PANEL_ID,
|
|
147
147
|
order: 20,
|
|
148
|
-
label: () => "\u63D2\u4EF6\u4E2D\u5FC3"
|
|
148
|
+
label: () => "\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3"
|
|
149
149
|
},
|
|
150
150
|
PanelIcon
|
|
151
151
|
)
|
|
@@ -233,36 +233,73 @@ function InstalledList({
|
|
|
233
233
|
const item = center.get(bundle.name);
|
|
234
234
|
const localInstall = !bundle.source || /(?:^|[^a-z0-9])(?:file|link):/iu.test(bundle.source);
|
|
235
235
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: "pcx-card", children: [
|
|
236
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
237
|
-
"div",
|
|
238
|
-
|
|
239
|
-
className: "pcx-card-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-
|
|
245
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-titles", children: [
|
|
246
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-row", children: [
|
|
247
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-name", children: item?.displayName ?? bundle.name }),
|
|
248
|
-
/* @__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" }),
|
|
249
|
-
bundle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge pcx-badge-danger", children: "\u8BFB\u53D6\u5F02\u5E38" }) : null,
|
|
250
|
-
item ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u672A\u4E0A\u67B6" })
|
|
251
|
-
] }),
|
|
252
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-pkg", children: bundle.name })
|
|
253
|
-
] })
|
|
236
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-main", onClick: () => onOpen(bundle.name), children: [
|
|
237
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-top", children: [
|
|
238
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-icon", children: iconLetter(item?.displayName ?? bundle.name) }),
|
|
239
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-titles", children: [
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-row", children: [
|
|
241
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-name", children: item?.displayName ?? bundle.name }),
|
|
242
|
+
/* @__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" }),
|
|
243
|
+
bundle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge pcx-badge-danger", children: "\u8BFB\u53D6\u5F02\u5E38" }) : null,
|
|
244
|
+
item ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u672A\u4E0A\u67B6" })
|
|
254
245
|
] }),
|
|
255
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
246
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-pkg", children: bundle.name })
|
|
247
|
+
] })
|
|
248
|
+
] }),
|
|
249
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-foot", children: [
|
|
250
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-foot-owner", children: bundle.official ? "\u968F DSH \u5B89\u88C5" : localInstall ? "\u672C\u5730\u5305\u5B89\u88C5" : "registry \u5B89\u88C5" }),
|
|
251
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-foot-meta", children: bundle.version ? `v${bundle.version}` : "\u7248\u672C\u672A\u77E5" })
|
|
252
|
+
] })
|
|
253
|
+
] }),
|
|
262
254
|
bundle.removable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-card-actions", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "pcx-btn pcx-btn-sm pcx-btn-danger", onClick: () => onUninstall(bundle.name), children: "\u5378\u8F7D" }) }) : null
|
|
263
255
|
] }, bundle.name);
|
|
264
256
|
}) });
|
|
265
257
|
}
|
|
258
|
+
function LocalDetailView({
|
|
259
|
+
data,
|
|
260
|
+
onBack,
|
|
261
|
+
onOpenCenter,
|
|
262
|
+
onUninstall
|
|
263
|
+
}) {
|
|
264
|
+
const bundle = data.bundle;
|
|
265
|
+
const markdown = data.detail && data.detail.status === "found" ? data.detail.markdown : "";
|
|
266
|
+
const origin = data.detail && data.detail.status === "found" ? data.detail.path : "";
|
|
267
|
+
const localInstall = !bundle.source || /(?:^|[^a-z0-9])(?:file|link):/iu.test(bundle.source);
|
|
268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-root", children: [
|
|
269
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "pcx-back", onClick: onBack, children: "\u2190 \u8FD4\u56DE\u5217\u8868" }),
|
|
270
|
+
/* @__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) }),
|
|
272
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-detail-titles", children: [
|
|
273
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-row", children: [
|
|
274
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "pcx-title", children: bundle.displayName ?? bundle.name }),
|
|
275
|
+
/* @__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" }),
|
|
276
|
+
bundle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge pcx-badge-danger", children: "\u8BFB\u53D6\u5F02\u5E38" }) : null
|
|
277
|
+
] }),
|
|
278
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-pkg", children: bundle.name }),
|
|
279
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-desc pcx-desc-block", children: bundle.summary || "\u672C\u673A\u5B89\u88C5\u7684\u63D2\u4EF6" })
|
|
280
|
+
] })
|
|
281
|
+
] }),
|
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-actions pcx-actions-left", children: [
|
|
283
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "pcx-sub", children: [
|
|
284
|
+
bundle.version ? `v${bundle.version}` : "\u7248\u672C\u672A\u77E5",
|
|
285
|
+
" \xB7",
|
|
286
|
+
" ",
|
|
287
|
+
bundle.official ? "\u968F DSH \u5B89\u88C5" : localInstall ? "\u672C\u5730\u5305\u5B89\u88C5" : "registry \u5B89\u88C5",
|
|
288
|
+
bundle.source ? ` \xB7 ${bundle.source}` : ""
|
|
289
|
+
] }),
|
|
290
|
+
onOpenCenter ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "pcx-btn", onClick: onOpenCenter, children: "\u5728\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u67E5\u770B" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u672A\u5728\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u4E0A\u67B6" }),
|
|
291
|
+
bundle.removable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "pcx-btn pcx-btn-danger", onClick: onUninstall, children: "\u5378\u8F7D" }) : null
|
|
292
|
+
] }),
|
|
293
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "pcx-section", children: [
|
|
294
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "pcx-h2", children: "\u63D2\u4EF6\u8BE6\u60C5" }),
|
|
295
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-text", children: markdown || bundle.description || "\u8FD9\u4E2A\u63D2\u4EF6\u6CA1\u6709\u63D0\u4F9B README \u6216 locale \u8BE6\u60C5\u3002" })
|
|
296
|
+
] }),
|
|
297
|
+
origin ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "pcx-section", children: [
|
|
298
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "pcx-h2", children: "\u8BE6\u60C5\u6765\u6E90" }),
|
|
299
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-text", children: origin })
|
|
300
|
+
] }) : null
|
|
301
|
+
] });
|
|
302
|
+
}
|
|
266
303
|
function Panel() {
|
|
267
304
|
const cached = panelSnapshot;
|
|
268
305
|
const rootRef = (0, import_react.useRef)(null);
|
|
@@ -286,6 +323,7 @@ function Panel() {
|
|
|
286
323
|
const pushTrace = (line) => setTrace((current) => [...current.slice(-7), `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} ${line}`]);
|
|
287
324
|
const [view, setView] = (0, import_react.useState)(cached?.view ?? "list");
|
|
288
325
|
const [detail, setDetail] = (0, import_react.useState)(cached?.detail ?? null);
|
|
326
|
+
const [localDetail, setLocalDetail] = (0, import_react.useState)(null);
|
|
289
327
|
const [binding, setBinding] = (0, import_react.useState)(false);
|
|
290
328
|
const [dialog, setDialog] = (0, import_react.useState)(null);
|
|
291
329
|
const [passwordOpen, setPasswordOpen] = (0, import_react.useState)(false);
|
|
@@ -406,7 +444,7 @@ function Panel() {
|
|
|
406
444
|
return;
|
|
407
445
|
}
|
|
408
446
|
setSelfUpdate({ phase: "idle" });
|
|
409
|
-
if (manual) setNotice("\u63D2\u4EF6\u4E2D\u5FC3\u5DF2\u662F\u6700\u65B0\u7248\u672C");
|
|
447
|
+
if (manual) setNotice("\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u5DF2\u662F\u6700\u65B0\u7248\u672C");
|
|
410
448
|
}
|
|
411
449
|
async function pollSelfUpdate(version) {
|
|
412
450
|
if (selfUpdatePolling) return;
|
|
@@ -455,7 +493,7 @@ function Panel() {
|
|
|
455
493
|
setSelfUpdate({
|
|
456
494
|
phase: "error",
|
|
457
495
|
to: version,
|
|
458
|
-
message: "\u66F4\u65B0\u8D85\u65F6\uFF1A\u8BF7\u5230 DSH \u7684 Plugins \u9875\u9762\u786E\u8BA4\u63D2\u4EF6\u4E2D\u5FC3\u7248\u672C\uFF0C\u6216\u91CD\u542F DSH \u540E\u91CD\u8BD5"
|
|
496
|
+
message: "\u66F4\u65B0\u8D85\u65F6\uFF1A\u8BF7\u5230 DSH \u7684 Plugins \u9875\u9762\u786E\u8BA4\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u7248\u672C\uFF0C\u6216\u91CD\u542F DSH \u540E\u91CD\u8BD5"
|
|
459
497
|
});
|
|
460
498
|
} finally {
|
|
461
499
|
selfUpdatePolling = false;
|
|
@@ -476,7 +514,7 @@ function Panel() {
|
|
|
476
514
|
}
|
|
477
515
|
function confirmSelfUpdate(version) {
|
|
478
516
|
setDialog({
|
|
479
|
-
title: `\u66F4\u65B0\u63D2\u4EF6\u4E2D\u5FC3\u5230 v${version}`,
|
|
517
|
+
title: `\u66F4\u65B0\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u5230 v${version}`,
|
|
480
518
|
description: "\u66F4\u65B0\u4F1A\u5148\u5378\u8F7D\u65E7\u7248\u672C\u518D\u5B89\u88C5\u65B0\u7248\u672C\uFF0C\u9762\u677F\u5C06\u65AD\u5F00\u51E0\u79D2\uFF0C\u5B8C\u6210\u540E\u81EA\u52A8\u5237\u65B0\u3002\u5931\u8D25\u65F6 DSH \u4F1A\u81EA\u52A8\u6062\u590D\u65E7\u7248\u672C\u3002",
|
|
481
519
|
input: false,
|
|
482
520
|
confirmLabel: "\u5F00\u59CB\u66F4\u65B0",
|
|
@@ -510,7 +548,7 @@ function Panel() {
|
|
|
510
548
|
if (record.phase === "done" && record.to) {
|
|
511
549
|
selfUpdateNotified = true;
|
|
512
550
|
setNotice(
|
|
513
|
-
record.restartReason ? `\u5DF2\u5B89\u88C5 v${record.to}\uFF0C\u91CD\u542F DSH \u540E\u751F\u6548` : `\u63D2\u4EF6\u4E2D\u5FC3\u5DF2\u66F4\u65B0\u5230 v${record.to}`
|
|
551
|
+
record.restartReason ? `\u5DF2\u5B89\u88C5 v${record.to}\uFF0C\u91CD\u542F DSH \u540E\u751F\u6548` : `\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u5DF2\u66F4\u65B0\u5230 v${record.to}`
|
|
514
552
|
);
|
|
515
553
|
return;
|
|
516
554
|
}
|
|
@@ -576,12 +614,13 @@ function Panel() {
|
|
|
576
614
|
function uninstallLocal(packageName) {
|
|
577
615
|
setDialog({
|
|
578
616
|
title: `\u5378\u8F7D\u300C${packageName}\u300D\uFF1F`,
|
|
579
|
-
description: "\u53EA\u4ECE\u672C\u673A DSH \u79FB\u9664\uFF0C\u4E0D\u5F71\u54CD\u63D2\u4EF6\u4E2D\u5FC3\u91CC\u7684\u7248\u672C\u3002",
|
|
617
|
+
description: "\u53EA\u4ECE\u672C\u673A DSH \u79FB\u9664\uFF0C\u4E0D\u5F71\u54CD\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u91CC\u7684\u7248\u672C\u3002",
|
|
580
618
|
input: false,
|
|
581
619
|
confirmLabel: "\u5378\u8F7D",
|
|
582
620
|
danger: true,
|
|
583
621
|
action: async () => {
|
|
584
622
|
await api("/uninstall", { method: "POST", body: { packageName } });
|
|
623
|
+
setLocalDetail(null);
|
|
585
624
|
setNotice(`\u5DF2\u5378\u8F7D ${packageName}`);
|
|
586
625
|
await load(scope, category, query);
|
|
587
626
|
}
|
|
@@ -754,6 +793,14 @@ function Panel() {
|
|
|
754
793
|
setError(err.message);
|
|
755
794
|
}
|
|
756
795
|
}
|
|
796
|
+
async function openLocalDetail(packageName) {
|
|
797
|
+
setError("");
|
|
798
|
+
try {
|
|
799
|
+
setLocalDetail(await api(`/local-detail?package=${encodeURIComponent(packageName)}`));
|
|
800
|
+
} catch (err) {
|
|
801
|
+
setError(err.message);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
757
804
|
async function afterUpload(packageName) {
|
|
758
805
|
setView("list");
|
|
759
806
|
await load(scope, category, query);
|
|
@@ -786,6 +833,27 @@ function Panel() {
|
|
|
786
833
|
}
|
|
787
834
|
);
|
|
788
835
|
}
|
|
836
|
+
if (localDetail) {
|
|
837
|
+
const centerItem = items.find((plugin) => plugin.packageName === localDetail.bundle.name);
|
|
838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
839
|
+
notice ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-toast", children: notice }) : null,
|
|
840
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-toast pcx-toast-error", children: error }) : null,
|
|
841
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
842
|
+
LocalDetailView,
|
|
843
|
+
{
|
|
844
|
+
data: localDetail,
|
|
845
|
+
onBack: () => setLocalDetail(null),
|
|
846
|
+
onOpenCenter: centerItem ? () => {
|
|
847
|
+
const name = localDetail.bundle.name;
|
|
848
|
+
setLocalDetail(null);
|
|
849
|
+
void openDetail(name);
|
|
850
|
+
} : void 0,
|
|
851
|
+
onUninstall: () => uninstallLocal(localDetail.bundle.name)
|
|
852
|
+
}
|
|
853
|
+
),
|
|
854
|
+
dialog ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PromptDialog, { dialog, onClose: () => setDialog(null) }) : null
|
|
855
|
+
] });
|
|
856
|
+
}
|
|
789
857
|
if (detail) {
|
|
790
858
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
791
859
|
notice ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-toast", children: notice }) : null,
|
|
@@ -823,7 +891,7 @@ function Panel() {
|
|
|
823
891
|
onYank: (releaseId) => yankRelease(releaseId),
|
|
824
892
|
onUninstall: () => setDialog({
|
|
825
893
|
title: `\u5378\u8F7D\u300C${detail.displayName}\u300D\uFF1F`,
|
|
826
|
-
description: "\u53EA\u4ECE\u672C\u673A DSH \u79FB\u9664\uFF0C\u4E0D\u5F71\u54CD\u63D2\u4EF6\u4E2D\u5FC3\u91CC\u7684\u7248\u672C\u3002",
|
|
894
|
+
description: "\u53EA\u4ECE\u672C\u673A DSH \u79FB\u9664\uFF0C\u4E0D\u5F71\u54CD\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u91CC\u7684\u7248\u672C\u3002",
|
|
827
895
|
input: false,
|
|
828
896
|
confirmLabel: "\u5378\u8F7D",
|
|
829
897
|
danger: true,
|
|
@@ -856,13 +924,13 @@ function Panel() {
|
|
|
856
924
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-logo", children: "P" }),
|
|
857
925
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
858
926
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h1", { className: "pcx-title", children: [
|
|
859
|
-
"\u63D2\u4EF6\u4E2D\u5FC3",
|
|
927
|
+
"\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3",
|
|
860
928
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
861
929
|
"button",
|
|
862
930
|
{
|
|
863
931
|
type: "button",
|
|
864
932
|
className: "pcx-version-tag pcx-version-tag-btn",
|
|
865
|
-
title: state?.self?.updatable ? "\u70B9\u51FB\u68C0\u67E5\u63D2\u4EF6\u4E2D\u5FC3\u66F4\u65B0" : "\u63D2\u4EF6\u4E2D\u5FC3\u7248\u672C",
|
|
933
|
+
title: state?.self?.updatable ? "\u70B9\u51FB\u68C0\u67E5\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u66F4\u65B0" : "\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u7248\u672C",
|
|
866
934
|
onClick: () => void checkSelfUpdate(true),
|
|
867
935
|
children: [
|
|
868
936
|
"v",
|
|
@@ -919,14 +987,14 @@ function Panel() {
|
|
|
919
987
|
error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-toast pcx-toast-error", children: error }) : null,
|
|
920
988
|
installProgress ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InstallProgressCard, { progress: installProgress }) : null,
|
|
921
989
|
selfUpdate.phase === "running" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-overlay", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-dialog", role: "dialog", "aria-modal": "true", children: [
|
|
922
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "pcx-dialog-title", children: "\u6B63\u5728\u66F4\u65B0\u63D2\u4EF6\u4E2D\u5FC3" }),
|
|
990
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "pcx-dialog-title", children: "\u6B63\u5728\u66F4\u65B0\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3" }),
|
|
923
991
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "pcx-sub", children: [
|
|
924
992
|
"\u6B63\u5728\u5B89\u88C5 v",
|
|
925
993
|
selfUpdate.to,
|
|
926
994
|
"\uFF0C\u9762\u677F\u4F1A\u77ED\u6682\u65AD\u5F00\uFF0C\u5B8C\u6210\u540E\u81EA\u52A8\u5237\u65B0\u3002"
|
|
927
995
|
] }),
|
|
928
996
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-progress-track pcx-progress-indeterminate", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-progress-fill" }) }),
|
|
929
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-sub", children: "\u5982\u679C\u957F\u65F6\u95F4\u6CA1\u6709\u53CD\u5E94\uFF0C\u8BF7\u5230 DSH \u7684 Plugins \u9875\u9762\u786E\u8BA4\u63D2\u4EF6\u4E2D\u5FC3\u7248\u672C\u3002" })
|
|
997
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-sub", children: "\u5982\u679C\u957F\u65F6\u95F4\u6CA1\u6709\u53CD\u5E94\uFF0C\u8BF7\u5230 DSH \u7684 Plugins \u9875\u9762\u786E\u8BA4\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u7248\u672C\u3002" })
|
|
930
998
|
] }) }) : null,
|
|
931
999
|
selfUpdate.phase === "done" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-overlay", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-dialog", role: "dialog", "aria-modal": "true", children: [
|
|
932
1000
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", { className: "pcx-dialog-title", children: [
|
|
@@ -943,7 +1011,7 @@ function Panel() {
|
|
|
943
1011
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-sub", children: "\u5F53\u524D profile \u6CA1\u6709\u70ED\u91CD\u8F7D\uFF0C\u91CD\u542F DSH \u540E\u65B0\u7248\u672C\u624D\u4F1A\u751F\u6548\u3002" }),
|
|
944
1012
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-dialog-actions", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "pcx-btn pcx-btn-primary", onClick: () => setSelfUpdate({ phase: "idle" }), children: "\u77E5\u9053\u4E86" }) })
|
|
945
1013
|
] }) }) : null,
|
|
946
|
-
!ready ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-auth-page", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-auth-column", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-empty", children: "\u6B63\u5728\u8FDE\u63A5\u63D2\u4EF6\u4E2D\u5FC3\u2026" }) }) }) : !signedIn ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-auth-page", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-auth-column", children: [
|
|
1014
|
+
!ready ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-auth-page", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-auth-column", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-empty", children: "\u6B63\u5728\u8FDE\u63A5\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u2026" }) }) }) : !signedIn ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-auth-page", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-auth-column", children: [
|
|
947
1015
|
notice ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-alert pcx-alert-success", children: notice }) : null,
|
|
948
1016
|
error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-alert pcx-alert-error", children: error }) : null,
|
|
949
1017
|
authView === "reset" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -959,7 +1027,7 @@ function Panel() {
|
|
|
959
1027
|
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
960
1028
|
AuthBox,
|
|
961
1029
|
{
|
|
962
|
-
title: "\u767B\u5F55\u63D2\u4EF6\u4E2D\u5FC3",
|
|
1030
|
+
title: "\u767B\u5F55\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3",
|
|
963
1031
|
description: "\u767B\u5F55\u540E\u5373\u53EF\u6D4F\u89C8\u3001\u5B89\u88C5\u548C\u4E0A\u4F20\u63D2\u4EF6\u3002",
|
|
964
1032
|
onDone: () => load(scope, category, query),
|
|
965
1033
|
onForgot: () => setAuthView("reset")
|
|
@@ -1070,7 +1138,10 @@ function Panel() {
|
|
|
1070
1138
|
bundles: state?.installed ?? [],
|
|
1071
1139
|
centerItems: items,
|
|
1072
1140
|
query,
|
|
1073
|
-
onOpen: (name) =>
|
|
1141
|
+
onOpen: (name) => {
|
|
1142
|
+
if (items.some((plugin) => plugin.packageName === name)) void openDetail(name);
|
|
1143
|
+
else void openLocalDetail(name);
|
|
1144
|
+
},
|
|
1074
1145
|
onUninstall: uninstallLocal
|
|
1075
1146
|
}
|
|
1076
1147
|
) : 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: [
|
|
@@ -1206,7 +1277,7 @@ function UploadView({
|
|
|
1206
1277
|
AuthBox,
|
|
1207
1278
|
{
|
|
1208
1279
|
title: "\u767B\u5F55\u540E\u4E0A\u4F20\u63D2\u4EF6",
|
|
1209
|
-
description: "\u4E0A\u4F20\u9700\u8981\u63D2\u4EF6\u4E2D\u5FC3\u8D26\u53F7\uFF1B\u767B\u5F55\u6210\u529F\u540E\u4F1A\u81EA\u52A8\u8FDB\u5165\u4E0A\u4F20\u8868\u5355\u3002",
|
|
1280
|
+
description: "\u4E0A\u4F20\u9700\u8981\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\u8D26\u53F7\uFF1B\u767B\u5F55\u6210\u529F\u540E\u4F1A\u81EA\u52A8\u8FDB\u5165\u4E0A\u4F20\u8868\u5355\u3002",
|
|
1210
1281
|
onDone: onLogin
|
|
1211
1282
|
}
|
|
1212
1283
|
) }) })
|
|
@@ -2472,7 +2543,7 @@ function BindOps({ onDone, onCancel }) {
|
|
|
2472
2543
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-auth", children: [
|
|
2473
2544
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-auth-head", children: [
|
|
2474
2545
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "pcx-auth-title", children: "\u7ED1\u5B9A\u8FD0\u8425\u52A9\u624B\u8D26\u53F7" }),
|
|
2475
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-sub", children: "\u7ED1\u5B9A\u540E\u53EF\u4EE5\u7528\u8FD0\u8425\u52A9\u624B\u8D26\u53F7\u767B\u5F55\u63D2\u4EF6\u4E2D\u5FC3\uFF1B\u9700\u8981\u8BE5\u624B\u673A\u53F7\u5728\u8FD0\u8425\u52A9\u624B\u91CC\u5DF2\u6CE8\u518C\u3002" })
|
|
2546
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-sub", children: "\u7ED1\u5B9A\u540E\u53EF\u4EE5\u7528\u8FD0\u8425\u52A9\u624B\u8D26\u53F7\u767B\u5F55\u5C0F\u8DA3\u63D2\u4EF6\u4E2D\u5FC3\uFF1B\u9700\u8981\u8BE5\u624B\u673A\u53F7\u5728\u8FD0\u8425\u52A9\u624B\u91CC\u5DF2\u6CE8\u518C\u3002" })
|
|
2476
2547
|
] }),
|
|
2477
2548
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "pcx-auth-form pcx-auth-form-bind", onSubmit: submit, children: [
|
|
2478
2549
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-field", children: [
|
package/lib/index.js
CHANGED
|
@@ -143,7 +143,7 @@ function selfUpdateBlockedInfo(own) {
|
|
|
143
143
|
if (local) {
|
|
144
144
|
return {
|
|
145
145
|
reason: 'local',
|
|
146
|
-
hint:
|
|
146
|
+
hint: `当前小趣插件中心是按本地包安装的(${source ?? 'file:'}),DSH 无法原地升级。执行一次迁移后即可自动更新:${reinstall},然后重启 DSH。`,
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -256,7 +256,7 @@ async function centerFetch(config, path, init = {}) {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
if (!response.ok) {
|
|
259
|
-
const error = new Error(data.error ??
|
|
259
|
+
const error = new Error(data.error ?? `小趣插件中心返回 ${response.status}`)
|
|
260
260
|
error.status = response.status
|
|
261
261
|
throw error
|
|
262
262
|
}
|
|
@@ -825,7 +825,7 @@ export function apply(ctx) {
|
|
|
825
825
|
const version = url.searchParams.get('version')
|
|
826
826
|
const contentType = req.headers['content-type'] ?? ''
|
|
827
827
|
|
|
828
|
-
//
|
|
828
|
+
// 面板直传:文件不经过小趣插件中心,先换预签名地址,再由本机 PUT 到 OSS。
|
|
829
829
|
if (version && !contentType.includes('multipart')) {
|
|
830
830
|
let presign
|
|
831
831
|
try {
|
|
@@ -919,6 +919,44 @@ export function apply(ctx) {
|
|
|
919
919
|
return send(res, 200, detail)
|
|
920
920
|
}
|
|
921
921
|
|
|
922
|
+
// 本机已装插件的详情:即使没在中心上架,也能读到 README / locale 详情。
|
|
923
|
+
if (req.method === 'GET' && path === '/local-detail') {
|
|
924
|
+
const packageName = url.searchParams.get('package') ?? ''
|
|
925
|
+
if (!packageName) return send(res, 400, { error: '缺少 package 参数' })
|
|
926
|
+
const manager = ctx.get('pluginManager')
|
|
927
|
+
if (!manager) return send(res, 503, { error: 'DSH 插件管理器不可用' })
|
|
928
|
+
|
|
929
|
+
const bundle = (await manager.listBundles()).find((item) => item.name === packageName)
|
|
930
|
+
if (!bundle) return send(res, 404, { error: `本机没有安装 ${packageName}` })
|
|
931
|
+
|
|
932
|
+
const meta = bundle.meta && typeof bundle.meta === 'object' ? bundle.meta : {}
|
|
933
|
+
let detail = null
|
|
934
|
+
try {
|
|
935
|
+
if (typeof manager.readBundleDetail === 'function') {
|
|
936
|
+
detail = await manager.readBundleDetail(packageName, 'zh')
|
|
937
|
+
}
|
|
938
|
+
} catch {
|
|
939
|
+
detail = null
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
return send(res, 200, {
|
|
943
|
+
bundle: {
|
|
944
|
+
name: bundle.name,
|
|
945
|
+
displayName: typeof meta.name === 'string' ? meta.name : bundle.name,
|
|
946
|
+
summary: typeof meta.summary === 'string' ? meta.summary : (bundle.description ?? ''),
|
|
947
|
+
description: bundle.description ?? null,
|
|
948
|
+
version: bundle.version ?? null,
|
|
949
|
+
enabled: bundle.enabled,
|
|
950
|
+
official: Boolean(bundle.official),
|
|
951
|
+
availability: bundle.availability ?? null,
|
|
952
|
+
removable: Boolean(bundle.removable),
|
|
953
|
+
source: bundle.source ?? null,
|
|
954
|
+
error: bundle.error?.code ?? null,
|
|
955
|
+
},
|
|
956
|
+
detail,
|
|
957
|
+
})
|
|
958
|
+
}
|
|
959
|
+
|
|
922
960
|
if (req.method === 'GET' && path === '/install-progress') {
|
|
923
961
|
const packageName = url.searchParams.get('package') ?? ''
|
|
924
962
|
if (!packageName) return send(res, 400, { error: '缺少 package 参数' })
|
|
@@ -1090,9 +1128,9 @@ export function apply(ctx) {
|
|
|
1090
1128
|
const isNetwork = raw === 'fetch failed' || error.name === 'TypeError'
|
|
1091
1129
|
if (installTarget) failInstallProgress(installTarget)
|
|
1092
1130
|
const message = isNetwork
|
|
1093
|
-
?
|
|
1131
|
+
? `无法连接小趣插件中心(${config.baseUrl}),请确认服务已启动`
|
|
1094
1132
|
: error.name === 'AbortError' || raw.includes('timeout')
|
|
1095
|
-
? '
|
|
1133
|
+
? '连接小趣插件中心超时,请稍后重试'
|
|
1096
1134
|
: raw
|
|
1097
1135
|
return send(res, status, {
|
|
1098
1136
|
error: message,
|
package/package.json
CHANGED