A full-featured download manager.
fix: check changed preferences is need restart
Dr_rOot35df1c799b55
diff --git a/src/renderer/components/Preference/Advanced.vue b/src/renderer/components/Preference/Advanced.vueindex 8809806a..5f014894 100644--- a/src/renderer/components/Preference/Advanced.vue+++ b/src/renderer/components/Preference/Advanced.vue@@ -183,6 +183,7 @@import {buildRpcUrl,calcFormLabelWidth,+ checkIsNeedRestart,convertCommaToLine,convertLineToComma,diffConfig@@ -353,6 +354,10 @@if (this.isRenderer()) {this.$electron.ipcRenderer.send('command', 'application:setup-protocols-client', data.protocols)++ if (checkIsNeedRestart(changed)) {+ this.$electron.ipcRenderer.send('command', 'application:relaunch')+ }}})},diff --git a/src/renderer/components/Preference/Basic.vue b/src/renderer/components/Preference/Basic.vueindex feb934bf..9cafc9b4 100644--- a/src/renderer/components/Preference/Basic.vue+++ b/src/renderer/components/Preference/Basic.vue@@ -151,7 +151,11 @@import { availableLanguages, getLanguage } from '@shared/locales'import { getLocaleManager } from '@/components/Locale'import { prettifyDir } from '@/components/Native/utils'- import { calcFormLabelWidth, diffConfig } from '@shared/utils'+ import {+ calcFormLabelWidth,+ diffConfig,+ checkIsNeedRestart+ } from '@shared/utils'const initialForm = (config) => {const {@@ -292,6 +296,10 @@if (this.isRenderer()) {this.$electron.ipcRenderer.send('command', 'application:open-at-login', openAtLogin)++ if (checkIsNeedRestart(changed)) {+ this.$electron.ipcRenderer.send('command', 'application:relaunch')+ }}})},diff --git a/src/shared/configKeys.js b/src/shared/configKeys.jsindex 59b33ae0..8e670aed 100644--- a/src/shared/configKeys.js+++ b/src/shared/configKeys.js@@ -134,7 +134,12 @@ const systemKeys = ['user-agent']+const needRestartKeys = [+ 'hide-app-menu'+]+export {userKeys,- systemKeys+ systemKeys,+ needRestartKeys}diff --git a/src/shared/utils.js b/src/shared/utils.jsindex ef0523c4..b7121dbe 100644--- a/src/shared/utils.js+++ b/src/shared/utils.js@@ -12,7 +12,7 @@ import {pick} from 'lodash'import { resolve } from 'path'-import { userKeys, systemKeys } from './configKeys'+import { userKeys, systemKeys, needRestartKeys } from './configKeys'export function bytesToSize (bytes) {const b = parseInt(bytes, 10)@@ -571,3 +571,21 @@ export function buildRpcUrl (options) {return result}++export function checkIsNeedRestart (changed = {}) {+ let result = false++ if (isEmpty(changed)) {+ return result+ }++ const kebabCaseChanged = changeKeysToKebabCase(changed)+ needRestartKeys.some((key) => {+ if (kebabCaseChanged.hasOwnProperty(key)) {+ result = true+ return true+ }+ })++ return result+}