-
Notifications
You must be signed in to change notification settings - Fork 2
/
electron-launch.ts
43 lines (39 loc) · 1.14 KB
/
electron-launch.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
import {app} from 'electron';
var _url: any, url = () => { _url = _url || require('url'); return _url; };
var _path: any, path = () => { _path = _path || require('path'); return _path; };
class FnLaunch implements yubo.FnLaunch {
constructor() {}
handleOpenFile(filePath: string): void {
const myApp = ((this as unknown) as yubo.IMYukkuriVoice);
if (myApp.mainWindow) {
const ext = path().extname(filePath);
if (ext == '.wav') {
myApp.mainWindow.webContents.send('recentDocument', filePath);
} else {
myApp.mainWindow.webContents.send('dropTextFile', filePath);
}
} else {
myApp.launchArgs = {filePath: filePath};
}
}
handleOpenUrl(scheme: string): void {
const myApp = ((this as unknown) as yubo.IMYukkuriVoice);
const parsed = url().parse(scheme, true);
switch (parsed.host) {
case 'quit':
app.quit();
break;
case 'reload':
if (myApp.mainWindow) {
myApp.mainWindow.webContents.reload();
}
break;
case 'open':
default:
// open
break;
}
}
}
export default FnLaunch;