Compare commits

..

8 Commits

Author SHA1 Message Date
Dr_rOot 3aa18e7f72 fix: revert mac target 2021-05-07 19:19:10 +08:00
Dr_rOot e939f9e5dc Merge pull request #925 from agalwood/hotfix/app_hang_20210507 2021-05-07 16:40:04 +08:00
Dr_rOot 53ec0b1dee chore: update deps 2021-05-07 14:11:34 +08:00
Dr_rOot fcfd32a71e refactor: task detail style 2021-05-07 14:06:35 +08:00
Dr_rOot 2ff56a3770 refactor: task item style 2021-05-07 14:06:28 +08:00
Dr_rOot 48768f0658 fix: copyright year 2021-05-07 14:03:32 +08:00
Dr_rOot 3e84230b33 fix: app reset engine not start 2021-05-07 14:03:13 +08:00
Dr_rOot 5490946267 fix: app hang caused by child_process spawn
https://github.com/electron/electron/issues/24329#issuecomment-760699187
2021-05-07 14:02:48 +08:00
10 changed files with 146 additions and 93 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "Motrix",
"version": "1.6.8",
"version": "1.6.9",
"description": "A full-featured download manager",
"homepage": "https://motrix.app",
"author": {
@@ -240,7 +240,7 @@
"css-loader": "^5.2.4",
"css-minimizer-webpack-plugin": "^2.0.0",
"del": "^6.0.0",
"electron": "^11.4.4",
"electron": "^11.4.5",
"electron-builder": "22.10.5",
"electron-builder-notarize": "^1.2.0",
"electron-devtools-installer": "^3.2.0",
@@ -266,7 +266,7 @@
"vue-style-loader": "^4.1.3",
"vue-template-compiler": "^2.6.12",
"webpack": "^5.36.2",
"webpack-cli": "^4.6.0",
"webpack-cli": "^4.7.0",
"webpack-dev-server": "^3.11.2",
"webpack-hot-middleware": "^2.25.0",
"webpack-merge": "^5.7.3",
+44 -20
View File
@@ -41,7 +41,7 @@ export default class Application extends EventEmitter {
}
init () {
this.configManager = new ConfigManager()
this.configManager = this.initConfigManager()
this.locale = this.configManager.getLocale()
this.localeManager = setupLocaleManager(this.locale)
@@ -84,6 +84,22 @@ export default class Application extends EventEmitter {
this.emit('application:initialized')
}
initConfigManager () {
this.configListeners = {}
return new ConfigManager()
}
offConfigListeners () {
try {
Object.keys(this.configListeners).forEach((key) => {
this.configListeners[key]()
})
} catch (e) {
logger.warn('[Motrix] offConfigListeners===>', e)
}
this.configListeners = {}
}
setupApplicationMenu () {
this.menuManager = new MenuManager()
this.menuManager.setup(this.locale)
@@ -172,7 +188,9 @@ export default class Application extends EventEmitter {
}
watchTraySpeedometerEnabledChange () {
this.configManager.userConfig.onDidChange('tray-speedometer', async (newValue, oldValue) => {
const { userConfig } = this.configManager
const key = 'tray-speedometer'
this.configListeners[key] = userConfig.onDidChange('tray-speedometer', async (newValue, oldValue) => {
logger.info('[Motrix] detected tray speedometer value change event:', newValue, oldValue)
this.trayManager.handleSpeedometerEnableChange(newValue)
})
@@ -230,10 +248,11 @@ export default class Application extends EventEmitter {
}
watchUPnPPortsChange () {
const { systemConfig } = this.configManager
const watchKeys = ['listen-port', 'dht-listen-port']
watchKeys.forEach((key) => {
this.configManager.systemConfig.onDidChange(key, async (newValue, oldValue) => {
this.configListeners[key] = systemConfig.onDidChange(key, async (newValue, oldValue) => {
logger.info('[Motrix] detected port change event:', key, newValue, oldValue)
const enable = this.configManager.getUserConfig('enable-upnp')
if (!enable) {
@@ -254,7 +273,9 @@ export default class Application extends EventEmitter {
}
watchUPnPEnabledChange () {
this.configManager.userConfig.onDidChange('enable-upnp', async (newValue, oldValue) => {
const { userConfig } = this.configManager
const key = 'enable-upnp'
this.configListeners[key] = userConfig.onDidChange(key, async (newValue, oldValue) => {
logger.info('[Motrix] detected enable-upnp value change event:', newValue, oldValue)
if (newValue) {
this.startUPnPMapping()
@@ -546,12 +567,27 @@ export default class Application extends EventEmitter {
})
}
relaunch () {
this.stop()
async relaunch () {
await this.stop()
app.relaunch()
app.exit()
}
async resetSession () {
await this.stopEngine()
app.clearRecentDocuments()
const sessionPath = this.configManager.getUserConfig('session-path') || getSessionPath()
setTimeout(() => {
unlink(sessionPath, function (err) {
logger.info('[Motrix] Removed the download seesion file:', err)
})
this.engine.start()
}, 3000)
}
savePreference (config = {}) {
logger.info('[Motrix] save preference:', config)
const { system, user } = config
@@ -602,22 +638,10 @@ export default class Application extends EventEmitter {
this.hide(page)
})
this.on('application:reset-session', () => {
this.engine.stop()
app.clearRecentDocuments()
const sessionPath = this.configManager.getUserConfig('session-path') || getSessionPath()
setTimeout(() => {
unlink(sessionPath, function (err) {
logger.info('[Motrix] Removed the download seesion file:', err)
})
this.engine.start()
}, 3000)
})
this.on('application:reset-session', () => this.resetSession())
this.on('application:reset', () => {
this.offConfigListeners()
this.configManager.reset()
this.relaunch()
})
+4 -1
View File
@@ -38,7 +38,10 @@ export default class Engine {
const binPath = this.getBinPath()
const args = this.getStartArgs()
this.instance = spawn(binPath, args)
this.instance = spawn(binPath, args, {
windowsHide: false,
stdio: is.dev() ? 'pipe' : 'ignore'
})
const pid = this.instance.pid.toString()
this.writePidFile(pidPath, pid)
+1 -1
View File
@@ -2,7 +2,7 @@
<el-row class="copyright">
<el-col :span="6" class="copyright-left">
<a target="_blank" rel="noopener noreferrer" href="https://motrix.app/">
&copy;2020 Motrix
&copy;2021 Motrix
</a>
</el-col>
<el-col :span="18" class="copyright-right">
+2 -2
View File
@@ -98,8 +98,8 @@
}
.task-name {
color: #505753;
margin-bottom: 32px;
margin-right: 240px;
margin-bottom: 1.5rem;
margin-right: 220px;
word-break: break-all;
min-height: 26px;
&> span {
@@ -1,42 +1,44 @@
<template>
<el-row class="task-progress-info">
<el-col :span="8" class="task-progress-info-left">
<el-col :span="6" class="task-progress-info-left">
<div v-if="task.completedLength > 0 || task.totalLength > 0">
<span>{{ task.completedLength | bytesToSize }}</span>
<span v-if="task.totalLength > 0"> / {{ task.totalLength | bytesToSize }}</span>
</div>
</el-col>
<el-col :span="16" class="task-progress-info-right">
<el-col :span="18" class="task-progress-info-right">
<div class="task-speed-info" v-if="isActive">
<span class="task-speed-text" v-if="isBT">
<i><mo-icon name="arrow-up" width="10" height="10" /></i>
<i>{{ task.uploadSpeed | bytesToSize }}/s</i>
</span>
<span class="task-speed-text">
<i><mo-icon name="arrow-down" width="10" height="10" /></i>
<i>{{ task.downloadSpeed | bytesToSize }}/s</i>
</span>
<span class="task-speed-text" v-if="remaining > 0">
{{
remaining | timeFormat({
prefix: $t('task.remaining-prefix'),
i18n: {
'gt1d': $t('app.gt1d'),
'hour': $t('app.hour'),
'minute': $t('app.minute'),
'second': $t('app.second')
}
})
}}
</span>
<span class="task-speed-text" v-if="isBT">
<i><mo-icon name="magnet" width="10" height="10" /></i>
<i>{{ task.numSeeders }}</i>
</span>
<span class="task-speed-text">
<i><mo-icon name="node" width="10" height="10" /></i>
<i>{{ task.connections }}</i>
</span>
<div class="task-speed-text" v-if="isBT">
<i><mo-icon name="arrow-up" width="10" height="14" /></i>
<span>{{ task.uploadSpeed | bytesToSize }}/s</span>
</div>
<div class="task-speed-text">
<i><mo-icon name="arrow-down" width="10" height="14" /></i>
<span>{{ task.downloadSpeed | bytesToSize }}/s</span>
</div>
<div class="task-speed-text" v-if="remaining > 0">
<span>
{{
remaining | timeFormat({
prefix: $t('task.remaining-prefix'),
i18n: {
'gt1d': $t('app.gt1d'),
'hour': $t('app.hour'),
'minute': $t('app.minute'),
'second': $t('app.second')
}
})
}}
</span>
</div>
<div class="task-speed-text" v-if="isBT">
<i><mo-icon name="magnet" width="10" height="14" /></i>
<span>{{ task.numSeeders }}</span>
</div>
<div class="task-speed-text">
<i><mo-icon name="node" width="10" height="14" /></i>
<span>{{ task.connections }}</span>
</div>
</div>
</el-col>
</el-row>
@@ -87,29 +89,46 @@
<style lang="scss">
.task-progress-info {
font-size: 12px;
line-height: 14px;
min-height: 14px;
font-size: 0.75rem;
line-height: 0.875rem;
min-height: 0.875rem;
color: #9B9B9B;
margin-top: 8px;
margin-top: 0.5rem;
i {
font-style: normal;
}
}
.task-progress-info-left {
min-height: 14px;
min-height: 0.875rem;
text-align: left;
}
.task-progress-info-right {
min-height: 14px;
min-height: 0.875rem;
text-align: right;
}
.task-speed-info {
font-size: 0;
& > .task-speed-text {
margin-left: 8px;
& > i {
margin-left: 0.375rem;
font-size: 0;
line-height: 0.875rem;
vertical-align: middle;
display: inline-block;
&:first-of-type {
margin-left: 0;
}
& > i, & > span {
height: 0.875rem;
line-height: 0.875rem;
display: inline-block;
vertical-align: middle;
}
& > i {
margin-right: 0.125rem;
}
& > span {
font-size: 0.75rem;
}
}
}
</style>
@@ -25,7 +25,7 @@
/>
</div>
</el-col>
<el-col :span="4">
<el-col :span="5">
{{ percent }}
</el-col>
</el-row>
@@ -4,7 +4,7 @@
<el-table
stripe
ref="peerTable"
style="width: 100%"
class="mo-peer-table"
:data="peers"
>
<el-table-column
@@ -16,7 +16,7 @@
</el-table-column>
<el-table-column
:label="`${$t('task.task-peer-client')}: `"
min-width="130">
min-width="125">
<template slot-scope="scope">
{{ scope.row.peerId | peerIdParser }}
</template>
@@ -32,7 +32,7 @@
<el-table-column
:label="`↑`"
align="right"
width="95">
width="90">
<template slot-scope="scope">
{{ scope.row.uploadSpeed | bytesToSize }}/s
</template>
@@ -40,7 +40,7 @@
<el-table-column
:label="`↓`"
align="right"
width="95">
width="90">
<template slot-scope="scope">
{{ scope.row.downloadSpeed | bytesToSize }}/s
</template>
@@ -74,3 +74,10 @@
}
}
</script>
<style lang="scss">
.el-table.mo-peer-table .cell {
padding-left: 0.5rem;
padding-right: 0.5rem;
}
</style>
@@ -271,6 +271,7 @@ iframe {
line-height: 0;
border: 1px solid $--task-detail-box-border;
border-radius: $--border-radius-base;
box-sizing: content-box;
}
.form-static-value {
+21 -22
View File
@@ -1312,22 +1312,22 @@
"@webassemblyjs/ast" "1.11.0"
"@xtuc/long" "4.2.2"
"@webpack-cli/configtest@^1.0.2":
version "1.0.2"
resolved "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.0.2.tgz#2a20812bfb3a2ebb0b27ee26a52eeb3e3f000836"
integrity sha512-3OBzV2fBGZ5TBfdW50cha1lHDVf9vlvRXnjpVbJBa20pSZQaSkMJZiwA8V2vD9ogyeXn8nU5s5A6mHyf5jhMzA==
"@webpack-cli/configtest@^1.0.3":
version "1.0.3"
resolved "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.0.3.tgz#204bcff87cda3ea4810881f7ea96e5f5321b87b9"
integrity sha512-WQs0ep98FXX2XBAfQpRbY0Ma6ADw8JR6xoIkaIiJIzClGOMqVRvPCWqndTxf28DgFopWan0EKtHtg/5W1h0Zkw==
"@webpack-cli/info@^1.2.3":
version "1.2.3"
resolved "https://registry.npmjs.org/@webpack-cli/info/-/info-1.2.3.tgz#ef819d10ace2976b6d134c7c823a3e79ee31a92c"
integrity sha512-lLek3/T7u40lTqzCGpC6CAbY6+vXhdhmwFRxZLMnRm6/sIF/7qMpT8MocXCRQfz0JAh63wpbXLMnsQ5162WS7Q==
"@webpack-cli/info@^1.2.4":
version "1.2.4"
resolved "https://registry.npmjs.org/@webpack-cli/info/-/info-1.2.4.tgz#7381fd41c9577b2d8f6c2594fad397ef49ad5573"
integrity sha512-ogE2T4+pLhTTPS/8MM3IjHn0IYplKM4HbVNMCWA9N4NrdPzunwenpCsqKEXyejMfRu6K8mhauIPYf8ZxWG5O6g==
dependencies:
envinfo "^7.7.3"
"@webpack-cli/serve@^1.3.1":
version "1.3.1"
resolved "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.3.1.tgz#911d1b3ff4a843304b9c3bacf67bb34672418441"
integrity sha512-0qXvpeYO6vaNoRBI52/UsbcaBydJCggoBBnIo/ovQQdn6fug0BgwsjorV1hVS7fMqGVTZGcVxv8334gjmbj5hw==
"@webpack-cli/serve@^1.4.0":
version "1.4.0"
resolved "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.4.0.tgz#f84fd07bcacefe56ce762925798871092f0f228e"
integrity sha512-xgT/HqJ+uLWGX+Mzufusl3cgjAcnqYYskaB7o0vRcwOEfuu6hMzSILQpnIzFMGsTaeaX4Nnekl+6fadLbl1/Vg==
"@xtuc/ieee754@^1.2.0":
version "1.2.0"
@@ -3541,7 +3541,7 @@ electron-updater@^4.3.8:
lodash.isequal "^4.5.0"
semver "^7.3.4"
electron@^11.4.4:
electron@^11.4.5:
version "11.4.5"
resolved "https://registry.npmjs.org/electron/-/electron-11.4.5.tgz#71ffeb8be8d04bddcd165ed8460867d6e6a4a396"
integrity sha512-F1s70t8ZVU7PuXuP7wxbF5muOIRulWvzRAE8MiD5PTomaOar5+I+eR3jD20bs13Z5GdyOQu148WQt8r9h+ALTA==
@@ -3619,7 +3619,7 @@ enhanced-resolve@^5.8.0:
graceful-fs "^4.2.4"
tapable "^2.2.0"
enquirer@^2.3.5, enquirer@^2.3.6:
enquirer@^2.3.5:
version "2.3.6"
resolved "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d"
integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==
@@ -8871,18 +8871,17 @@ wbuf@^1.1.0, wbuf@^1.7.3:
dependencies:
minimalistic-assert "^1.0.0"
webpack-cli@^4.6.0:
version "4.6.0"
resolved "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.6.0.tgz#27ae86bfaec0cf393fcfd58abdc5a229ad32fd16"
integrity sha512-9YV+qTcGMjQFiY7Nb1kmnupvb1x40lfpj8pwdO/bom+sQiP4OBMKjHq29YQrlDWDPZO9r/qWaRRywKaRDKqBTA==
webpack-cli@^4.7.0:
version "4.7.0"
resolved "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.7.0.tgz#3195a777f1f802ecda732f6c95d24c0004bc5a35"
integrity sha512-7bKr9182/sGfjFm+xdZSwgQuFjgEcy0iCTIBxRUeteJ2Kr8/Wz0qNJX+jw60LU36jApt4nmMkep6+W5AKhok6g==
dependencies:
"@discoveryjs/json-ext" "^0.5.0"
"@webpack-cli/configtest" "^1.0.2"
"@webpack-cli/info" "^1.2.3"
"@webpack-cli/serve" "^1.3.1"
"@webpack-cli/configtest" "^1.0.3"
"@webpack-cli/info" "^1.2.4"
"@webpack-cli/serve" "^1.4.0"
colorette "^1.2.1"
commander "^7.0.0"
enquirer "^2.3.6"
execa "^5.0.0"
fastest-levenshtein "^1.0.12"
import-local "^3.0.2"