-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
66 lines (52 loc) · 1.54 KB
/
index.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
/*
'use strict';
const { app, BrowserWindow, dialog, ipcMain } = require('electron')
const firstStartupController = require("./controllers/first_startup")
const playerController = require("./controllers/player")
const fs = require('fs');
const path = require('path');
const os = require('os');
const Sequelize = require("sequelize");
const libraryPath = path.join(os.homedir(), "Music/WhisperBook/")
if (!fs.existsSync(libraryPath)) fs.mkdirSync(libraryPath);
const sequelize = new Sequelize({
dialect: 'sqlite',
storage: path.join(libraryPath,'WhisperBook.sqlite')
});
sequelize.authenticate()
.then(() => { console.log('Connection successfully made.'); })
.catch(console.error);
const db = {
models: {
Library: require(path.join(__dirname, "./db_models/Library.js"))(sequelize, Sequelize.DataTypes),
Book: require(path.join(__dirname, "./db_models/Book.js"))(sequelize, Sequelize.DataTypes)
},
sequelize: sequelize
}
function create_first_load_window() {
const main_window = new BrowserWindow({
width: 1600,
height: 600,
webPreferences: {
nodeIntegration: true,
}
});
main_window.webContents.openDevTools();
main_window.loadFile('views/player.html');
return main_window
}
app.on('ready', function () {
const win = create_first_load_window()
//firstStartupController.controller(win, db)
playerController.controller(win, db)
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})
/*
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
create_first_load_window()
}
})
*/