This commit is contained in:
crusader 2018-10-02 21:48:02 +09:00
parent df1c926c67
commit 2c594295a6
2 changed files with 16 additions and 1309 deletions

View File

@ -3,7 +3,10 @@ import * as fse from 'fs-extra';
import * as path from 'path'; import * as path from 'path';
import * as ChildProcess from 'child_process'; import * as ChildProcess from 'child_process';
import { shellNeedsPatching, updateEnvironmentForProcess } from '@overflow/core/shell'; import {
shellNeedsPatching,
updateEnvironmentForProcess
} from '@overflow/core/shell';
import { parseAppURL } from '@overflow/core/parse-app-url'; import { parseAppURL } from '@overflow/core/parse-app-url';
// import { // import {
// enableSourceMaps, // enableSourceMaps,
@ -33,9 +36,8 @@ const launchTime = now();
let preventQuit = false; let preventQuit = false;
let readyTime: number | null = null; let readyTime: number | null = null;
let db: sqlite3.Database; let db: sqlite3.Database | null = null;
let probeProcess: ChildProcess.ChildProcess; let probeProcess: ChildProcess.ChildProcess | null = null;
type OnDidLoadFn = (window: AppWindow) => void; type OnDidLoadFn = (window: AppWindow) => void;
/** See the `onDidLoad` function. */ /** See the `onDidLoad` function. */
@ -167,7 +169,7 @@ function setAsDefaultProtocolClient(protocol: string) {
if (__WIN32__) { if (__WIN32__) {
app.setAsDefaultProtocolClient(protocol, process.execPath, [ app.setAsDefaultProtocolClient(protocol, process.execPath, [
'--protocol-launcher', '--protocol-launcher',
'--', '--'
]); ]);
} else { } else {
app.setAsDefaultProtocolClient(protocol); app.setAsDefaultProtocolClient(protocol);
@ -186,12 +188,10 @@ app.on('ready', () => {
return; return;
} }
const dbPath = __DEV__ ? const dbPath = __DEV__
path.join(__dirname, '..', '..', 'config', '_database.sqlite') ? path.join(__dirname, '..', '..', 'config', '_database.sqlite')
: path.join(__dirname, '..', '..', 'bin', 'database.sqlite'); : path.join(__dirname, '..', '..', 'bin', 'database.sqlite');
db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => { db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => {
if (err) { if (err) {
console.error(err.message); console.error(err.message);
@ -228,9 +228,7 @@ app.on('ready', () => {
ipcMain.on( ipcMain.on(
'update-preferred-app-menu-item-labels', 'update-preferred-app-menu-item-labels',
( (event: Electron.IpcMessageEvent) => {
event: Electron.IpcMessageEvent,
) => {
menu = buildDefaultMenu(); menu = buildDefaultMenu();
Menu.setApplicationMenu(menu); Menu.setApplicationMenu(menu);
if (mainWindow) { if (mainWindow) {
@ -256,7 +254,7 @@ app.on('ready', () => {
const menuItem = findMenuItemByID(menu, id); const menuItem = findMenuItemByID(menu, id);
if (menuItem) { if (menuItem) {
const window = BrowserWindow.fromWebContents(event.sender); const window = BrowserWindow.fromWebContents(event.sender);
const fakeEvent = { preventDefault: () => { }, sender: event.sender }; const fakeEvent = { preventDefault: () => {}, sender: event.sender };
menuItem.click(fakeEvent, window, event.sender); menuItem.click(fakeEvent, window, event.sender);
} }
} }
@ -409,7 +407,7 @@ app.on('web-contents-created', (event, contents) => {
}); });
}); });
app.on('before-quit', function (event) { app.on('before-quit', function(event) {
event.preventDefault(); event.preventDefault();
if (null !== db) { if (null !== db) {
@ -419,7 +417,6 @@ app.on('before-quit', function (event) {
if (null !== probeProcess && !probeProcess.killed) { if (null !== probeProcess && !probeProcess.killed) {
probeProcess.kill(); probeProcess.kill();
} }
}); });
// app.on( // app.on(
@ -438,14 +435,14 @@ function createWindow() {
if (__DEV__) { if (__DEV__) {
const { const {
default: installExtension, default: installExtension
} = require('electron-devtools-installer'); } = require('electron-devtools-installer');
require('electron-debug')({ showDevTools: true }); require('electron-debug')({ showDevTools: true });
const ChromeLens = { const ChromeLens = {
id: 'idikgljglpfilbhaboonnpnnincjhjkd', id: 'idikgljglpfilbhaboonnpnnincjhjkd',
electron: '>=1.2.1', electron: '>=1.2.1'
}; };
const extensions = [ChromeLens]; const extensions = [ChromeLens];
@ -453,7 +450,7 @@ function createWindow() {
for (const extension of extensions) { for (const extension of extensions) {
try { try {
installExtension(extension); installExtension(extension);
} catch (e) { } } catch (e) {}
} }
} }
@ -469,7 +466,7 @@ function createWindow() {
window.sendLaunchTimingStats({ window.sendLaunchTimingStats({
mainReadyTime: readyTime ? readyTime : 0, mainReadyTime: readyTime ? readyTime : 0,
loadTime: window.loadTime ? window.loadTime : 0, loadTime: window.loadTime ? window.loadTime : 0,
rendererReadyTime: window.rendererReadyTime ? window.rendererReadyTime : 0, rendererReadyTime: window.rendererReadyTime ? window.rendererReadyTime : 0
}); });
const fns = onDidLoadFns ? onDidLoadFns : null; const fns = onDidLoadFns ? onDidLoadFns : null;

1290
yarn.lock

File diff suppressed because it is too large Load Diff