feat: 设置页检测 GitHub master 更新,版本号从 1.0.0 起

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-09-17 18:01:29 +08:00
1 parent b4701de4a0
commit 3f1ef4d69f
6 files changed
+312 -15

No files matched your search

+26
View File
@@ -5,6 +5,7 @@ import { spawn } from "node:child_process";
import { fileURLToPath } from "node:url";
import * as core from "./core.js";
import * as rules from "./rules.js";
import * as updater from "./update.js";
import {
GLOBAL_PROMPT_ORDER,
rewritePromptAssembly,
@@ -684,6 +685,7 @@ function installWebServer(ctx, cfg) {
override_status: state.override_status,
override_path: state.override_path,
dsh_home: state.dsh_home,
plugin_version: updater.localVersion(),
});
} catch (e) {
sendJson(response, 500, { ok: false, error: String(e) });
@@ -818,6 +820,30 @@ function installWebServer(ctx, cfg) {
}
},
}, "dsh-purge: restart");
host.webServer.register({
kind: "exact",
path: "/dsh-purge/update",
handler: async (request, response) => {
if (request.method === "GET") {
try {
sendJson(response, 200, await updater.checkUpdate());
} catch (e) {
sendJson(response, 500, { ok: false, error: String(e) });
}
return;
}
if (request.method === "POST") {
try {
sendJson(response, 200, await updater.applyUpdate());
} catch (e) {
sendJson(response, 500, { ok: false, error: String(e) });
}
return;
}
response.writeHead(405, { allow: "GET, POST" });
response.end();
},
}, "dsh-purge: update");
}, "dsh-purge: http routes");
});
}