feat: electron goodies

This commit is contained in:
cha0s 2022-04-04 07:16:46 -05:00
parent 0afee09cf8
commit f192d52345
5 changed files with 39 additions and 23 deletions

View File

@ -1,8 +0,0 @@
require('dotenv/config');
module.exports = {
options: {
root: __dirname,
},
use: [],
};

View File

@ -109,6 +109,11 @@
'@flecks/redux': {} '@flecks/redux': {}
'@flecks/repl': {} '@flecks/repl': {}
'@flecks/server': '@flecks/server':
nodeArgs:
- '--inspect'
# - '--log-deopt'
# - '--log-ic'
# - '--logfile=/home/cha0s/yuge/tmp/v8.log'
up: up:
- '@flecks/docker' - '@flecks/docker'
- '@flecks/db' - '@flecks/db'
@ -136,6 +141,7 @@
resolution: [1600, 900] resolution: [1600, 900]
'@humus/combat': {} '@humus/combat': {}
'@humus/core': {} '@humus/core': {}
'@humus/core/electron': {}
'@humus/farm': {} '@humus/farm': {}
'@humus/inventory': {} '@humus/inventory': {}
'@humus/universe': '@humus/universe':

View File

@ -18,6 +18,8 @@
}, },
"files": [ "files": [
"build", "build",
"electron/server.js",
"electron/server.js.map",
"index.js", "index.js",
"index.js.map", "index.js.map",
"server.js", "server.js",
@ -44,7 +46,8 @@
"@flecks/redux": "^1.4.1", "@flecks/redux": "^1.4.1",
"@flecks/socket": "^1.4.1", "@flecks/socket": "^1.4.1",
"@flecks/user": "^1.4.1", "@flecks/user": "^1.4.1",
"debug": "4.3.1" "debug": "4.3.1",
"is-electron": "^2.2.1"
}, },
"devDependencies": { "devDependencies": {
"@flecks/fleck": "^1.4.1" "@flecks/fleck": "^1.4.1"

View File

@ -0,0 +1,29 @@
import {Hooks} from '@flecks/core';
import isElectron from 'is-electron';
const {
NODE_ENV,
} = process.env;
export default {
[Hooks]: {
'@flecks/electron/server.window': async (win) => {
win.removeMenu();
if ('production' !== NODE_ENV) {
win.openDevTools();
}
win.maximize();
win.once('ready-to-show', () => {
win.show();
});
},
'@flecks/web/server.request.route': (flecks) => async (req, res, next) => {
if (isElectron() && 0 === req.user.id) {
const {User} = flecks.get('$flecks/db.models');
req.logIn(await User.findByPk(1), next);
return;
}
next();
},
},
};

View File

@ -1,14 +0,0 @@
import {Hooks} from '@flecks/core';
export default {
[Hooks]: {
'@flecks/electron/server.window': async (win) => {
win.removeMenu();
win.openDevTools();
win.maximize();
win.once('ready-to-show', () => {
win.show();
});
},
},
};