Skip to content

Commit e939f9e

Browse files
authored
Merge pull request #925 from agalwood/hotfix/app_hang_20210507
2 parents 9461381 + 53ec0b1 commit e939f9e

10 files changed

Lines changed: 147 additions & 102 deletions

File tree

package.json

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Motrix",
3-
"version": "1.6.8",
3+
"version": "1.6.9",
44
"description": "A full-featured download manager",
55
"homepage": "https://motrix.app",
66
"author": {
@@ -92,18 +92,10 @@
9292
},
9393
"mac": {
9494
"target": [
95-
{
96-
"target": "dmg",
97-
"arch": [
98-
"x64",
99-
"arm64"
100-
]
101-
},
10295
{
10396
"target": "zip",
10497
"arch": [
105-
"x64",
106-
"arm64"
98+
"x64"
10799
]
108100
}
109101
],
@@ -240,7 +232,7 @@
240232
"css-loader": "^5.2.4",
241233
"css-minimizer-webpack-plugin": "^2.0.0",
242234
"del": "^6.0.0",
243-
"electron": "^11.4.4",
235+
"electron": "^11.4.5",
244236
"electron-builder": "22.10.5",
245237
"electron-builder-notarize": "^1.2.0",
246238
"electron-devtools-installer": "^3.2.0",
@@ -266,7 +258,7 @@
266258
"vue-style-loader": "^4.1.3",
267259
"vue-template-compiler": "^2.6.12",
268260
"webpack": "^5.36.2",
269-
"webpack-cli": "^4.6.0",
261+
"webpack-cli": "^4.7.0",
270262
"webpack-dev-server": "^3.11.2",
271263
"webpack-hot-middleware": "^2.25.0",
272264
"webpack-merge": "^5.7.3",

src/main/Application.js

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default class Application extends EventEmitter {
4141
}
4242

4343
init () {
44-
this.configManager = new ConfigManager()
44+
this.configManager = this.initConfigManager()
4545

4646
this.locale = this.configManager.getLocale()
4747
this.localeManager = setupLocaleManager(this.locale)
@@ -84,6 +84,22 @@ export default class Application extends EventEmitter {
8484
this.emit('application:initialized')
8585
}
8686

87+
initConfigManager () {
88+
this.configListeners = {}
89+
return new ConfigManager()
90+
}
91+
92+
offConfigListeners () {
93+
try {
94+
Object.keys(this.configListeners).forEach((key) => {
95+
this.configListeners[key]()
96+
})
97+
} catch (e) {
98+
logger.warn('[Motrix] offConfigListeners===>', e)
99+
}
100+
this.configListeners = {}
101+
}
102+
87103
setupApplicationMenu () {
88104
this.menuManager = new MenuManager()
89105
this.menuManager.setup(this.locale)
@@ -172,7 +188,9 @@ export default class Application extends EventEmitter {
172188
}
173189

174190
watchTraySpeedometerEnabledChange () {
175-
this.configManager.userConfig.onDidChange('tray-speedometer', async (newValue, oldValue) => {
191+
const { userConfig } = this.configManager
192+
const key = 'tray-speedometer'
193+
this.configListeners[key] = userConfig.onDidChange('tray-speedometer', async (newValue, oldValue) => {
176194
logger.info('[Motrix] detected tray speedometer value change event:', newValue, oldValue)
177195
this.trayManager.handleSpeedometerEnableChange(newValue)
178196
})
@@ -230,10 +248,11 @@ export default class Application extends EventEmitter {
230248
}
231249

232250
watchUPnPPortsChange () {
251+
const { systemConfig } = this.configManager
233252
const watchKeys = ['listen-port', 'dht-listen-port']
234253

235254
watchKeys.forEach((key) => {
236-
this.configManager.systemConfig.onDidChange(key, async (newValue, oldValue) => {
255+
this.configListeners[key] = systemConfig.onDidChange(key, async (newValue, oldValue) => {
237256
logger.info('[Motrix] detected port change event:', key, newValue, oldValue)
238257
const enable = this.configManager.getUserConfig('enable-upnp')
239258
if (!enable) {
@@ -254,7 +273,9 @@ export default class Application extends EventEmitter {
254273
}
255274

256275
watchUPnPEnabledChange () {
257-
this.configManager.userConfig.onDidChange('enable-upnp', async (newValue, oldValue) => {
276+
const { userConfig } = this.configManager
277+
const key = 'enable-upnp'
278+
this.configListeners[key] = userConfig.onDidChange(key, async (newValue, oldValue) => {
258279
logger.info('[Motrix] detected enable-upnp value change event:', newValue, oldValue)
259280
if (newValue) {
260281
this.startUPnPMapping()
@@ -546,12 +567,27 @@ export default class Application extends EventEmitter {
546567
})
547568
}
548569

549-
relaunch () {
550-
this.stop()
570+
async relaunch () {
571+
await this.stop()
551572
app.relaunch()
552573
app.exit()
553574
}
554575

576+
async resetSession () {
577+
await this.stopEngine()
578+
579+
app.clearRecentDocuments()
580+
581+
const sessionPath = this.configManager.getUserConfig('session-path') || getSessionPath()
582+
setTimeout(() => {
583+
unlink(sessionPath, function (err) {
584+
logger.info('[Motrix] Removed the download seesion file:', err)
585+
})
586+
587+
this.engine.start()
588+
}, 3000)
589+
}
590+
555591
savePreference (config = {}) {
556592
logger.info('[Motrix] save preference:', config)
557593
const { system, user } = config
@@ -602,22 +638,10 @@ export default class Application extends EventEmitter {
602638
this.hide(page)
603639
})
604640

605-
this.on('application:reset-session', () => {
606-
this.engine.stop()
607-
608-
app.clearRecentDocuments()
609-
610-
const sessionPath = this.configManager.getUserConfig('session-path') || getSessionPath()
611-
setTimeout(() => {
612-
unlink(sessionPath, function (err) {
613-
logger.info('[Motrix] Removed the download seesion file:', err)
614-
})
615-
616-
this.engine.start()
617-
}, 3000)
618-
})
641+
this.on('application:reset-session', () => this.resetSession())
619642

620643
this.on('application:reset', () => {
644+
this.offConfigListeners()
621645
this.configManager.reset()
622646
this.relaunch()
623647
})

src/main/core/Engine.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ export default class Engine {
3838

3939
const binPath = this.getBinPath()
4040
const args = this.getStartArgs()
41-
this.instance = spawn(binPath, args)
41+
this.instance = spawn(binPath, args, {
42+
windowsHide: false,
43+
stdio: is.dev() ? 'pipe' : 'ignore'
44+
})
4245
const pid = this.instance.pid.toString()
4346
this.writePidFile(pidPath, pid)
4447

src/renderer/components/About/Copyright.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<el-row class="copyright">
33
<el-col :span="6" class="copyright-left">
44
<a target="_blank" rel="noopener noreferrer" href="https://motrix.app/">
5-
&copy;2020 Motrix
5+
&copy;2021 Motrix
66
</a>
77
</el-col>
88
<el-col :span="18" class="copyright-right">

src/renderer/components/Task/TaskItem.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
}
9999
.task-name {
100100
color: #505753;
101-
margin-bottom: 32px;
102-
margin-right: 240px;
101+
margin-bottom: 1.5rem;
102+
margin-right: 220px;
103103
word-break: break-all;
104104
min-height: 26px;
105105
&> span {

src/renderer/components/Task/TaskProgressInfo.vue

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
<template>
22
<el-row class="task-progress-info">
3-
<el-col :span="8" class="task-progress-info-left">
3+
<el-col :span="6" class="task-progress-info-left">
44
<div v-if="task.completedLength > 0 || task.totalLength > 0">
55
<span>{{ task.completedLength | bytesToSize }}</span>
66
<span v-if="task.totalLength > 0"> / {{ task.totalLength | bytesToSize }}</span>
77
</div>
88
</el-col>
9-
<el-col :span="16" class="task-progress-info-right">
9+
<el-col :span="18" class="task-progress-info-right">
1010
<div class="task-speed-info" v-if="isActive">
11-
<span class="task-speed-text" v-if="isBT">
12-
<i><mo-icon name="arrow-up" width="10" height="10" /></i>
13-
<i>{{ task.uploadSpeed | bytesToSize }}/s</i>
14-
</span>
15-
<span class="task-speed-text">
16-
<i><mo-icon name="arrow-down" width="10" height="10" /></i>
17-
<i>{{ task.downloadSpeed | bytesToSize }}/s</i>
18-
</span>
19-
<span class="task-speed-text" v-if="remaining > 0">
20-
{{
21-
remaining | timeFormat({
22-
prefix: $t('task.remaining-prefix'),
23-
i18n: {
24-
'gt1d': $t('app.gt1d'),
25-
'hour': $t('app.hour'),
26-
'minute': $t('app.minute'),
27-
'second': $t('app.second')
28-
}
29-
})
30-
}}
31-
</span>
32-
<span class="task-speed-text" v-if="isBT">
33-
<i><mo-icon name="magnet" width="10" height="10" /></i>
34-
<i>{{ task.numSeeders }}</i>
35-
</span>
36-
<span class="task-speed-text">
37-
<i><mo-icon name="node" width="10" height="10" /></i>
38-
<i>{{ task.connections }}</i>
39-
</span>
11+
<div class="task-speed-text" v-if="isBT">
12+
<i><mo-icon name="arrow-up" width="10" height="14" /></i>
13+
<span>{{ task.uploadSpeed | bytesToSize }}/s</span>
14+
</div>
15+
<div class="task-speed-text">
16+
<i><mo-icon name="arrow-down" width="10" height="14" /></i>
17+
<span>{{ task.downloadSpeed | bytesToSize }}/s</span>
18+
</div>
19+
<div class="task-speed-text" v-if="remaining > 0">
20+
<span>
21+
{{
22+
remaining | timeFormat({
23+
prefix: $t('task.remaining-prefix'),
24+
i18n: {
25+
'gt1d': $t('app.gt1d'),
26+
'hour': $t('app.hour'),
27+
'minute': $t('app.minute'),
28+
'second': $t('app.second')
29+
}
30+
})
31+
}}
32+
</span>
33+
</div>
34+
<div class="task-speed-text" v-if="isBT">
35+
<i><mo-icon name="magnet" width="10" height="14" /></i>
36+
<span>{{ task.numSeeders }}</span>
37+
</div>
38+
<div class="task-speed-text">
39+
<i><mo-icon name="node" width="10" height="14" /></i>
40+
<span>{{ task.connections }}</span>
41+
</div>
4042
</div>
4143
</el-col>
4244
</el-row>
@@ -87,29 +89,46 @@
8789

8890
<style lang="scss">
8991
.task-progress-info {
90-
font-size: 12px;
91-
line-height: 14px;
92-
min-height: 14px;
92+
font-size: 0.75rem;
93+
line-height: 0.875rem;
94+
min-height: 0.875rem;
9395
color: #9B9B9B;
94-
margin-top: 8px;
96+
margin-top: 0.5rem;
9597
i {
9698
font-style: normal;
9799
}
98100
}
99101
.task-progress-info-left {
100-
min-height: 14px;
102+
min-height: 0.875rem;
101103
text-align: left;
102104
}
103105
.task-progress-info-right {
104-
min-height: 14px;
106+
min-height: 0.875rem;
105107
text-align: right;
106108
}
107109
.task-speed-info {
110+
font-size: 0;
108111
& > .task-speed-text {
109-
margin-left: 8px;
110-
& > i {
112+
margin-left: 0.375rem;
113+
font-size: 0;
114+
line-height: 0.875rem;
115+
vertical-align: middle;
116+
display: inline-block;
117+
&:first-of-type {
118+
margin-left: 0;
119+
}
120+
& > i, & > span {
121+
height: 0.875rem;
122+
line-height: 0.875rem;
123+
display: inline-block;
111124
vertical-align: middle;
112125
}
126+
& > i {
127+
margin-right: 0.125rem;
128+
}
129+
& > span {
130+
font-size: 0.75rem;
131+
}
113132
}
114133
}
115134
</style>

src/renderer/components/TaskDetail/TaskActivity.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/>
2626
</div>
2727
</el-col>
28-
<el-col :span="4">
28+
<el-col :span="5">
2929
{{ percent }}
3030
</el-col>
3131
</el-row>

src/renderer/components/TaskDetail/TaskPeers.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<el-table
55
stripe
66
ref="peerTable"
7-
style="width: 100%"
7+
class="mo-peer-table"
88
:data="peers"
99
>
1010
<el-table-column
@@ -16,7 +16,7 @@
1616
</el-table-column>
1717
<el-table-column
1818
:label="`${$t('task.task-peer-client')}: `"
19-
min-width="130">
19+
min-width="125">
2020
<template slot-scope="scope">
2121
{{ scope.row.peerId | peerIdParser }}
2222
</template>
@@ -32,15 +32,15 @@
3232
<el-table-column
3333
:label="`↑`"
3434
align="right"
35-
width="95">
35+
width="90">
3636
<template slot-scope="scope">
3737
{{ scope.row.uploadSpeed | bytesToSize }}/s
3838
</template>
3939
</el-table-column>
4040
<el-table-column
4141
:label="`↓`"
4242
align="right"
43-
width="95">
43+
width="90">
4444
<template slot-scope="scope">
4545
{{ scope.row.downloadSpeed | bytesToSize }}/s
4646
</template>
@@ -74,3 +74,10 @@
7474
}
7575
}
7676
</script>
77+
78+
<style lang="scss">
79+
.el-table.mo-peer-table .cell {
80+
padding-left: 0.5rem;
81+
padding-right: 0.5rem;
82+
}
83+
</style>

src/renderer/components/Theme/Default.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ iframe {
271271
line-height: 0;
272272
border: 1px solid $--task-detail-box-border;
273273
border-radius: $--border-radius-base;
274+
box-sizing: content-box;
274275
}
275276

276277
.form-static-value {

0 commit comments

Comments
 (0)