-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
78 lines (60 loc) · 1.58 KB
/
main.js
File metadata and controls
78 lines (60 loc) · 1.58 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
var path = require('path');
var electron = require('electron');
var app = electron.app;
var globalShortcut = electron.globalShortcut;
var mainWindow;
app.commandLine.appendSwitch(
'ppapi-flash-path',
path.join(__dirname, 'PepperFlashPlayer.plugin')
);
app.commandLine.appendSwitch('ppapi-flash-version', '20.0.0.306');
app.on('ready', function() {
globalShortcut.register('MediaNextTrack', function() {
// 下一首
mainWindow.webContents.send('nextSong');
});
globalShortcut.register('MediaPlayPause', function() {
// 播放/暂停
mainWindow.webContents.send('playPause');
});
globalShortcut.register('Cmd + L', function() {
// 喜欢
mainWindow.webContents.send('like');
});
/*
globalShortcut.register('Cmd + T', function() {
// 垃圾桶
mainWindow.webContents.send('trash');
});*/
createWindow();
});
app.on('will-quit', function() {
globalShortcut.unregisterAll();
// ipcRenderer.removeAllListeners();
});
app.on('window-all-closed', function() {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', function() {
if (mainWindow === null) {
createWindow();
}
});
function createWindow() {
mainWindow = new electron.BrowserWindow({
// fullscreen: true,
width: 1200,
height: 600,
'web-preferences': { 'plugins': true },
title: 'douban.fm',
icon: __dirname + '/douban-fm.png'
});
mainWindow.loadURL('file://' + __dirname + '/index.html');
// mainWindow.webContents.openDevTools();
mainWindow.on('closed', function() {
mainWindow = null;
});
}