-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
118 lines (99 loc) · 2.76 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
const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('path')
const os = require('os')
const local = os.homedir() + '/AppData/Local/ivafly'
const fs = require('fs')
//const friend = require('./logs-data/friend/addfriends')
/**
* Creation de données utile
*/
let profil = {
users: {
account: null,
},
preferencie: {
lang: 'en',
interface: 'white',
},
}
const newUsersProfil = JSON.stringify(profil, null, 2)
fs.mkdirSync(local, { recursive: true })
// fs.mkdirSync(local + '/friend')
// fs.mkdirSync(local + '/sav')
// fs.mkdirSync(local + '/data-atc')
// fs.mkdirSync(local + '/data-pilot')
if(!fs.existsSync(local + '/users.json')){
fs.writeFileSync(local + '/users.json', newUsersProfil)
}
fs.open(local + '/users.json', function (err) {
if (err) {
fs.writeFile(local + '/users.json', newUsersProfil, "utf8", function (err, data) {
if (err) {
console.log(err)
} else {
console.log(profil)
}
})
}
})
//friend.creatdatabase()
/**
* Logiciel
*/
let win = null
let Mainwindows = null
function createWindow(
loadFileTemplate,
withDefault = 1200,
heightDefault = 800,
iconDefault = path.join('./images/IVAO_Logo.png'),
titleDefault = 'IvaFly'
) {
win = new BrowserWindow({
width: withDefault,
height: heightDefault,
icon: iconDefault,
title: titleDefault,
webPreferences: {
nodeIntegration: true,
contextIsolation: false, //lancement dans les autres fenetre
plugins: true,
},
})
/**
* ouverture des codes sources en version devs
*/
win.loadFile(loadFileTemplate)
// Handle window closed
win.on('closed', () => {
win = null
})
return win
}
// Close App
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
app.whenReady().then(() => {
app.allowRendererProcessReuse = true
Mainwindows = createWindow('./src/home/home.html')
})
ipcMain.on('welcome', (EventTarget, arg) => {
const users = local + '/users.json'
if (users['account'] == null) {
Mainwindows = createWindow('./src/account/creataccount.html', 600, 480, null, 'Add account')
} else {
Mainwindows = createWindow('./src/account/account.html', 600, 480, null, 'my account')
}
})
ipcMain.on('discord', (EventTarget, arg) => {
const { discord } = require('./function/discord')
discord()
})
ipcMain.on('atchtml', (EventTarget, arg) => {
const { discord } = require('./function/discord')
discord()
})
ipcMain.on('friendbutton', (EventTarget, arg) => {
Mainwindows = createWindow('./src/friend/friend.html', 'Add friend')
})