Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
syntax_j
mycard
Commits
5b016d5c
Commit
5b016d5c
authored
Jul 16, 2021
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
friendly aria2c fail tip
parent
38b0ad61
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
index.js
index.js
+22
-4
No files found.
index.js
View file @
5b016d5c
...
...
@@ -27,7 +27,7 @@ if (handleElevate()) {
return
;
}
const
{
ipcMain
,
app
,
shell
,
BrowserWindow
,
Menu
,
Tray
}
=
require
(
'
electron
'
);
const
{
ipcMain
,
app
,
shell
,
BrowserWindow
,
Menu
,
Tray
,
Notification
}
=
require
(
'
electron
'
);
const
{
autoUpdater
}
=
require
(
'
electron-updater
'
);
const
isDev
=
require
(
'
electron-is-dev
'
);
const
child_process
=
require
(
'
child_process
'
);
...
...
@@ -37,6 +37,9 @@ const path = require('path');
// be closed automatically when the JavaScript object is garbage collected.
let
mainWindow
;
// aria2c启动失败则为null
let
aria2c
;
// 单实例
const
gotTheLock
=
app
.
requestSingleInstanceLock
()
...
...
@@ -136,9 +139,18 @@ function createAria2c() {
default
:
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
'
});
aria2c
=
child_process
.
spawn
(
aria2c_path
,
[
'
--enable-rpc
'
,
'
--rpc-allow-origin-all
'
,
'
--rpc-listen-port=6800
'
,
'
--continue
'
,
'
--split=10
'
,
'
--min-split-size=1M
'
,
'
--max-connection-per-server=10
'
,
'
--remove-control-file
'
,
'
--allow-overwrite
'
],
{
stdio
:
'
ignore
'
});
}
const
aria2c
=
createAria2c
();
// 主窗口
function
createWindow
()
{
...
...
@@ -212,6 +224,12 @@ app.on('ready', async () => {
if
(
process
.
platform
===
'
win32
'
)
{
createTray
();
}
createAria2c
();
aria2c
.
on
(
'
error
'
,
(
err
)
=>
{
new
Notification
({
title
:
'
MyCard
'
,
body
:
'
启动aria2失败,可能是被杀毒软件误删。游戏下载和更新功能将不可用。
'
}).
show
();
console
.
error
(
err
);
aria2c
=
null
;
});
if
(
process
.
env
[
'
NODE_ENV
'
]
===
'
production
'
)
{
/*let updateTempPath = '~/.cache/mycard-updater'
if (process.platform === 'win32') {
...
...
@@ -248,7 +266,7 @@ app.on('activate', function () {
app
.
on
(
'
quit
'
,
()
=>
{
// windows 在非 detach 模式下会自动退出子进程
if
(
process
.
platform
!==
'
win32
'
)
{
if
(
process
.
platform
!==
'
win32
'
&&
aria2c
)
{
aria2c
.
kill
();
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment