mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: 修复重启 但win无法及时结束父进程
This commit is contained in:
parent
f74a83bc46
commit
db63675b8e
@ -1,32 +1,30 @@
|
||||
import { exit } from "process";
|
||||
import { resolve } from "path";
|
||||
import { promisify } from "node:util";
|
||||
import { writeFile, writeFileSync } from "fs";
|
||||
import { exec } from "node:child_process";
|
||||
let execAsync = promisify(exec);
|
||||
import { spawn } from "node:child_process";
|
||||
import { sleep } from "./helper";
|
||||
|
||||
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') {
|
||||
console.log(process.platform);
|
||||
let result = await execAsync(`timeout /t 5 /nobreak & ${batUtf8Script} -q ${uin}`);
|
||||
console.log(result);
|
||||
let subProcess = spawn(`start ${batUtf8Script} -q ${uin}`, { detached: true, windowsHide: false, env: process.env, shell: true, stdio: 'ignore'});
|
||||
subProcess.unref();
|
||||
} else if (process.platform === 'linux') {
|
||||
await execAsync(`timeout 5 & ${bashScript} -q ${uin}`);
|
||||
// 启动bash执行脚本
|
||||
let subProcess = spawn(`${bashScript} -q ${uin}`, { detached: true, windowsHide: false, env: process.env, shell: true, stdio: 'ignore' });
|
||||
subProcess.unref();
|
||||
}
|
||||
//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') {
|
||||
exec(`timeout /t 5 /nobreak & ${batUtf8Script}`);
|
||||
spawn(`start ${batUtf8Script}`, { detached: true, windowsHide: false, env: process.env, shell: true });
|
||||
} else if (process.platform === 'linux') {
|
||||
exec(`timeout 5 & ${bashScript}`);
|
||||
// 启动bash执行脚本
|
||||
spawn(`${bashScript}`, { detached: true, windowsHide: false, env: process.env, shell: true });
|
||||
}
|
||||
await sleep(500);
|
||||
exit(0);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user