-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
127 lines (108 loc) · 2.71 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
const { app, BrowserWindow, Menu, ipcMain ,dialog } = require('electron');
const path = require('path')
const { exec } = require('child_process');
const isMac = process.platform === 'darwin';
const stat = require('./scan_antiVirus.js');
let startWindow;
let reportWindow;
function createStartWindow() {
startWindow = new BrowserWindow({
title: 'Log in Page',
width: 1000,
height: 800,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true, // Add this line
nodeIntegration: true
},
});
startWindow.loadFile(path.join(__dirname, './renderer/home/index.html'));
}
function createReportWindow() {
reportWindow = new BrowserWindow({
title: 'Report Page',
width: 1000,
height: 800,
webPreferences:{
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true, // Add this line
nodeIntegration:true,
}
});
reportWindow.loadFile(path.join(__dirname, './renderer/result/report.html'));
}
app.whenReady().then(() => {
createStartWindow();
const mainMenu = Menu.buildFromTemplate(menu);
Menu.setApplicationMenu(mainMenu);
ipcMain.handle('dialog', async () => {
const { canceled, filePaths } = await dialog.showOpenDialog(startWindow, {
properties: ['openDirectory']
})
if (canceled) {
return
} else {
return filePaths[0]
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createStartWindow();
}
});
});
ipcMain.on('open report', (event,data) => {
let {path,type} = data
createReportWindow();
reportWindow.once('ready-to-show', () => {
let statobj = stat(path,reportWindow)
reportWindow.webContents.send('statistics',statobj)
})
});
const menu = [
{
role: 'quit',
label:'quit',
click: () => {
app.quit();
},
accelerator: 'CmdOrCtrl+q',
},
{
label: 'exit',
click: () => {
reportWindow?.close();
},
accelerator: 'CmdOrCtrl+e',
},
];
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
// Open aLoginwindo if none are open (macOS)
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createStartWindow();
});
process.on('uncaughtException', function (err) {
console.log(err);
})
function Delete_ALL(filesPaths) {
for (let filepath of filesPaths) {
Delete_FILE(filepath)
}
}
function Delete_FILE(path) {//delet onee file custom choice
exec(`del "${path}"`, (error, stdout, stderr) => {
if (error) {
return;
}
});
}
ipcMain.on('delete', (event,data) => {
Delete_FILE(data.path)
})
ipcMain.on('deleteall', (event,data) => {
Delete_ALL(data.paths)
})