Commit 5d120d0e authored by 神楽坂玲奈's avatar 神楽坂玲奈

fix, 3.0.30

parent 18875db6
...@@ -16,9 +16,9 @@ function handleElevate() { ...@@ -16,9 +16,9 @@ function handleElevate() {
require('net').connect(elevate['ipc'], function () { require('net').connect(elevate['ipc'], function () {
process.send = (message, sendHandle, options, callback) => this.write(JSON.stringify(message) + require('os').EOL, callback); process.send = (message, sendHandle, options, callback) => this.write(JSON.stringify(message) + require('os').EOL, callback);
this.on('end', () => process.emit('disconnect')); this.on('end', () => process.emit('disconnect'));
require('readline').createInterface({input: this}).on('line', (line) => process.emit('message', JSON.parse(line))); require('readline').createInterface({ input: this }).on('line', (line) => process.emit('message', JSON.parse(line)));
process.argv = elevate['arguments'][1]; process.argv = elevate['arguments'][1];
require("./" + elevate['arguments'][0]); require('./' + elevate['arguments'][0]);
}); });
return true; return true;
} }
...@@ -27,7 +27,7 @@ if (handleElevate()) { ...@@ -27,7 +27,7 @@ if (handleElevate()) {
return; return;
} }
const {ipcMain, app, shell, BrowserWindow, Menu, Tray} = require('electron'); const { ipcMain, app, shell, BrowserWindow, Menu, Tray } = require('electron');
const { autoUpdater } = require('electron-updater'); const { autoUpdater } = require('electron-updater');
const isDev = require('electron-is-dev'); const isDev = require('electron-is-dev');
const child_process = require('child_process'); const child_process = require('child_process');
...@@ -42,21 +42,21 @@ const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => { ...@@ -42,21 +42,21 @@ const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window. // Someone tried to run a second instance, we should focus our window.
if (mainWindow) { if (mainWindow) {
if (mainWindow.isMinimized()) { if (mainWindow.isMinimized()) {
mainWindow.restore() mainWindow.restore();
} }
if (!mainWindow.isVisible()) { if (!mainWindow.isVisible()) {
mainWindow.show(); mainWindow.show();
} }
mainWindow.focus() mainWindow.focus();
} }
}); });
if (shouldQuit) { if (shouldQuit) {
app.quit() app.quit();
} }
// 调试模式 // 调试模式
if (!process.env['NODE_ENV']) { if (!process.env['NODE_ENV']) {
process.env['NODE_ENV'] = isDev ? 'development' : 'production' process.env['NODE_ENV'] = isDev ? 'development' : 'production';
} }
// 自动更新 // 自动更新
...@@ -102,11 +102,11 @@ autoUpdater.on('update-downloaded', (event) => { ...@@ -102,11 +102,11 @@ autoUpdater.on('update-downloaded', (event) => {
shell.openExternal(url); shell.openExternal(url);
}); });
updateWindow.on('closed', function () { updateWindow.on('closed', function () {
updateWindow = null updateWindow = null;
}); });
ipcMain.on('update', (event, arg) => { ipcMain.on('update', (event, arg) => {
autoUpdater.quitAndInstall() autoUpdater.quitAndInstall();
}) });
}); });
// Aria2c // Aria2c
...@@ -130,7 +130,7 @@ function createAria2c() { ...@@ -130,7 +130,7 @@ function createAria2c() {
default: default:
throw 'unsupported platform'; throw 'unsupported platform';
} }
return child_process.spawn(aria2c_path, ['--enable-rpc', '--rpc-allow-origin-all', '--continue', '--split=10', '--min-split-size=1M', '--max-connection-per-server=10', '--remove-control-file', '--allow-overwrite'], {stdio: 'ignore'}); return child_process.spawn(aria2c_path, ['--enable-rpc', '--rpc-allow-origin-all', '--continue', '--split=10', '--min-split-size=1M', '--max-connection-per-server=10', '--remove-control-file', '--allow-overwrite'], { stdio: 'ignore' });
} }
const aria2c = createAria2c(); const aria2c = createAria2c();
...@@ -165,13 +165,13 @@ function createWindow() { ...@@ -165,13 +165,13 @@ function createWindow() {
// Dereference the window object, usually you would store windows // Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time // in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element. // when you should delete the corresponding element.
mainWindow = null mainWindow = null;
}) });
} }
let tray; let tray;
function createTray() { function createTray() {
tray = new Tray(path.join('images', 'icon.ico')); tray = new Tray(path.join(__dirname, 'images', 'icon.ico'));
tray.on('click', (event) => { tray.on('click', (event) => {
console.log(event); console.log(event);
if (event.metaKey) { if (event.metaKey) {
...@@ -203,10 +203,10 @@ function createTray() { ...@@ -203,10 +203,10 @@ function createTray() {
app.on('ready', () => { app.on('ready', () => {
createWindow(); createWindow();
if (process.platform === 'win32') { if (process.platform === 'win32') {
createTray() createTray();
} }
if (process.env['NODE_ENV'] === 'production') { if (process.env['NODE_ENV'] === 'production') {
autoUpdater.checkForUpdates() autoUpdater.checkForUpdates();
} }
}); });
...@@ -215,7 +215,7 @@ app.on('window-all-closed', function () { ...@@ -215,7 +215,7 @@ app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar // On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q // to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
app.quit() app.quit();
} }
}); });
...@@ -223,7 +223,7 @@ app.on('activate', function () { ...@@ -223,7 +223,7 @@ app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the // On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open. // dock icon is clicked and there are no other windows open.
if (mainWindow === null) { if (mainWindow === null) {
createWindow() createWindow();
} }
}); });
...@@ -233,6 +233,6 @@ app.on('activate', function () { ...@@ -233,6 +233,6 @@ app.on('activate', function () {
app.on('quit', () => { app.on('quit', () => {
// windows 在非 detach 模式下会自动退出子进程 // windows 在非 detach 模式下会自动退出子进程
if (process.platform !== 'win32') { if (process.platform !== 'win32') {
aria2c.kill() aria2c.kill();
} }
}); });
{ {
"name": "mycard", "name": "mycard",
"version": "3.0.29", "version": "3.0.30",
"description": "moecube", "description": "moecube",
"keywords": [], "keywords": [],
"author": "zh99998 <zh99998@gmail.com>", "author": "zh99998 <zh99998@gmail.com>",
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
"devDependencies": { "devDependencies": {
"@angular/compiler-cli": "latest", "@angular/compiler-cli": "latest",
"@angular/platform-server": "latest", "@angular/platform-server": "latest",
"@types/electron": "latest",
"@types/glob": "latest", "@types/glob": "latest",
"@types/ini": "latest", "@types/ini": "latest",
"@types/node": "latest", "@types/node": "latest",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment