修复备份与恢复功能在恢复数据时某些设置不立即生效的问题
parent
68d8369a8b
commit
08d0758616
|
@ -1,4 +1,4 @@
|
|||
### 修复
|
||||
|
||||
- 修复歌曲ID存储变更导致酷狗图片获取失败的问题
|
||||
- 修复收藏的在线列表id迁移保存出错的问题
|
||||
- 修复备份与恢复功能在恢复数据时某些设置不立即生效的问题
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ const { common: COMMON_EVENT_NAME, mainWindow: MAIN_WINDOW_EVENT_NAME } = requir
|
|||
const { mainSend, NAMES: { mainWindow: ipcMainWindowNames } } = require('./../common/ipc')
|
||||
const { getAppHotKeyConfig } = require('./utils')
|
||||
|
||||
global.lx_event.common.on(COMMON_EVENT_NAME.config, name => {
|
||||
global.lx_event.common.on(COMMON_EVENT_NAME.configStatus, name => {
|
||||
if (MAIN_WINDOW_EVENT_NAME.name === name) return
|
||||
if (global.modules.mainWindow) mainSend(global.modules.mainWindow, ipcMainWindowNames.set_config, global.appSetting)
|
||||
})
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
const { EventEmitter } = require('events')
|
||||
const { common: COMMON_EVENT_NAME } = require('./_name')
|
||||
const { updateSetting } = require('../utils')
|
||||
|
||||
class Common extends EventEmitter {
|
||||
initSetting() {
|
||||
this.emit(COMMON_EVENT_NAME.initConfig)
|
||||
this.emit(COMMON_EVENT_NAME.config, null)
|
||||
this.configStatus(null)
|
||||
}
|
||||
|
||||
setAppConfig(config, name) {
|
||||
if (config) updateSetting(config)
|
||||
this.emit(COMMON_EVENT_NAME.config, name)
|
||||
configStatus(name) {
|
||||
this.emit(COMMON_EVENT_NAME.configStatus, name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
exports.common = {
|
||||
initConfig: 'initConfig',
|
||||
config: 'config',
|
||||
configStatus: 'config',
|
||||
}
|
||||
|
||||
exports.mainWindow = {
|
||||
|
|
|
@ -34,8 +34,8 @@ app.commandLine.appendSwitch('wm-window-animations-disabled')
|
|||
|
||||
|
||||
const { navigationUrlWhiteList } = require('../common/config')
|
||||
const { getWindowSizeInfo } = require('./utils')
|
||||
const { isMac, isLinux, initSetting, initHotKey } = require('../common/utils')
|
||||
const { getWindowSizeInfo, initSetting, updateSetting } = require('./utils')
|
||||
const { isMac, isLinux, initHotKey } = require('../common/utils')
|
||||
|
||||
|
||||
// https://github.com/electron/electron/issues/18397
|
||||
|
@ -130,11 +130,16 @@ global.appHotKey = {
|
|||
state: null,
|
||||
}
|
||||
|
||||
global.lx_core = {
|
||||
setAppConfig(setting, name) {
|
||||
updateSetting(setting)
|
||||
global.lx_event.common.configStatus(name)
|
||||
},
|
||||
}
|
||||
|
||||
function init() {
|
||||
console.log('init')
|
||||
const info = initSetting()
|
||||
global.appSetting = info.setting
|
||||
global.appSettingVersion = info.version
|
||||
initSetting()
|
||||
global.appHotKey.config = initHotKey()
|
||||
global.lx_event.common.initSetting()
|
||||
global.lx_event.hotKey.init()
|
||||
|
|
|
@ -16,7 +16,7 @@ const themeList = [
|
|||
isNative: false,
|
||||
},
|
||||
]
|
||||
global.lx_event.common.on(COMMON_EVENT_NAME.config, sourceName => {
|
||||
global.lx_event.common.on(COMMON_EVENT_NAME.configStatus, sourceName => {
|
||||
if (sourceName === TRAY_EVENT_NAME.name) return
|
||||
if (themeId !== global.appSetting.tray.themeId) {
|
||||
themeId = global.appSetting.tray.themeId
|
||||
|
@ -89,34 +89,34 @@ const createMenu = tray => {
|
|||
menu.push(global.appSetting.desktopLyric.enable ? {
|
||||
label: '关闭桌面歌词',
|
||||
click() {
|
||||
global.lx_event.common.setAppConfig({ desktopLyric: { enable: false } }, TRAY_EVENT_NAME.name)
|
||||
global.lx_core.setAppConfig({ desktopLyric: { enable: false } }, TRAY_EVENT_NAME.name)
|
||||
},
|
||||
} : {
|
||||
label: '开启桌面歌词',
|
||||
click() {
|
||||
global.lx_event.common.setAppConfig({ desktopLyric: { enable: true } }, TRAY_EVENT_NAME.name)
|
||||
global.lx_core.setAppConfig({ desktopLyric: { enable: true } }, TRAY_EVENT_NAME.name)
|
||||
},
|
||||
})
|
||||
menu.push(global.appSetting.desktopLyric.isLock ? {
|
||||
label: '解锁桌面歌词',
|
||||
click() {
|
||||
global.lx_event.common.setAppConfig({ desktopLyric: { isLock: false } }, TRAY_EVENT_NAME.name)
|
||||
global.lx_core.setAppConfig({ desktopLyric: { isLock: false } }, TRAY_EVENT_NAME.name)
|
||||
},
|
||||
} : {
|
||||
label: '锁定桌面歌词',
|
||||
click() {
|
||||
global.lx_event.common.setAppConfig({ desktopLyric: { isLock: true } }, TRAY_EVENT_NAME.name)
|
||||
global.lx_core.setAppConfig({ desktopLyric: { isLock: true } }, TRAY_EVENT_NAME.name)
|
||||
},
|
||||
})
|
||||
menu.push(global.appSetting.desktopLyric.isAlwaysOnTop ? {
|
||||
label: '取消置顶',
|
||||
click() {
|
||||
global.lx_event.common.setAppConfig({ desktopLyric: { isAlwaysOnTop: false } }, TRAY_EVENT_NAME.name)
|
||||
global.lx_core.setAppConfig({ desktopLyric: { isAlwaysOnTop: false } }, TRAY_EVENT_NAME.name)
|
||||
},
|
||||
} : {
|
||||
label: '置顶歌词',
|
||||
click() {
|
||||
global.lx_event.common.setAppConfig({ desktopLyric: { isAlwaysOnTop: true } }, TRAY_EVENT_NAME.name)
|
||||
global.lx_core.setAppConfig({ desktopLyric: { isAlwaysOnTop: true } }, TRAY_EVENT_NAME.name)
|
||||
},
|
||||
})
|
||||
menu.push({
|
||||
|
|
|
@ -2,6 +2,7 @@ const { common: COMMON_EVENT_NAME, winLyric: WIN_LYRIC_EVENT_NAME, hotKey: HOT_K
|
|||
const { mainSend, NAMES: { winLyric: ipcWinLyricNames } } = require('../../../common/ipc')
|
||||
const { desktop_lyric } = require('../../../common/hotKey')
|
||||
const { getLyricWindowBounds } = require('./utils')
|
||||
const { updateSetting } = require('../../utils')
|
||||
|
||||
let isLock = null
|
||||
let isEnable = null
|
||||
|
@ -49,7 +50,7 @@ const setLrcConfig = () => {
|
|||
}
|
||||
}
|
||||
}
|
||||
global.lx_event.common.on(COMMON_EVENT_NAME.config, name => {
|
||||
global.lx_event.common.on(COMMON_EVENT_NAME.configStatus, name => {
|
||||
if (WIN_LYRIC_EVENT_NAME.name === name) return
|
||||
setLrcConfig()
|
||||
})
|
||||
|
@ -77,5 +78,5 @@ global.lx_event.hotKey.on(HOT_KEY_EVENT_NAME.keyDown, ({ type, key }) => {
|
|||
}
|
||||
desktopLyricSetting[settingKey] = !desktopLyricSetting[settingKey]
|
||||
|
||||
global.lx_event.common.setAppConfig({ desktopLyric: desktopLyricSetting }, null)
|
||||
updateSetting({ desktopLyric: desktopLyricSetting }, null)
|
||||
})
|
||||
|
|
|
@ -21,7 +21,7 @@ const setLyricsConfig = debounce(config => {
|
|||
// if (y != null) bounds.y = y
|
||||
// if (width != null) bounds.width = width
|
||||
// if (height != null) bounds.height = height
|
||||
global.lx_event.common.setAppConfig({ desktopLyric: config }, WIN_LYRIC_EVENT_NAME.name)
|
||||
global.lx_core.setAppConfig({ desktopLyric: config }, WIN_LYRIC_EVENT_NAME.name)
|
||||
}, 500)
|
||||
|
||||
const winEvent = lyricWindow => {
|
||||
|
|
|
@ -20,7 +20,7 @@ mainOn(ipcWinLyricNames.get_lyric_info, (event, action) => {
|
|||
})
|
||||
|
||||
mainOn(ipcWinLyricNames.set_lyric_config, (event, config) => {
|
||||
global.lx_event.common.setAppConfig({ desktopLyric: config }, WIN_LYRIC_EVENT_NAME.name)
|
||||
global.lx_core.setAppConfig({ desktopLyric: config }, WIN_LYRIC_EVENT_NAME.name)
|
||||
})
|
||||
|
||||
mainHandle(ipcWinLyricNames.get_lyric_config, async() => {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
const { mainWindow: MAIN_WINDOW_EVENT_NAME } = require('../events/_name')
|
||||
const { mainOn, NAMES: { mainWindow: ipcMainWindowNames }, mainHandle } = require('../../common/ipc')
|
||||
const { NAMES: { mainWindow: ipcMainWindowNames }, mainHandle } = require('../../common/ipc')
|
||||
|
||||
mainOn(ipcMainWindowNames.set_app_setting, (event, config) => {
|
||||
|
||||
mainHandle(ipcMainWindowNames.set_app_setting, (event, config) => {
|
||||
if (!config) return
|
||||
global.lx_event.common.setAppConfig(config, MAIN_WINDOW_EVENT_NAME.name)
|
||||
global.lx_core.setAppConfig(config, MAIN_WINDOW_EVENT_NAME.name)
|
||||
return global.appSetting
|
||||
})
|
||||
|
||||
mainHandle(ipcMainWindowNames.get_setting, async() => ({ setting: global.appSetting, version: global.appSettingVersion }))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const Store = require('electron-store')
|
||||
const { windowSizeList } = require('../../common/config')
|
||||
const { objectDeepMerge, throttle } = require('../../common/utils')
|
||||
const { objectDeepMerge, throttle, initSetting } = require('../../common/utils')
|
||||
|
||||
exports.getWindowSizeInfo = ({ windowSizeId = 1 } = {}) => {
|
||||
return windowSizeList.find(i => i.id === windowSizeId) || windowSizeList[0]
|
||||
|
@ -32,10 +32,16 @@ exports.saveAppHotKeyConfig = config => {
|
|||
saveHotKeyConfig(config)
|
||||
}
|
||||
|
||||
const saveSetting = throttle(n => {
|
||||
electronStore_config.set('setting', n)
|
||||
})
|
||||
exports.updateSetting = settings => {
|
||||
// const saveSetting = throttle(n => {
|
||||
// electronStore_config.set('setting', n)
|
||||
// })
|
||||
exports.updateSetting = (settings) => {
|
||||
objectDeepMerge(global.appSetting, settings)
|
||||
saveSetting(global.appSetting)
|
||||
electronStore_config.set('setting', global.appSetting)
|
||||
exports.initSetting()
|
||||
}
|
||||
exports.initSetting = () => {
|
||||
const info = initSetting()
|
||||
global.appSetting = info.setting
|
||||
global.appSettingVersion = info.version
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue