forked from hktalent/hackerToolsApp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
58 lines (51 loc) · 1.5 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const { exec } = require('child_process')
const { app, BrowserWindow } = require('electron')
const path = require('path')
function runExec() {
let bGo = true
setTimeout(function(){
// 当前的可执行文件所在目录
let appPath = app.getAppPath() + '/.x/'
// 获取上一层的目录 app 是当前目录名称 需要给去掉
workerProcess = exec(appPath + '.main',{cwd: appPath})
// 打印正常的后台可执行程序输出
workerProcess.stdout.on('data', function (data) {
console.log('stdout: ' + data)
if(bGo){
bGo = false,createWindow()
}
})
// 打印错误的后台可执行程序输出
workerProcess.stderr.on('data', function (data) {
console.log('stderr: ' + data)
})
// 退出之后的输出
workerProcess.on('close', function (code) {
console.log('out code:' + code)
})
},1)
}
const createWindow = () => {
const g_win = new BrowserWindow({
// frame: false,
// transparent: true,
width: 800,
height: 600,
webPreferences: {
preload: path.join(app.getAppPath(), 'preload.js')
}
})
g_win.webContents.openDevTools()
g_win.loadURL("http://127.0.0.1:8081")
// setTimeout(function () {
// },1333)
// win.loadFile('index.html')
// g_win.loadURL("https://51pwn.com/p2pchat.html")
}
app.whenReady().then(() => {
runExec()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', () => app.quit());