-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
87 lines (68 loc) · 1.95 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
const { app, BrowserWindow, systemPreferences, Menu } = require('electron')
const { join } = require('path')
let mainWindow = null
const dev = process.argv.indexOf('--dev') != -1
if (process.platform == 'linux') {
app.disableHardwareAcceleration()
app.commandLine.appendSwitch("disable-software-rasterizer")
}
async function initialize() {
makeSingleInstance()
async function createWindow() {
Menu.setApplicationMenu(new Menu())
const windowOptions = {
width: 1080,
minWidth: 680,
title: 'ChatRoulette',
height: 840,
icon: join(__dirname, '/icon.png'),
webPreferences: {
webSecurity: false,
preload: join(__dirname, 'dist/preload.js')
}
}
mainWindow = new BrowserWindow(windowOptions)
mainWindow.loadURL('https://videochatru.com/embed/')
if (dev)
mainWindow.webContents.openDevTools()
try {
if (process.platform == 'darwin' || process.platform == 'win32') {
const m = systemPreferences.getMediaAccessStatus('microphone')
const c = systemPreferences.getMediaAccessStatus('camera')
if(m == 'not-determined')
await systemPreferences.askForMediaAccess('microphone')
.catch(console.log)
if(c == 'not-determined')
await systemPreferences.askForMediaAccess('camera')
.catch(console.log)
}
}catch(e) {
console.log(e)
}
mainWindow.on('closed', () => {
mainWindow = null
})
}
app.on('ready', () => {
createWindow()
})
app.on('window-all-closed', () => {
app.quit()
})
app.on('activate', () => {
if (mainWindow === null) {
createWindow()
}
})
}
function makeSingleInstance() {
if (process.mas) return
app.requestSingleInstanceLock()
app.on('second-instance', () => {
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore()
mainWindow.focus()
}
})
}
initialize().catch(console.log)