|
@@ -1,9 +1,11 @@
|
|
|
const { app, BrowserWindow } = require('electron');
|
|
|
+const file = require('./helper/file');
|
|
|
const window = require('./helper/window');
|
|
|
const path = require('path');
|
|
|
const { execSync } = require('child_process');
|
|
|
const { program } = require('commander');
|
|
|
|
|
|
+app.allowRendererProcessReuse = true;
|
|
|
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
|
|
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
|
|
|
app.quit();
|
|
@@ -13,6 +15,7 @@ if (require('electron-squirrel-startup')) { // eslint-disable-line global-requir
|
|
|
|
|
|
// Global var
|
|
|
let mainWindow;
|
|
|
+let launchInfo;
|
|
|
let indexFile = 'src/index.html';
|
|
|
|
|
|
// Add version and option
|
|
@@ -28,8 +31,25 @@ const folder = program.src ? '/' : '/app/';
|
|
|
|
|
|
// Main function
|
|
|
async function main() {
|
|
|
- if (!program.src) {
|
|
|
- // Compile SCSS file from app
|
|
|
+ // Check if launch-info.json exist
|
|
|
+ console.log('Reading launch info');
|
|
|
+ if (file.exist(path.join(__dirname, '/data/launch-info.json'))) {
|
|
|
+ launchInfo = require('./data/launch-info');
|
|
|
+ // Reset data if change source between src and app
|
|
|
+ if (launchInfo.app === program.src) {
|
|
|
+ indexFile = 'src/reset.html';
|
|
|
+ }
|
|
|
+ // Update launch info
|
|
|
+ launchInfo.app = !program.src;
|
|
|
+ } else {
|
|
|
+ launchInfo = {
|
|
|
+ app: !program.src
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // Edit launch info file
|
|
|
+ file.put(path.join(__dirname, '/data/launch-info.json'), JSON.stringify(launchInfo));
|
|
|
+ // Compile SCSS file from app
|
|
|
+ if (!program.src) {
|
|
|
console.info('Compiling SCSS files in CSS');
|
|
|
let scssFile = path.join(__dirname, folder, 'src/css/style.scss');
|
|
|
let cssFile = path.join(__dirname, folder, 'src/css/style.min.css');
|
|
@@ -44,7 +64,7 @@ async function main() {
|
|
|
}
|
|
|
|
|
|
// Create main window function
|
|
|
-async function createMainWindow(simple = false) {
|
|
|
+function createMainWindow(simple = false) {
|
|
|
if (simple) {
|
|
|
mainWindow = window.simple(path.join(__dirname, folder, indexFile));
|
|
|
} else {
|