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
9
Issues
9
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
MyCard
mycard
Commits
b81b5bdd
Commit
b81b5bdd
authored
Jul 16, 2025
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix log
parent
bc1051f5
Pipeline
#39095
failed with stages
in 4 minutes and 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
index.js
index.js
+23
-7
No files found.
index.js
View file @
b81b5bdd
...
...
@@ -65,6 +65,25 @@ if (!process.env['NODE_ENV']) {
process
.
env
[
'
NODE_ENV
'
]
=
isDev
?
'
development
'
:
'
production
'
;
}
// 记录主窗口加载前的日志
const
logBuffer
=
[];
function
mylog
(...
args
)
{
logBuffer
.
push
(
args
);
console
.
log
(
args
);
flushLogBuffer
();
}
// 转发给主窗口
function
flushLogBuffer
()
{
if
(
mainWindow
&&
mainWindow
.
webContents
&&
logBuffer
.
length
>
0
)
{
logBuffer
.
forEach
(
args
=>
{
mainWindow
.
webContents
.
executeJavaScript
(
`console.log.apply(console,
${
JSON
.
stringify
(
args
)}
)`
);
});
logBuffer
.
length
=
0
;
}
}
// 自动更新
let
updateWindow
;
global
.
autoUpdater
=
autoUpdater
;
...
...
@@ -156,17 +175,13 @@ function createAria2c() {
'
--max-download-result=40000
'
],
{
stdio
:
'
ignore
'
});
aria2c
.
on
(
'
error
'
,
(
err
)
=>
{
console
.
error
(
'
aria2c spawn error:
'
,
aria2c_path
,
err
);
});
aria2c
.
on
(
'
exit
'
,
(
code
,
signal
)
=>
{
if
(
code
!==
0
)
{
console
.
error
(
`aria2c exited with code
${
code
}
, signal
${
signal
}
, aria2c_path:
${
aria2c_path
}
`
);
mylog
(
`aria2c exited with code
${
code
}
, signal
${
signal
}
, aria2c_path:
${
aria2c_path
}
`
);
}
});
}
catch
(
err
)
{
console
.
error
(
'
Failed to start aria2c:
'
,
aria2c_path
,
err
);
mylog
(
'
Failed to start aria2c:
'
,
aria2c_path
,
err
);
}
}
...
...
@@ -239,13 +254,14 @@ function createTray() {
// Some APIs can only be used after this event occurs.
app
.
on
(
'
ready
'
,
async
()
=>
{
createWindow
();
flushLogBuffer
();
if
(
process
.
platform
===
'
win32
'
)
{
createTray
();
}
createAria2c
();
aria2c
.
on
(
'
error
'
,
(
err
)
=>
{
new
Notification
({
title
:
'
MyCard
'
,
body
:
'
启动aria2失败,可能是被杀毒软件误删。游戏下载和更新功能将不可用。
'
}).
show
();
console
.
error
(
err
);
mylog
(
'
启动aria2失败
'
,
err
,
'
工作目录:
'
,
process
.
cwd
()
);
aria2c
=
null
;
});
if
(
process
.
env
[
'
NODE_ENV
'
]
===
'
production
'
)
{
...
...
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