This repository has been archived by the owner on Mar 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
130 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
last 1 versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.DS_Store | ||
|
||
# custom ignore | ||
gui | ||
node_modules | ||
package-lock.json | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const path = require('path') | ||
|
||
module.exports = { | ||
dir: { | ||
app: __dirname, | ||
gui: path.join(__dirname, 'gui') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const path = require('path') | ||
const { BrowserWindow } = require('electron') | ||
const config = require('../config') | ||
|
||
const list = {} | ||
const defaults = { | ||
icon: path.join(config.dir.gui, 'icon.ico'), | ||
show: false, | ||
frame: false, | ||
webPreferences: { | ||
nodeIntegration: false, | ||
preload: path.join(config.dir.gui, 'script/ipc.js'), | ||
webSecurity: true | ||
} | ||
} | ||
|
||
module.exports = { exists, custom, open, load } | ||
|
||
function exists (window) { | ||
return list[window] instanceof BrowserWindow | ||
} | ||
|
||
function custom (name, options) { | ||
return new Promise((resolve, reject) => { | ||
if ( this.exists(name) === true ) | ||
return reject(`window ${name} already exists`) | ||
|
||
else { | ||
list[name] = new BrowserWindow(options) | ||
return resolve(list[name]) | ||
} | ||
}) | ||
} | ||
|
||
function open (name, extra = {}) { | ||
var options = extraOptions(defaults, extra) | ||
|
||
return new Promise((resolve, reject) => { | ||
this.custom(name, options) | ||
.then(handle) | ||
.catch(reject) | ||
|
||
function handle (window) { | ||
window.loadFile( path.join(config.dir.gui, `${name}.html`) ) | ||
window.once('ready-to-show', () => { | ||
window.show() | ||
resolve(window) | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
function load (window) { | ||
return new Promise((resolve, reject) => { | ||
if ( this.exists(window) === true ) | ||
return resolve(list[window]) | ||
|
||
else return reject(`window ${name} not exists`) | ||
}) | ||
} | ||
|
||
// Helper functions | ||
function extraOptions (...options) { | ||
var copy = {} | ||
|
||
options.forEach(obj => { | ||
Object.assign(copy, JSON.parse(JSON.stringify(obj))) | ||
}) | ||
|
||
return copy | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const path = require('path') | ||
|
||
const pages = {} | ||
const root = __dirname | ||
|
||
for (let page of loads) | ||
pages[page] = { | ||
entry: path.join(root, 'source', `${page}.js`), | ||
template: path.join(root, 'public', `${page}.html`), | ||
filename: `${page}.html` | ||
} | ||
|
||
module.exports = { | ||
publicPath: './', | ||
pages: pages, | ||
filenameHashing: false, | ||
productionSourceMap: false, | ||
outputDir: path.join(root, 'gui'), | ||
configureWebpack: { | ||
resolve: { | ||
alias: { | ||
'root': root, | ||
':root': root, | ||
|
||
'src': path.join(root, 'source'), | ||
':src': path.join(root, 'source') | ||
} | ||
} | ||
} | ||
} |