feat: electron goodies
This commit is contained in:
parent
e350d52186
commit
204444f8c8
|
@ -90,11 +90,12 @@
|
||||||
- 'react-window'
|
- 'react-window'
|
||||||
port: 32360
|
port: 32360
|
||||||
request.route:
|
request.route:
|
||||||
- '@flecks/user/session/server'
|
- '@flecks/user/session'
|
||||||
- '@flecks/user/server'
|
- '@flecks/user'
|
||||||
|
- '@persea/core/electron'
|
||||||
- '...'
|
- '...'
|
||||||
request.socket:
|
request.socket:
|
||||||
- '@persea/core/server'
|
- '@persea/core'
|
||||||
- '...'
|
- '...'
|
||||||
stream.html:
|
stream.html:
|
||||||
- '@flecks/react'
|
- '@flecks/react'
|
||||||
|
@ -137,3 +138,4 @@
|
||||||
'@flecks/user/session': {}
|
'@flecks/user/session': {}
|
||||||
'@persea/bootstrap': {}
|
'@persea/bootstrap': {}
|
||||||
'@persea/core': {}
|
'@persea/core': {}
|
||||||
|
'@persea/core/electron': {}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<base href="/" />
|
<base href="/" />
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
<link rel="icon" type="image/png" href="/icon.png" />
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no" />
|
<meta name="viewport" content="width=device-width, user-scalable=no" />
|
||||||
<title>Persea</title>
|
<title>Persea</title>
|
||||||
<style>
|
<style>
|
||||||
|
|
21
build/web.neutrinorc.js
Normal file
21
build/web.neutrinorc.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
|
const copy = require('@neutrinojs/copy');
|
||||||
|
|
||||||
|
module.exports = async (flecks) => {
|
||||||
|
// eslint-disable-next-line global-require
|
||||||
|
const config = await require('@flecks/web/server/build/web.neutrinorc')(flecks);
|
||||||
|
|
||||||
|
config.use.push(
|
||||||
|
copy({
|
||||||
|
copyUnmodified: true,
|
||||||
|
patterns: [
|
||||||
|
{
|
||||||
|
from: 'icon.png',
|
||||||
|
to: 'web/assets/icon.png',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return config;
|
||||||
|
};
|
|
@ -17,6 +17,8 @@
|
||||||
"files": [
|
"files": [
|
||||||
"assets",
|
"assets",
|
||||||
"build",
|
"build",
|
||||||
|
"electron/server.js",
|
||||||
|
"electron/server.js.map",
|
||||||
"index.css",
|
"index.css",
|
||||||
"index.css.map",
|
"index.css.map",
|
||||||
"index.js",
|
"index.js",
|
||||||
|
@ -41,6 +43,7 @@
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"fast-json-patch": "^3.0.0-1",
|
"fast-json-patch": "^3.0.0-1",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
|
"is-electron": "^2.2.1",
|
||||||
"natsort": "^2.0.2",
|
"natsort": "^2.0.2",
|
||||||
"react-hex-editor": "^0.3.0",
|
"react-hex-editor": "^0.3.0",
|
||||||
"react-modal": "^3.12.1",
|
"react-modal": "^3.12.1",
|
||||||
|
|
36
packages/core/src/electron/server.js
Normal file
36
packages/core/src/electron/server.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import {join} from 'path';
|
||||||
|
|
||||||
|
import {Hooks} from '@flecks/core';
|
||||||
|
import isElectron from 'is-electron';
|
||||||
|
|
||||||
|
const {
|
||||||
|
FLECKS_CORE_ROOT = process.cwd(),
|
||||||
|
NODE_ENV,
|
||||||
|
} = process.env;
|
||||||
|
|
||||||
|
export default {
|
||||||
|
[Hooks]: {
|
||||||
|
'@flecks/core.starting': (flecks) => {
|
||||||
|
const {browserWindowOptions} = flecks.get('@flecks/electron/server');
|
||||||
|
browserWindowOptions.icon = join(FLECKS_CORE_ROOT, 'icon.png');
|
||||||
|
},
|
||||||
|
'@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();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
|
@ -24,14 +24,6 @@ export default {
|
||||||
'@flecks/db/server.models.decorate': (
|
'@flecks/db/server.models.decorate': (
|
||||||
Flecks.decorate(require.context('./models/decorators', false, /\.js$/))
|
Flecks.decorate(require.context('./models/decorators', false, /\.js$/))
|
||||||
),
|
),
|
||||||
'@flecks/electron/server.window': async (win) => {
|
|
||||||
win.removeMenu();
|
|
||||||
win.openDevTools();
|
|
||||||
win.maximize();
|
|
||||||
win.once('ready-to-show', () => {
|
|
||||||
win.show();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'@flecks/web/server.request.socket': () => (req, res, next) => {
|
'@flecks/web/server.request.socket': () => (req, res, next) => {
|
||||||
if (req.url.startsWith('/projects')) {
|
if (req.url.startsWith('/projects')) {
|
||||||
req.url = req.url.slice(9);
|
req.url = req.url.slice(9);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user