This commit is contained in:
crusader 2018-10-02 21:20:53 +09:00
parent e12cf15dda
commit df1c926c67

View File

@ -33,6 +33,10 @@ const launchTime = now();
let preventQuit = false;
let readyTime: number | null = null;
let db: sqlite3.Database;
let probeProcess: ChildProcess.ChildProcess;
type OnDidLoadFn = (window: AppWindow) => void;
/** See the `onDidLoad` function. */
let onDidLoadFns: Array<OnDidLoadFn> | null = [];
@ -186,7 +190,9 @@ app.on('ready', () => {
path.join(__dirname, '..', '..', 'config', '_database.sqlite')
: path.join(__dirname, '..', '..', 'bin', 'database.sqlite');
const db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => {
db = new sqlite3.Database(dbPath, sqlite3.OPEN_READONLY, (err: Error) => {
if (err) {
console.error(err.message);
}
@ -195,7 +201,7 @@ app.on('ready', () => {
if (!__DEV__) {
const probePath = path.join(__dirname, '..', '..', 'bin', 'probe');
ChildProcess.spawn(probePath);
probeProcess = ChildProcess.spawn(probePath);
}
readyTime = now() - launchTime;
@ -403,6 +409,19 @@ app.on('web-contents-created', (event, contents) => {
});
});
app.on('before-quit', function (event) {
event.preventDefault();
if (null !== db) {
db.close();
}
if (null !== probeProcess && !probeProcess.killed) {
probeProcess.kill();
}
});
// app.on(
// 'certificate-error',
// (event, webContents, url, error, certificate, callback) => {