-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.js
99 lines (87 loc) · 3.13 KB
/
dev.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
// Import required modules
const { app, BrowserWindow } = require("electron");
const path = require("path");
const fs = require("fs");
const os = require("os");
// Disable hardware acceleration
app.disableHardwareAcceleration();
// Function to create a new window
function createWindow() {
// Create a new window with the following configurations
const window = new BrowserWindow({
width: 1440,
height: 900,
autoHideMenuBar: true,
outline: "none",
webPreferences: {
enableRemoteModule: true,
},
title: "PDT and Awards Tracker",
icon: ".\\src\\public\\icon.ico",
});
// Maximize window
window.maximize();
// Loads the URL of the app
window.loadURL("http://localhost:3000");
}
// Calculate user's tracker directory
const userHomeDirectory = os.homedir();
const trackerDirectory = path.join(userHomeDirectory, ".tracker");
// Create directory if it doesn't exist
if (!fs.existsSync(trackerDirectory)) fs.mkdirSync(trackerDirectory);
// Define the path for the data.json file and cfg.json
const dataFilePath = path.join(trackerDirectory, "data.json");
const cfgFilePath = path.join(trackerDirectory, "cfg.json");
// Check if the JSON file exists, if not, create it with empty JSON object
if (!fs.existsSync(dataFilePath))
fs.writeFileSync(dataFilePath, JSON.stringify({}), "utf8");
if (!fs.existsSync(cfgFilePath))
fs.writeFileSync(
cfgFilePath,
JSON.stringify({ datapath: dataFilePath }),
"utf8"
);
// When Electron has finished initialization and is ready
// to create browser windows, call the createWindow function
app.on("ready", createWindow);
// Quit the application when all windows are closed
// (except on macOS)
app.on("window-all-closed", function () {
// Kill all associated processes
if (process.platform !== "darwin") {
app.quit();
}
});
// When the application gets activated, create a window if
// there isn't one already
app.on("activate", function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
// /\
// | |
// | |
// .' '.
// | |
// | |
// | /\ |
// .' |__|'.
// | | | |
// .' | | '.
// /\ | \__/ | /\
// | | | | | | | |
// /| | |,-\ | | /-,| | |\
// || |,-' | | | | '-,| ||
// ||-' | | | | '-||
// |\ _,-' | | | | '-,_ /|
// || ,-' _ | | | | '-, ||
// ||-' =(*)= | | | | '-||
// || | \ / | ||
// |\________....--------\ || /--------....________/|
// /| || |\
// / | || | \
// / | \/ | \
// / | | \
// // .| |. \\
// .' |_./ | | \._| '.
// / _.-||| |||-._ \
// \__.-' \||/\||/ '-.__/