From 35dcb7b88b75e3c406472e4264bed9a6cd3164ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 12 May 2024 22:11:47 +0800 Subject: [PATCH] feat: reboot util --- src/common/utils/reboot.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/common/utils/reboot.ts b/src/common/utils/reboot.ts index e3e88780..5d55c122 100644 --- a/src/common/utils/reboot.ts +++ b/src/common/utils/reboot.ts @@ -1,28 +1,28 @@ import { exit } from "process"; import { resolve } from "path"; import { writeFile, writeFileSync } from "fs"; -async function rebootWithQuickLogin(uin: string) { +import { exec } from "node:child_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') { - writeFileSync(resolve(__dirname, './reboot-utf8.bat'), ` - @echo off - timeout /t 5 /nobreak - start /b /wait %~dp0\\napcat-utf8.bat -q ${uin} - `); - // 启动cmd执行脚本 - + exec(`timeout /t 5 /nobreak & ${batUtf8Script} -q ${uin}`); } else if (process.platform === 'linux') { - writeFileSync(resolve(__dirname, './reboot.sh'), ` - #!/bin/bash - timeout 5 - ./napcat-utf8.sh -q ${uin} - `); + exec(`timeout 5 & ${bashScript} -q ${uin}`); + // 启动bash执行脚本 + } + 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}`); + } else if (process.platform === 'linux') { + exec(`timeout 5 & ${bashScript}`); // 启动bash执行脚本 - - - } exit(0); } \ No newline at end of file