From c6a9eb226d4656a24b44851bf990ab84c65f4113 Mon Sep 17 00:00:00 2001 From: Dr_rOot Date: Tue, 11 May 2021 15:18:21 +0800 Subject: [PATCH 1/5] fix: auto update exception --- src/main/Application.js | 3 ++- src/main/core/UpdateManager.js | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/Application.js b/src/main/Application.js index 829fa5d42..2c0d256f2 100644 --- a/src/main/Application.js +++ b/src/main/Application.js @@ -557,8 +557,9 @@ export default class Application extends EventEmitter { win.setProgressBar(0) }) - this.updateManager.on('will-updated', (event) => { + this.updateManager.on('will-updated', async (event) => { this.windowManager.setWillQuit(true) + await this.stop() }) this.updateManager.on('update-error', (event) => { diff --git a/src/main/core/UpdateManager.js b/src/main/core/UpdateManager.js index d07664d58..75dd8ca76 100644 --- a/src/main/core/UpdateManager.js +++ b/src/main/core/UpdateManager.js @@ -17,8 +17,10 @@ export default class UpdateManager extends EventEmitter { this.options = options this.i18n = getI18n() + this.isChecking = false this.updater = autoUpdater this.updater.autoDownload = false + this.updater.autoInstallOnAppQuit = false this.updater.logger = logger this.autoCheckData = { checkEnable: this.options.autoCheck, @@ -40,9 +42,10 @@ export default class UpdateManager extends EventEmitter { this.updater.on('update-not-available', this.updateNotAvailable.bind(this)) this.updater.on('download-progress', this.updateDownloadProgress.bind(this)) this.updater.on('update-downloaded', this.updateDownloaded.bind(this)) + this.updater.on('update-cancelled', this.updateCancelled.bind(this)) this.updater.on('error', this.updateError.bind(this)) - if (this.autoCheckData.checkEnable) { + if (this.autoCheckData.checkEnable && !this.isChecking) { this.autoCheckData.userCheck = false this.updater.checkForUpdates() } @@ -54,6 +57,7 @@ export default class UpdateManager extends EventEmitter { } checkingForUpdate () { + this.isChecking = true this.emit('checking') } @@ -73,6 +77,7 @@ export default class UpdateManager extends EventEmitter { } updateNotAvailable (event, info) { + this.isChecking = false this.emit('update-not-available', info) if (this.autoCheckData.userCheck) { dialog.showMessageBox({ @@ -102,20 +107,26 @@ export default class UpdateManager extends EventEmitter { title: this.i18n.t('app.check-for-updates-title'), message: this.i18n.t('app.update-downloaded-message') }).then(_ => { + this.isChecking = false this.emit('will-updated') - setImmediate(() => { + setTimeout(() => { this.updater.quitAndInstall() - }) + }, 200) }) } + updateCancelled () { + this.isChecking = false + } + updateError (event, error) { + this.isChecking = false this.emit('update-error', error) const msg = (error == null) - ? this.i18n.t('update-error-message') + ? this.i18n.t('app.update-error-message') : (error.stack || error).toString() this.updater.logger.warn(`[Motrix] update-error: ${msg}`) - dialog.showErrorBox(msg) + dialog.showErrorBox('Error', msg) } } From 87635ade345a55003ef95a0f8a018ef57ad26aa8 Mon Sep 17 00:00:00 2001 From: Dr_rOot Date: Wed, 12 May 2021 11:24:15 +0800 Subject: [PATCH 2/5] fix: auto theme --- src/main/Application.js | 2 +- src/main/ui/ThemeManager.js | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main/Application.js b/src/main/Application.js index 2c0d256f2..b670296bc 100644 --- a/src/main/Application.js +++ b/src/main/Application.js @@ -652,7 +652,7 @@ export default class Application extends EventEmitter { }) this.on('application:change-theme', (theme) => { - this.themeManager.updateAppAppearance(theme) + this.themeManager.updateSystemTheme(theme) this.sendCommandToAll('application:update-theme', { theme }) }) diff --git a/src/main/ui/ThemeManager.js b/src/main/ui/ThemeManager.js index ac92f7d6f..b77dbc43f 100644 --- a/src/main/ui/ThemeManager.js +++ b/src/main/ui/ThemeManager.js @@ -1,8 +1,9 @@ import { EventEmitter } from 'events' -import { nativeTheme, systemPreferences } from 'electron' +import { nativeTheme } from 'electron' import is from 'electron-is' import { APP_THEME } from '@shared/constants' +import logger from '../core/Logger' import { getSystemTheme } from '../utils' export default class ThemeManager extends EventEmitter { @@ -31,19 +32,13 @@ export default class ThemeManager extends EventEmitter { nativeTheme.on('updated', () => { const theme = getSystemTheme() this.systemTheme = theme - console.log('nativeTheme updated===>', theme) + logger.info('[Motrix] nativeTheme updated===>', theme) this.emit('system-theme-change', theme) }) } - /** - * deprecated - * @see https://www.electronjs.org/docs/all#systempreferencessetapplevelappearanceappearance-macos-deprecated - */ - updateAppAppearance (theme) { - if (!is.macOS() || theme !== APP_THEME.LIGHT || theme !== APP_THEME.DARK) { - return - } - systemPreferences.setAppLevelAppearance(theme) + updateSystemTheme (theme) { + theme = theme === APP_THEME.AUTO ? 'system' : theme + nativeTheme.themeSource = theme } } From bffe919b93b240e88b325f157fcdae7314ad9e68 Mon Sep 17 00:00:00 2001 From: Dr_rOot Date: Wed, 12 May 2021 11:24:51 +0800 Subject: [PATCH 3/5] fix: add one task triggered rename rule --- src/shared/utils/rename.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shared/utils/rename.js b/src/shared/utils/rename.js index 3525e8402..b48d79d3b 100644 --- a/src/shared/utils/rename.js +++ b/src/shared/utils/rename.js @@ -49,6 +49,10 @@ export const buildOuts = (uris = [], out = '') => { return result } + if (count === 1) { + return [out] + } + const ruleStr = getRuleString(out) if (!ruleStr) { return result From 1b44ef725bd5633aa8df9424f99f2121ec66284b Mon Sep 17 00:00:00 2001 From: Dr_rOot Date: Wed, 12 May 2021 11:47:18 +0800 Subject: [PATCH 4/5] fix: task detail not auto hide when remove task --- src/renderer/store/modules/task.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/renderer/store/modules/task.js b/src/renderer/store/modules/task.js index 99ad39d25..ded76ae7e 100644 --- a/src/renderer/store/modules/task.js +++ b/src/renderer/store/modules/task.js @@ -148,8 +148,12 @@ const actions = { const { gid, options } = payload return api.changeOption({ gid, options }) }, - removeTask ({ dispatch }, task) { + removeTask ({ state, dispatch }, task) { const { gid } = task + if (gid === state.currentTaskGid) { + dispatch('hideTaskDetail') + } + return api.removeTask({ gid }) .finally(() => { dispatch('fetchList') @@ -231,8 +235,12 @@ const actions = { } return dispatch('changeTaskOption', { gid, options }) }, - removeTaskRecord ({ dispatch }, task) { + removeTaskRecord ({ state, dispatch }, task) { const { gid, status } = task + if (gid === state.currentTaskGid) { + dispatch('hideTaskDetail') + } + const { ERROR, COMPLETE, REMOVED } = TASK_STATUS if ([ERROR, COMPLETE, REMOVED].indexOf(status) === -1) { return From c257816608af99b71cfa418cc4c5ec6906a68e30 Mon Sep 17 00:00:00 2001 From: Dr_rOot Date: Wed, 12 May 2021 22:32:53 +0800 Subject: [PATCH 5/5] fix: element ui message z-index --- src/renderer/components/Theme/Default.scss | 1 + src/renderer/components/Theme/Variables.scss | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/Theme/Default.scss b/src/renderer/components/Theme/Default.scss index e6ce3cde9..ccdc66002 100644 --- a/src/renderer/components/Theme/Default.scss +++ b/src/renderer/components/Theme/Default.scss @@ -9,6 +9,7 @@ body { BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif; font-variant: tabular-nums; + font-size: $--font-size-medium; } ::-webkit-scrollbar { diff --git a/src/renderer/components/Theme/Variables.scss b/src/renderer/components/Theme/Variables.scss index 2f381abac..d11d32d4a 100644 --- a/src/renderer/components/Theme/Variables.scss +++ b/src/renderer/components/Theme/Variables.scss @@ -133,7 +133,7 @@ $--size-base: 14px !default; -------------------------- */ $--index-normal: 1 !default; $--index-top: 1000 !default; -$--index-popper: 2000 !default; +$--index-popper: 2100 !default; /* Disable base -------------------------- */