diff --git a/src/common/utils/reboot.ts b/src/common/utils/reboot.ts index 23f3af6f..f6db9dc0 100644 --- a/src/common/utils/reboot.ts +++ b/src/common/utils/reboot.ts @@ -1,30 +1,37 @@ -import { exit } from "process"; -import { resolve } from "path"; +import { resolve } from "node:path"; import { spawn } from "node:child_process"; -import { sleep } from "./helper"; - +import { pid, ppid, exit } from 'node:process'; export async function rebootWithQuickLogin(uin: string) { let batScript = resolve(__dirname, './napcat.bat'); let batUtf8Script = resolve(__dirname, './napcat-utf8.bat'); let bashScript = resolve(__dirname, './napcat.sh'); if (process.platform === 'win32') { - let subProcess = spawn(`start ${batUtf8Script} -q ${uin}`, { detached: true, windowsHide: false, env: process.env, shell: true, stdio: 'ignore'}); + const subProcess = spawn(`start ${batUtf8Script} -q ${uin}`, { detached: true, windowsHide: false, env: process.env, shell: true, stdio: 'ignore' }); subProcess.unref(); + // 子父进程一起送走 有点效果 + spawn('cmd /c taskkill /t /f /pid ' + pid.toString(), { detached: true, shell: true, stdio: 'ignore' }); + spawn('cmd /c taskkill /t /f /pid ' + ppid.toString(), { detached: true, shell: true, stdio: 'ignore' }); } else if (process.platform === 'linux') { - let subProcess = spawn(`${bashScript} -q ${uin}`, { detached: true, windowsHide: false, env: process.env, shell: true, stdio: 'ignore' }); + const subProcess = spawn(`${bashScript} -q ${uin}`, { detached: true, windowsHide: false, env: process.env, shell: true, stdio: 'ignore' }); + //还没兼容 subProcess.unref(); + exit(0); } - exit(0); + //exit(0); } export async function rebootWithNormolLogin() { let batScript = resolve(__dirname, './napcat.bat'); let batUtf8Script = resolve(__dirname, './napcat-utf8.bat'); let bashScript = resolve(__dirname, './napcat.sh'); if (process.platform === 'win32') { - spawn(`start ${batUtf8Script}`, { detached: true, windowsHide: false, env: process.env, shell: true }); + const subProcess = spawn(`start ${batUtf8Script} -q ${uin}`, { detached: true, windowsHide: false, env: process.env, shell: true, stdio: 'ignore' }); + subProcess.unref(); + // 子父进程一起送走 有点效果 + spawn('cmd /c taskkill /t /f /pid ' + pid.toString(), { detached: true, shell: true, stdio: 'ignore' }); + spawn('cmd /c taskkill /t /f /pid ' + ppid.toString(), { detached: true, shell: true, stdio: 'ignore' }); } else if (process.platform === 'linux') { - spawn(`${bashScript}`, { detached: true, windowsHide: false, env: process.env, shell: true }); + const subProcess = spawn(`${bashScript}`, { detached: true, windowsHide: false, env: process.env, shell: true }); + subProcess.unref(); + exit(0); } - await sleep(500); - exit(0); } \ No newline at end of file diff --git a/src/core b/src/core index ca47eb47..7575cec4 160000 --- a/src/core +++ b/src/core @@ -1 +1 @@ -Subproject commit ca47eb4754fb676827297a3c4b10b5746e3a0d95 +Subproject commit 7575cec4fe527796a72126097e6feb6139799e27