forked from mrmelon54/WhatsAppExportViewer-v0
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
74 lines (64 loc) · 1.86 KB
/
app.js
File metadata and controls
74 lines (64 loc) · 1.86 KB
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
const { app, BrowserWindow, Menu, ipcMain, dialog } = require('electron');
const { getMenuTemplate } = require('./menu');
const AsarFs = require('asar-fs');
const fs = require('fs');
const path = require('path');
var currentPackage;
if(path.basename(__dirname)=="app.asar") {
console.log("Package info hidden in app.asar");
let d = path.dirname(__dirname);
fs.readdirSync(d).forEach(file => {
console.log(file);
});
console.log(path.join(d,'app.asar'));
console.log(path.join(__dirname,'package.json'));
currentPackage = JSON.parse(fs.readFileSync(path.join(d,'app.asar','package.json'), 'utf8'));
console.log(currentPackage);
} else {
currentPackage = JSON.parse(fs.readFileSync(path.join(__dirname,'package.json'), 'utf8'));
}
const funcs = {
openAbout
};
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
icon: 'icon.png'
});
const menu = Menu.buildFromTemplate(getMenuTemplate(win, funcs));
Menu.setApplicationMenu(menu);
win.loadFile(`${__dirname}/babel/index.html`);
}
function openAbout() {
const options = {
type: 'info',
buttons: ['Ok'],
defaultId: 2,
title: currentPackage.productName,
message: currentPackage.productName,
detail: `
Version: ${currentPackage.version}
ID: ${currentPackage.appId}
Copyright: ${currentPackage.copyright}
Electron: ${process.versions.electron}
Chrome: ${process.versions.chrome}
NodeJS: ${process.versions.node}
V8: ${process.versions.v8}
`
};
dialog.showMessageBox(null, options, response => {
console.log(response);
});
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});