@ququ-jiaxk/dsh-plugin-center 0.1.36 → 0.1.37
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 +14 -1
- package/lib/index.js +42 -0
- package/package.json +1 -1
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.37" : "0.0.0";
|
|
34
34
|
var PANEL_ID = "plugin-center";
|
|
35
35
|
var inject = ["slots", "remote", "remote.pluginManager"];
|
|
36
36
|
var hostCtx = null;
|
|
@@ -298,6 +298,19 @@ function Panel() {
|
|
|
298
298
|
if (manual) setError("\u68C0\u67E5\u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
|
+
if (result.status === "unsupported") {
|
|
302
|
+
setSelfUpdate({ phase: "idle" });
|
|
303
|
+
if (manual) {
|
|
304
|
+
setDialog({
|
|
305
|
+
title: "\u5F53\u524D DSH \u7248\u672C\u4E0D\u652F\u6301\u81EA\u66F4\u65B0",
|
|
306
|
+
description: String(result.hint ?? ""),
|
|
307
|
+
input: false,
|
|
308
|
+
confirmLabel: "\u77E5\u9053\u4E86",
|
|
309
|
+
action: async () => void 0
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
301
314
|
if (result.status === "available" && result.latest) {
|
|
302
315
|
setSelfUpdate({ phase: "available", to: result.latest });
|
|
303
316
|
if (manual) setNotice(`\u53D1\u73B0\u65B0\u7248\u672C v${result.latest}`);
|
package/lib/index.js
CHANGED
|
@@ -170,6 +170,28 @@ async function findSelfBundle(manager) {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/** 自更新依赖 DSH 0.2.x 的 listVersions / updateBundle;旧版管理器没有这两个方法。 */
|
|
174
|
+
function selfUpdateCapability(manager) {
|
|
175
|
+
if (!manager) return { supported: false, reason: 'no-manager' }
|
|
176
|
+
if (typeof manager.listVersions !== 'function' || typeof manager.updateBundle !== 'function') {
|
|
177
|
+
return { supported: false, reason: 'dsh-version' }
|
|
178
|
+
}
|
|
179
|
+
return { supported: true }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function selfUpdateUnsupportedInfo(reason) {
|
|
183
|
+
if (reason === 'no-manager') {
|
|
184
|
+
return {
|
|
185
|
+
reason: 'no-manager',
|
|
186
|
+
hint: 'DSH 插件管理器不可用(当前不是 profile 模式),无法自更新。',
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
reason: 'dsh-version',
|
|
191
|
+
hint: '当前 DSH 版本不支持面板自更新(插件管理器缺少 listVersions / updateBundle)。请先把 DSH 升级到 0.2.2 或更高版本,再点标题旁的版本号检查。',
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
173
195
|
function loadConfig() {
|
|
174
196
|
try {
|
|
175
197
|
const parsed = JSON.parse(readFileSync(CONFIG_PATH, 'utf8'))
|
|
@@ -394,6 +416,7 @@ export function apply(ctx) {
|
|
|
394
416
|
installed,
|
|
395
417
|
self,
|
|
396
418
|
selfUpdate: readSelfUpdateRecord(),
|
|
419
|
+
selfUpdateSupported: selfUpdateCapability(manager).supported,
|
|
397
420
|
})
|
|
398
421
|
}
|
|
399
422
|
|
|
@@ -401,6 +424,15 @@ export function apply(ctx) {
|
|
|
401
424
|
const manager = ctx.get('pluginManager')
|
|
402
425
|
if (!manager) return send(res, 503, { error: 'DSH 插件管理器不可用(当前不是 profile 模式)' })
|
|
403
426
|
|
|
427
|
+
const capability = selfUpdateCapability(manager)
|
|
428
|
+
if (!capability.supported) {
|
|
429
|
+
return send(res, 200, {
|
|
430
|
+
status: 'unsupported',
|
|
431
|
+
...selfUpdateUnsupportedInfo(capability.reason),
|
|
432
|
+
version: HOST_VERSION,
|
|
433
|
+
})
|
|
434
|
+
}
|
|
435
|
+
|
|
404
436
|
const own = await findSelfBundle(manager)
|
|
405
437
|
const installedVersion = own?.version ?? HOST_VERSION
|
|
406
438
|
if (!own?.updatable) {
|
|
@@ -475,6 +507,16 @@ export function apply(ctx) {
|
|
|
475
507
|
const manager = ctx.get('pluginManager')
|
|
476
508
|
if (!manager) return send(res, 503, { error: 'DSH 插件管理器不可用(当前不是 profile 模式)' })
|
|
477
509
|
|
|
510
|
+
const capability = selfUpdateCapability(manager)
|
|
511
|
+
if (!capability.supported) {
|
|
512
|
+
const unsupported = selfUpdateUnsupportedInfo(capability.reason)
|
|
513
|
+
return send(res, 409, {
|
|
514
|
+
error: unsupported.hint,
|
|
515
|
+
code: 'unsupported',
|
|
516
|
+
reason: unsupported.reason,
|
|
517
|
+
})
|
|
518
|
+
}
|
|
519
|
+
|
|
478
520
|
const own = await findSelfBundle(manager)
|
|
479
521
|
if (!own?.updatable) {
|
|
480
522
|
const blocked = selfUpdateBlockedInfo(own)
|