mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
fix: 修复linux打包后无法拉起wechat的bug
This commit is contained in:
@@ -4,6 +4,7 @@ import { existsSync, readdirSync, statSync, readFileSync } from 'fs'
|
|||||||
import { execFile, exec } from 'child_process'
|
import { execFile, exec } from 'child_process'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
import { createRequire } from 'module';
|
import { createRequire } from 'module';
|
||||||
|
import { spawn } from 'child_process'
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
|
|
||||||
const execFileAsync = promisify(execFile)
|
const execFileAsync = promisify(execFile)
|
||||||
@@ -51,12 +52,37 @@ export class KeyServiceLinux {
|
|||||||
await new Promise(r => setTimeout(r, 1000))
|
await new Promise(r => setTimeout(r, 1000))
|
||||||
|
|
||||||
onStatus?.('正在尝试拉起微信...', 0)
|
onStatus?.('正在尝试拉起微信...', 0)
|
||||||
const startCmds = [
|
|
||||||
'nohup wechat >/dev/null 2>&1 &',
|
const cleanEnv = { ...process.env };
|
||||||
'nohup wechat-bin >/dev/null 2>&1 &',
|
delete cleanEnv.ELECTRON_RUN_AS_NODE;
|
||||||
'nohup xwechat >/dev/null 2>&1 &'
|
delete cleanEnv.ELECTRON_NO_ATTACH_CONSOLE;
|
||||||
|
delete cleanEnv.APPDIR;
|
||||||
|
delete cleanEnv.APPIMAGE;
|
||||||
|
|
||||||
|
const wechatBins = [
|
||||||
|
'wechat',
|
||||||
|
'wechat-bin',
|
||||||
|
'xwechat',
|
||||||
|
'/opt/wechat/wechat',
|
||||||
|
'/usr/bin/wechat',
|
||||||
|
'/opt/apps/com.tencent.wechat/files/wechat'
|
||||||
]
|
]
|
||||||
for (const cmd of startCmds) execAsync(cmd).catch(() => {})
|
|
||||||
|
for (const binName of wechatBins) {
|
||||||
|
try {
|
||||||
|
const child = spawn(binName, [], {
|
||||||
|
detached: true,
|
||||||
|
stdio: 'ignore',
|
||||||
|
env: cleanEnv
|
||||||
|
});
|
||||||
|
|
||||||
|
child.on('error', () => {});
|
||||||
|
|
||||||
|
child.unref();
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onStatus?.('等待微信进程出现...', 0)
|
onStatus?.('等待微信进程出现...', 0)
|
||||||
let pid = 0
|
let pid = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user