-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
160 lines (142 loc) · 3.37 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
const { ipcRenderer } = require('electron');
const electron = require('electron')
const { app, BrowserWindow, ipcMain, session } = electron
const path = require('path');
const { billingsButton } = require('./src/Controllers/DashboardController');
// const sqlite3 = require('sqlite3');
// const db = new sqlite3.Database('./src/database/db.sqlite');
let win;
let usersWin;
let billingsWin;
let carsWin;
let companiesWin;
let partsWin;
let customersWin;
function createWindow(){
win = new BrowserWindow({
width: 1200,
height: 900,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
})
win.loadFile('src/index.html')
return win
}
app.whenReady().then(() => {
win = createWindow()
app.on('activate', () => {
createWindow()
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
// win = new BrowserWindow({
// width: 1200,
// height: 900,
// webPreferences: {
// nodeIntegration: true,
// contextIsolation: false
// }
// })
// win.loadFile('src/index.html')
}
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
ipcMain.on('login', (event, data) => {
console.log(data)
if (data) {
event.sender.send('user-login', 'User Logged In');
}
// sessionStorage.setItem('email', data?.email)
// sessionStorage.setItem('name', data?.name)
// const auth = session.fromPartition('presist:login')
// auth.set('email', 'data.email')
// auth.set('name', 'data.name')
})
ipcMain.on('usersButton', (event, data) => {
usersWin = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
parent: win,
modal: true,
})
usersWin.loadFile('src/views/users.html')
})
ipcMain.on('carsButton', (event, data) => {
carsWin = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
parent: win,
modal: true,
})
carsWin.loadFile('src/views/cars.html')
})
ipcMain.on('companiesButton', (event, data) => {
companiesWin = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
parent: win,
modal: true,
})
companiesWin.loadFile('src/views/companies.html')
})
ipcMain.on('customersButton', (event, data) => {
customersWin = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
parent: win,
modal: true,
})
customersWin.loadFile('src/views/customers.html')
customersWin.webContents.openDevTools()
})
ipcMain.on('partsButton', (event, data) => {
partsWin = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
parent:win,
modal:true,
})
partsWin.loadFile('src/views/parts.html')
})
ipcMain.on('billingsButton', (event, data) => {
billingsWin = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
},
parent:win,
modal:true,
})
billingsWin.on('blur', ()=>{
console.log('error');
})
billingsWin.loadFile('src/views/billings.html')
})