@ququ-jiaxk/dsh-plugin-center 0.1.47 → 0.1.49
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 +5 -4
- package/lib/index.js +19 -4
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -36,7 +36,7 @@ var logo_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" v
|
|
|
36
36
|
|
|
37
37
|
// src/client.tsx
|
|
38
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
-
var PLUGIN_VERSION = true ? "0.1.
|
|
39
|
+
var PLUGIN_VERSION = true ? "0.1.49" : "0.0.0";
|
|
40
40
|
var PANEL_ID = "plugin-center";
|
|
41
41
|
var inject = ["slots", "remote", "remote.pluginManager"];
|
|
42
42
|
var hostCtx = null;
|
|
@@ -406,7 +406,7 @@ function InstalledList({
|
|
|
406
406
|
const item = center.get(bundle.name);
|
|
407
407
|
const missing = bundle.availability === "missing";
|
|
408
408
|
const localInstall = !bundle.source || /(?:^|[^a-z0-9])(?:file|link):/iu.test(bundle.source);
|
|
409
|
-
const experimental = bundle.name.includes("experimental")
|
|
409
|
+
const experimental = bundle.name.includes("experimental");
|
|
410
410
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: "pcx-card", children: [
|
|
411
411
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
412
412
|
"div",
|
|
@@ -416,10 +416,10 @@ function InstalledList({
|
|
|
416
416
|
onClick: missing ? void 0 : () => onOpen(bundle.name),
|
|
417
417
|
children: [
|
|
418
418
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-top", children: [
|
|
419
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-icon", children: iconLetter(item?.displayName ?? bundle.name) }),
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-icon", children: iconLetter(bundle.title ?? item?.displayName ?? bundle.name) }),
|
|
420
420
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-titles", children: [
|
|
421
421
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-row", children: [
|
|
422
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-name", children: item?.displayName ?? bundle.name }),
|
|
422
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-name", children: bundle.title ?? item?.displayName ?? bundle.name }),
|
|
423
423
|
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" }),
|
|
424
424
|
bundle.availability === "installation" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u5185\u7F6E" }) : null,
|
|
425
425
|
experimental ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u5B9E\u9A8C\u6027" }) : null,
|
|
@@ -430,6 +430,7 @@ function InstalledList({
|
|
|
430
430
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-pkg", children: bundle.name })
|
|
431
431
|
] })
|
|
432
432
|
] }),
|
|
433
|
+
bundle.description || item?.summary ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "pcx-desc pcx-desc-block", children: bundle.description ?? item?.summary }) : null,
|
|
433
434
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-foot", children: [
|
|
434
435
|
/* @__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" }),
|
|
435
436
|
/* @__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" })
|
package/lib/index.js
CHANGED
|
@@ -161,6 +161,20 @@ function selfUpdateBlockedInfo(own) {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
/** DSH 的 meta.title / meta.description 可能是字符串,也可能是按语言索引的对象。 */
|
|
165
|
+
function localizedText(value) {
|
|
166
|
+
if (typeof value === 'string') return value || null
|
|
167
|
+
if (!value || typeof value !== 'object') return null
|
|
168
|
+
for (const key of ['zh', 'zh-cn', 'zh-hans', 'zh-hant', 'en']) {
|
|
169
|
+
const text = value[key]
|
|
170
|
+
if (typeof text === 'string' && text) return text
|
|
171
|
+
}
|
|
172
|
+
for (const text of Object.values(value)) {
|
|
173
|
+
if (typeof text === 'string' && text) return text
|
|
174
|
+
}
|
|
175
|
+
return null
|
|
176
|
+
}
|
|
177
|
+
|
|
164
178
|
async function findSelfBundle(manager) {
|
|
165
179
|
try {
|
|
166
180
|
const bundles = await manager.listBundles()
|
|
@@ -404,6 +418,7 @@ export function apply(ctx) {
|
|
|
404
418
|
// 单独给一份完整清单,供「本机」视图展示和启用。
|
|
405
419
|
bundles = list.map((bundle) => ({
|
|
406
420
|
name: bundle.name,
|
|
421
|
+
title: localizedText(bundle.meta?.title),
|
|
407
422
|
version: bundle.version ?? null,
|
|
408
423
|
enabled: bundle.enabled,
|
|
409
424
|
installed: Boolean(bundle.installed),
|
|
@@ -413,7 +428,7 @@ export function apply(ctx) {
|
|
|
413
428
|
removable: Boolean(bundle.removable),
|
|
414
429
|
source: bundle.source ?? null,
|
|
415
430
|
error: bundle.error?.code ?? null,
|
|
416
|
-
description: bundle.description ?? null,
|
|
431
|
+
description: localizedText(bundle.meta?.description) ?? bundle.description ?? null,
|
|
417
432
|
listedByDefault: bundle.listedByDefault !== false,
|
|
418
433
|
installTarget: bundle.installTarget ?? null,
|
|
419
434
|
}))
|
|
@@ -1011,10 +1026,10 @@ export function apply(ctx) {
|
|
|
1011
1026
|
return send(res, 200, {
|
|
1012
1027
|
bundle: {
|
|
1013
1028
|
name: bundle.name,
|
|
1014
|
-
displayName:
|
|
1015
|
-
summary:
|
|
1029
|
+
displayName: localizedText(meta.title) ?? bundle.name,
|
|
1030
|
+
summary: localizedText(meta.description) ?? bundle.description ?? '',
|
|
1016
1031
|
icon: typeof meta.icon === 'string' ? meta.icon : null,
|
|
1017
|
-
description: bundle.description ?? null,
|
|
1032
|
+
description: localizedText(meta.description) ?? bundle.description ?? null,
|
|
1018
1033
|
version: bundle.version ?? null,
|
|
1019
1034
|
enabled: bundle.enabled,
|
|
1020
1035
|
official: Boolean(bundle.official),
|