-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.js
37 lines (34 loc) · 1.04 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
const electron = require('electron');
const touch = require('touch');
const app = electron.app;
const FileSync = require('lowdb/adapters/FileSync');
touch.sync(`${app.getPath('userData')}/db.json`);
const db = require('lowdb')(new FileSync(`${app.getPath('userData')}/db.json`));
let win;
db.defaults({ config: { width: 802, height: 602, level: 20 } }).write();
app.on('ready', () => {
win = new electron.BrowserWindow({
autoHideMenuBar: true,
backgroundColor: '#1f1f1f',
center: true,
icon: `${__dirname}/assets/snake256.png`,
resizable: false,
title: 'Snake',
useContentSize: true,
width:
process.platform === 'win32'
? db.get('config').value().width + 10
: db.get('config').value().width,
height:
process.platform === 'win32'
? db.get('config').value().height + 34
: db.get('config').value().height
});
win.db = db;
win.loadURL(`file://${__dirname}/src/menu.html`);
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});