mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Typescript: Completed about app
This commit is contained in:
@@ -8,6 +8,15 @@ import { windowHandler } from './window-handler';
|
|||||||
let protocolWindow: Electron.WebContents;
|
let protocolWindow: Electron.WebContents;
|
||||||
let protocolUrl: string | undefined;
|
let protocolUrl: string | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caches the protocol uri
|
||||||
|
* @param {String} uri - the uri opened in the format 'symphony://...'
|
||||||
|
*/
|
||||||
|
const setProtocolUrl = (uri: string): void => {
|
||||||
|
logger.info(`Setting the property protocol url to ${uri}`);
|
||||||
|
protocolUrl = uri;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a protocol uri
|
* Processes a protocol uri
|
||||||
* @param {String} uri - the uri opened in the format 'symphony://abc?def=ghi'
|
* @param {String} uri - the uri opened in the format 'symphony://abc?def=ghi'
|
||||||
@@ -27,34 +36,6 @@ const processProtocolUri = (uri: string): void => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes protocol action for windows clients
|
|
||||||
* @param argv {Array} an array of command line arguments
|
|
||||||
* @param isAppAlreadyOpen {Boolean} whether the app is already open
|
|
||||||
*/
|
|
||||||
const processProtocolArgv = (argv: string[], isAppAlreadyOpen: boolean): void => {
|
|
||||||
|
|
||||||
// In case of windows, we need to handle protocol handler
|
|
||||||
// manually because electron doesn't emit
|
|
||||||
// 'open-url' event on windows
|
|
||||||
if (!(process.platform === 'win32')) {
|
|
||||||
logger.info('This is windows, not processing protocol url through arguments');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const protocolUri = getCommandLineArgs(argv, 'symphony://', false);
|
|
||||||
logger.info(`Trying to process a protocol action for uri ${protocolUri}`);
|
|
||||||
|
|
||||||
if (protocolUri) {
|
|
||||||
const parsedURL = url.parse(protocolUri);
|
|
||||||
if (!parsedURL.protocol || !parsedURL.slashes) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
logger.info(`Successfully parsed protocol url for ${parsedURL}`);
|
|
||||||
handleProtocolAction(protocolUri, isAppAlreadyOpen);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a protocol action based on the current state of the app
|
* Handles a protocol action based on the current state of the app
|
||||||
* @param uri
|
* @param uri
|
||||||
@@ -86,6 +67,34 @@ const handleProtocolAction = (uri: string, isAppAlreadyOpen: boolean): void => {
|
|||||||
processProtocolUri(uri);
|
processProtocolUri(uri);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes protocol action for windows clients
|
||||||
|
* @param argv {Array} an array of command line arguments
|
||||||
|
* @param isAppAlreadyOpen {Boolean} whether the app is already open
|
||||||
|
*/
|
||||||
|
const processProtocolArgv = (argv: string[], isAppAlreadyOpen: boolean): void => {
|
||||||
|
|
||||||
|
// In case of windows, we need to handle protocol handler
|
||||||
|
// manually because electron doesn't emit
|
||||||
|
// 'open-url' event on windows
|
||||||
|
if (!(process.platform === 'win32')) {
|
||||||
|
logger.info('This is windows, not processing protocol url through arguments');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const protocolUri = getCommandLineArgs(argv, 'symphony://', false);
|
||||||
|
logger.info(`Trying to process a protocol action for uri ${protocolUri}`);
|
||||||
|
|
||||||
|
if (protocolUri) {
|
||||||
|
const parsedURL = url.parse(protocolUri);
|
||||||
|
if (!parsedURL.protocol || !parsedURL.slashes) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logger.info(`Successfully parsed protocol url for ${parsedURL}`);
|
||||||
|
handleProtocolAction(protocolUri, isAppAlreadyOpen);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the protocol window
|
* Sets the protocol window
|
||||||
* @param {Object} win - the renderer window
|
* @param {Object} win - the renderer window
|
||||||
@@ -108,15 +117,6 @@ const checkProtocolAction = (): void => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Caches the protocol uri
|
|
||||||
* @param {String} uri - the uri opened in the format 'symphony://...'
|
|
||||||
*/
|
|
||||||
const setProtocolUrl = (uri: string): void => {
|
|
||||||
logger.info(`Setting the property protocol url to ${uri}`);
|
|
||||||
protocolUrl = uri;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the protocol url set against an instance
|
* Gets the protocol url set against an instance
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export class WindowHandler {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const extra = { podUrl: this.globalConfig.url, process: 'main' };
|
const extra = { podUrl: this.globalConfig.url, process: 'main' };
|
||||||
crashReporter.start({ ...this.globalConfig.crashReporter, ...extra });
|
crashReporter.start({ ...this.globalConfig.crashReporter, extra });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('failed to init crash report');
|
throw new Error('failed to init crash report');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { ipcRenderer } from 'electron';
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as ReactDOM from 'react-dom';
|
import * as ReactDOM from 'react-dom';
|
||||||
|
|
||||||
import AboutBox from './about-app';
|
import AboutBox from './about-app';
|
||||||
import LoadingScreen from './loading-screen';
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', load);
|
document.addEventListener('DOMContentLoaded', load);
|
||||||
|
|
||||||
@@ -12,20 +9,14 @@ document.addEventListener('DOMContentLoaded', load);
|
|||||||
*/
|
*/
|
||||||
export function load() {
|
export function load() {
|
||||||
const query = new URL(window.location.href).searchParams;
|
const query = new URL(window.location.href).searchParams;
|
||||||
const componentName = query.get('componentName');
|
const componentName = query.get('component');
|
||||||
|
|
||||||
let component;
|
let component;
|
||||||
switch (componentName) {
|
switch (componentName) {
|
||||||
case 'about-app':
|
case 'about-app':
|
||||||
component = AboutBox;
|
component = AboutBox;
|
||||||
break;
|
break;
|
||||||
case 'loading-screen':
|
|
||||||
component = LoadingScreen;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
const element = React.createElement(component);
|
||||||
ipcRenderer.on('data', (__: Electron.Event, args) => {
|
ReactDOM.render(element, document.getElementById('Root'));
|
||||||
const element = React.createElement(component, args);
|
|
||||||
ReactDOM.render(element, document.getElementById('Root'));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user