修复备份与恢复功能在恢复数据时某些设置不立即生效的问题

This commit is contained in:
lyswhut
2021-03-12 16:22:22 +08:00
parent 68d8369a8b
commit 08d0758616
15 changed files with 71 additions and 44 deletions
+4 -4
View File
@@ -25,7 +25,7 @@ import { mapMutations, mapGetters, mapActions } from 'vuex'
import { rendererOn, rendererSend, rendererInvoke, NAMES } from '../common/ipc'
import { isLinux } from '../common/utils'
import music from './utils/music'
import { throttle, openUrl, compareVer, getPlayList, parseUrlParams } from './utils'
import { throttle, openUrl, compareVer, getPlayList, parseUrlParams, saveSetting } from './utils'
import { base as eventBaseName } from './event/names'
import apiSourceInfo from './utils/music/api-source-info'
@@ -113,7 +113,7 @@ export default {
watch: {
setting: {
handler(n, o) {
rendererSend(NAMES.mainWindow.set_app_setting, n)
saveSetting(n)
},
deep: true,
},
@@ -246,7 +246,7 @@ export default {
})
rendererOn(NAMES.mainWindow.set_config, (event, config) => {
// console.log(config)
console.log(config)
// this.setDesktopLyricConfig(config)
// console.log('set_config', JSON.stringify(this.setting) === JSON.stringify(config))
this.setSetting(Object.assign({}, this.setting, config))
@@ -355,7 +355,7 @@ export default {
if (info.listId) {
const list = window.allList[info.listId]
// console.log(list)
if (!list) return
if (!list || !list.list[info.index]) return
info.list = list.list
}
@@ -62,7 +62,7 @@ import { openUrl } from '../../utils'
export default {
data() {
return {
time: 20,
time: 5,
globalObj: {
isShowPact: false,
},
+1 -1
View File
@@ -379,7 +379,7 @@ export const getProxyInfo = () => window.globalObj.proxy.enable
export const assertApiSupport = source => window.globalObj.qualityList[source] != undefined
export const getSetting = () => rendererInvoke(NAMES.mainWindow.get_setting)
export const saveSetting = () => rendererInvoke(NAMES.mainWindow.set_app_setting)
export const saveSetting = setting => rendererInvoke(NAMES.mainWindow.set_app_setting, setting)
export const getPlayList = () => rendererInvoke(NAMES.mainWindow.get_playlist).catch(error => {
rendererInvoke(NAMES.mainWindow.get_data_path).then(dataPath => {
+19 -4
View File
@@ -279,6 +279,8 @@ import {
clearCache,
sizeFormate,
setWindowSize,
getSetting,
saveSetting,
} from '../utils'
import { rendererSend, rendererInvoke, NAMES } from '@common/ipc'
import { mergeSetting, isMac } from '../../common/utils'
@@ -289,6 +291,7 @@ import { base as eventBaseName } from '../event/names'
import * as hotKeys from '../../common/hotKey'
import { mainWindow as eventsNameMainWindow, winLyric as eventsNameWinLyric } from '../../main/events/_name'
import { gzip, gunzip } from 'zlib'
import music from '../utils/music'
let hotKeyTargetInput
let newHotKey
@@ -748,6 +751,8 @@ export default {
if (list.location == null) list.location = 0
this.setList(list)
}
await this.refreshSetting(this.setting, this.settingVersion)
},
exportPlayList(path) {
const data = JSON.parse(JSON.stringify({
@@ -773,9 +778,6 @@ export default {
return
}
if (allData.type !== 'allData') return
const { version: settingVersion, setting } = mergeSetting(allData.setting)
setting.isAgreePact = false
this.refreshSetting(setting, settingVersion)
// 兼容0.6.2及以前版本的列表数据
if (allData.defaultList) return this.setList({ id: 'default', list: allData.defaultList.list, name: '试听列表', location: 0 })
@@ -784,6 +786,11 @@ export default {
if (list.location == null) list.location = 0
this.setList(list)
}
const { version: settingVersion, setting } = mergeSetting(allData.setting)
setting.isAgreePact = false
await this.refreshSetting(setting, settingVersion)
},
async exportAllData(path) {
let allData = JSON.parse(JSON.stringify({
@@ -906,10 +913,18 @@ export default {
let info = index == null ? this.windowSizeList[2] : this.windowSizeList[index]
setWindowSize(info.width, info.height)
},
refreshSetting(setting, version) {
async refreshSetting(newSetting, newVersion) {
await saveSetting(newSetting)
const { setting, version } = await getSetting()
this.setSetting(setting)
this.setSettingVersion(version)
if (setting.windowSizeId != null) this.handleWindowSizeChange(null, setting.windowSizeId)
window.globalObj.apiSource = setting.apiSource
if (/^user_api/.test(setting.apiSource)) {
rendererInvoke(NAMES.mainWindow.set_user_api, setting.apiSource)
} else {
window.globalObj.qualityList = music.supportQuality[setting.apiSource]
}
for (let key of Object.keys(setting.network.proxy)) {
window.globalObj.proxy[key] = setting.network.proxy[key]
}