mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 08:20:22 +08:00
feat: 设置页可卸载,AI 安装说明只跑官方 add
This commit is contained in:
1 parent
bea3877f4d
commit
fbd17e277e
13 files changed
+810
-124
No files matched your search
@@ -239,4 +239,38 @@ export function installHideConsoleIntoBin(aiBase, { fs, path: nodePath } = {}) {
|
||||
return "injected";
|
||||
}
|
||||
|
||||
export function revertHideConsoleFromBin(aiBase, { fs, path: nodePath } = {}) {
|
||||
const nodeFs = fs ?? requireFs();
|
||||
const p = nodePath ?? requirePath();
|
||||
const root = resolveDshBinRoot(aiBase, { fs: nodeFs, path: p });
|
||||
if (!root) return "missing_bin";
|
||||
const binJs = p.join(root, "lib", "bin.js");
|
||||
const side = p.join(root, "lib", `${IMPORT_MARK}.js`);
|
||||
const facadeSide = p.join(root, "lib", "dsh-purge-child-process-hide.mjs");
|
||||
let changed = false;
|
||||
if (nodeFs.existsSync(binJs)) {
|
||||
try {
|
||||
const text = nodeFs.readFileSync(binJs, "utf8");
|
||||
const next = text.replace(/^import "\.\/dsh-purge-hide-console\.js";.*\r?\n/gm, "");
|
||||
if (next !== text) {
|
||||
nodeFs.writeFileSync(binJs, next, "utf8");
|
||||
changed = true;
|
||||
}
|
||||
} catch (e) {
|
||||
return `error:${e}`;
|
||||
}
|
||||
}
|
||||
for (const fp of [side, facadeSide]) {
|
||||
try {
|
||||
if (nodeFs.existsSync(fp)) {
|
||||
nodeFs.unlinkSync(fp);
|
||||
changed = true;
|
||||
}
|
||||
} catch {
|
||||
// 重启后再删
|
||||
}
|
||||
}
|
||||
return changed ? "reverted" : "absent";
|
||||
}
|
||||
|
||||
installHideConsole();
|
||||
Reference in new issue
Block a user