Commit 4d79171f authored by 神楽坂玲奈's avatar 神楽坂玲奈

fix systemjs

parent ca3553d3
...@@ -6,16 +6,35 @@ const isDev = require('electron-is-dev'); ...@@ -6,16 +6,35 @@ const isDev = require('electron-is-dev');
const child_process = require('child_process'); const child_process = require('child_process');
const path = require('path'); const path = require('path');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
// 单实例
const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore()
}
mainWindow.focus()
}
})
if (shouldQuit) {
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'
} }
// 自动更新
let updateWindow;
global.autoUpdater = autoUpdater;
if (process.env['NODE_ENV'] == 'production' && process.platform == 'darwin') { if (process.env['NODE_ENV'] == 'production' && process.platform == 'darwin') {
autoUpdater.setFeedURL("https://wudizhanche.mycard.moe/update/darwin/" + app.getVersion()); autoUpdater.setFeedURL("https://wudizhanche.mycard.moe/update/darwin/" + app.getVersion());
} }
global.autoUpdater = autoUpdater;
autoUpdater.on('error', (event) => { autoUpdater.on('error', (event) => {
console.log('autoUpdater', 'error', event); console.log('autoUpdater', 'error', event);
}); });
...@@ -28,27 +47,22 @@ autoUpdater.on('update-available', () => { ...@@ -28,27 +47,22 @@ autoUpdater.on('update-available', () => {
autoUpdater.on('update-not-available', () => { autoUpdater.on('update-not-available', () => {
console.log('autoUpdater', 'update-not-available'); console.log('autoUpdater', 'update-not-available');
}); });
let updateWindow;
autoUpdater.on('update-downloaded', (event) => { autoUpdater.on('update-downloaded', (event) => {
console.log('autoUpdater', 'update-downloaded', event); console.log('autoUpdater', 'update-downloaded', event);
updateWindow = new BrowserWindow({ updateWindow = new BrowserWindow({
width: 640, width: 640,
height: 480, height: 480,
}); });
updateWindow.loadURL(`file://${__dirname}/update.html`); updateWindow.loadURL(`file://${__dirname}/update.html`);
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()
}) })
}); });
// 处理提权
function handleElevate() { function handleElevate() {
// for debug // for debug
...@@ -75,11 +89,11 @@ function handleElevate() { ...@@ -75,11 +89,11 @@ function handleElevate() {
return true; return true;
} }
} }
if (handleElevate()) { if (handleElevate()) {
return; return;
} }
// Aria2c
function createAria2c() { function createAria2c() {
let aria2c_path; let aria2c_path;
switch (process.platform) { switch (process.platform) {
...@@ -102,13 +116,9 @@ function createAria2c() { ...@@ -102,13 +116,9 @@ function createAria2c() {
} }
return child_process.spawn(aria2c_path, ['--enable-rpc', '--rpc-allow-origin-all', "--continue", "--split=10", "--min-split-size=1M", "--max-connection-per-server=10"], {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"], {stdio: 'ignore'});
} }
const aria2c = createAria2c(); const aria2c = createAria2c();
// Keep a global reference of the window object, if you don't, the window will // 主窗口
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
function createWindow() { function createWindow() {
// Create the browser window. // Create the browser window.
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
......
/*
SystemJS Text plugin from
https://github.com/systemjs/plugin-text/blob/master/text.js
*/
exports.translate = function(load) {
if (this.builder && this.transpiler) {
load.metadata.format = 'esm';
return 'exp' + 'ort var __useDefault = true; exp' + 'ort default ' + JSON.stringify(load.source) + ';';
}
load.metadata.format = 'amd';
return 'def' + 'ine(function() {\nreturn ' + JSON.stringify(load.source) + ';\n});';
}
...@@ -13,7 +13,7 @@ System.config({ ...@@ -13,7 +13,7 @@ System.config({
app: 'app', app: 'app',
// systemjs plugins // systemjs plugins
'text': 'systemjs-text-plugin.js', 'text': 'npm:systemjs-text-plugin.js',
// angular bundles // angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js', '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
......
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