Basic electron interface

This commit is contained in:
Jaco Greeff 2017-08-30 11:59:38 +02:00
parent d7de40ab4c
commit be56a06790
6 changed files with 65 additions and 5 deletions

View File

@ -1,7 +1,7 @@
{
"name": "parity.js",
"name": "Parity",
"version": "1.8.17",
"main": "release/index.js",
"main": "src/index.electron.js",
"jsnext:main": "src/index.js",
"author": "Parity Team <admin@parity.io>",
"maintainers": [
@ -46,6 +46,7 @@
"lint:js:fix": "eslint --fix --ignore-path .gitignore ./src/",
"start": "npm run clean && npm install && npm run build:lib && npm run start:app",
"start:app": "node webpack/dev.server",
"start:electron": "electron .",
"test": "NODE_ENV=test mocha --compilers ejs:ejsify 'src/**/*.spec.js' 'packages/**/*.spec.js'",
"test:coverage": "NODE_ENV=test istanbul cover _mocha -- --compilers ejs:ejsify 'src/**/*.spec.js' 'packages/**/*.spec.js'",
"test:e2e": "NODE_ENV=test mocha 'src/**/*.e2e.js' 'packages/**/*.e2e.js'",

57
js/src/index.electron.js Normal file
View File

@ -0,0 +1,57 @@
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
const url = require('url');
let mainWindow;
function createWindow () {
mainWindow = new BrowserWindow({
height: 600,
width: 800
});
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, '../.build', 'index.html'),
protocol: 'file:',
slashes: true
}));
mainWindow.webContents.openDevTools();
mainWindow.on('closed', function () {
mainWindow = null;
});
}
app.on('ready', createWindow);
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', function () {
if (mainWindow === null) {
createWindow();
}
});

View File

@ -46,7 +46,9 @@ export default class SecureApi extends Api {
// Returns a protocol with `:` at the end.
static protocol () {
return window.location.protocol;
return window.location.protocol === 'file:'
? 'http:'
: window.location.protocol;
}
constructor (uiUrl, nextToken, getTransport = SecureApi.getTransport, protocol = SecureApi.protocol) {

View File

@ -47,7 +47,7 @@ const isEmbed = EMBED === '1' || EMBED === 'true';
const entry = isEmbed
? { embed: './embed.js' }
: { bundle: './index.js' };
: { bundle: './index.parity.js' };
module.exports = {
cache: !isProd,
@ -176,7 +176,7 @@ module.exports = {
new HtmlWebpackPlugin({
title: 'Parity',
filename: 'index.html',
template: './index.ejs',
template: './index.parity.ejs',
favicon: FAVICON,
chunks: ['bundle']
}),