-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
78 lines (68 loc) · 2.03 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
const { app, BrowserWindow } = require("electron");
const { checkAccess } = require("./prompt-linux-access.js");
const IS_LINUX = require("os").platform() === "linux";
const isDev = require('electron-is-dev');
const { autoUpdater } = require("electron-updater")
const createWindow = () => {
const mainWindow = new BrowserWindow({
width: 1600,
height: 900,
autoHideMenuBar: true,
icon: 'icon.ico',
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
sandbox: true,
},
title: require('./package.json').name + ' ' + require('./package.json').version
});
mainWindow.on('page-title-updated', (event) => {
event.preventDefault();
});
mainWindow.webContents.session.on(
"select-hid-device",
(event, details, callback) => {
event.preventDefault();
if (details.deviceList && details.deviceList.length > 0) {
callback(details.deviceList[0].deviceId);
}
}
);
mainWindow.webContents.session.setDevicePermissionHandler((details) => {
if (details.deviceType === "hid") {
return true;
}
return false;
});
// Auto Updater
mainWindow.once('ready-to-show', () => {
if (isDev) {
console.log('Running in development');
} else {
console.log('SnailDOS Powered')
console.log('App Version:')
console.log(app.getVersion())
console.log('Running in production');
console.log('Setting parameters...')
autoUpdater.logger = require("electron-log")
autoUpdater.logger.transports.file.level = "info"
console.log('Sending update task now.')
autoUpdater.checkForUpdatesAndNotify();
console.log('App is ready.')
}
});
mainWindow.loadURL("https://main--cheery-tanuki-99ac8d.netlify.app/");
};
// Linux
app.whenReady().then(async () => {
if (IS_LINUX) {
await checkAccess(app);
}
createWindow();
app.on("activate", function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on("window-all-closed", function () {
if (process.platform !== "darwin") app.quit();
});