mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 05:50:22 +08:00
feat: 发布 1.1.7,Web / 桌面端分开安装并跟随当前桌面目录清洗
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2529db6088
commit
e84671d20a
14 files changed
+1370
-345
No files matched your search
+3
-29
@@ -1,10 +1,8 @@
|
||||
import fs from "node:fs";
|
||||
import { promises as fsp } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { spawn } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import * as core from "./core.js";
|
||||
import * as hostctl from "./host.js";
|
||||
import * as rules from "./rules.js";
|
||||
import * as updater from "./update.js";
|
||||
|
||||
@@ -265,30 +263,6 @@ export async function uninstallPurge() {
|
||||
return report;
|
||||
}
|
||||
|
||||
export function scheduleCleanupRestart({ request, restartArgv, cleanup = [] } = {}) {
|
||||
const src = fileURLToPath(new URL("./uninstall-restart.js", import.meta.url));
|
||||
const dest = path.join(os.tmpdir(), `dsh-purge-uninst-${process.pid}.mjs`);
|
||||
fs.copyFileSync(src, dest);
|
||||
const hostHeader = String(request?.headers?.host || "127.0.0.1");
|
||||
const portMatch = hostHeader.match(/:(\d+)$/);
|
||||
const child = spawn(process.execPath, [dest], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
windowsHide: true,
|
||||
shell: false,
|
||||
env: {
|
||||
...core.envForDetachedSpawn(),
|
||||
DSH_PURGE_RESTART: JSON.stringify({
|
||||
execPath: process.execPath,
|
||||
argv: restartArgv || [process.argv[1], "--no-open"],
|
||||
cwd: process.cwd(),
|
||||
host: hostHeader.replace(/:\d+$/, "") || "127.0.0.1",
|
||||
port: portMatch ? Number(portMatch[1]) : 3080,
|
||||
cleanup,
|
||||
helper: dest,
|
||||
}),
|
||||
},
|
||||
});
|
||||
child.unref();
|
||||
setTimeout(() => process.exit(0), 400);
|
||||
export function scheduleCleanupRestart(opts = {}) {
|
||||
hostctl.scheduleCleanupRestart(opts);
|
||||
}
|
||||
Reference in new issue
Block a user