-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
87 lines (67 loc) · 2.2 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* @file A program to organize your computer for ease of access.
*
* @name HomeBase
* @version 1.0.0
* @license Apache-2.0
*/
/**
* Application start functions.
*
* @name index
* @param {object} app A custom param for the electron module deconstuction.
* @return {null}
*/
(async ({ app } = require(`electron`)) => {
// Wait for the app to startup.
await app.whenReady()
// Get files.
// await this.fetch()
// Run other Node.JS files.
this.init()
app
/**
* Application activate event (Check if app is running, if not run `init` again).
*
* @name activate
* @return {null}
*/
.on(`activate`, _ => BrowserWindow.getAllWindows().length === 0 ? this.init() : null)
/**
* Application window close event.
*
* @name window-all-closed
* @return {null}
*/
.on(`window-all-closed`, _ => process.platform !== `darwin` ? app.quit() : null)
})()
/**
* Application init function.
*
* @name init
* @param {object} BrowserWindow A custom param for the electron module deconstuction.
* @return {null}
*/
module.exports.init = ({ BrowserWindow } = require(`electron`)) => {
// Init browser properties.
let window = new BrowserWindow({ width: 800, height: 600, icon: `icon.png` })
// Make app fullscreen.
window.maximize()
// Remove app menu.
// window.removeMenu()
// Load index HTML file.
window.loadFile(`./login.html`)
}
// This is protected code, see https://kura.gq?to=share for more information.
// module.exports.fetch = async _ => {
// let [fetch, fs] = [require(`node-fetch`), require(`fs`)],
// request = await fetch(`https://storage.home-base.gq/path.json`),
// requestDIR = await fetch(`https://storage.home-base.gq/dir.json`),
// result = await request.json(),
// resultDIR = await requestDIR.json()
// for (let dir of resultDIR) fs.access(`./${dir}`, error => { if (error) fs.mkdir(dir, err => { if (err) console.log('Error writing file', err) }) })
// for await (let file of result) {
// let req = await fetch(`https://storage.home-base.gq/${file}`), body = await req.text()
// fs.writeFile(`./${file}`, body, err => { if (err) console.log('Error writing file', err) })
// }
// }