diff --git a/src/renderer/store/mutations.js b/src/renderer/store/mutations.js index ed5d6d9f..12157e03 100644 --- a/src/renderer/store/mutations.js +++ b/src/renderer/store/mutations.js @@ -18,8 +18,8 @@ export default { if (sortId != null) state.setting.songList.sortId = sortId if (source != null) state.setting.songList.source = source }, - setListScroll(state, scrollTop) { - state.setting.list.scroll.location = scrollTop + setListScroll(state, { id, location }) { + state.setting.list.scroll.locations[id] = location }, setNewVersion(state, val) { // val.history.forEach(ver => { diff --git a/src/renderer/utils/index.js b/src/renderer/utils/index.js index 112f32fb..094f6bf7 100644 --- a/src/renderer/utils/index.js +++ b/src/renderer/utils/index.js @@ -164,7 +164,7 @@ export const isChildren = (parent, children) => { * @param {*} setting */ export const updateSetting = setting => { - const defaultVersion = '1.0.10' + const defaultVersion = '1.0.11' const defaultSetting = { version: defaultVersion, player: { @@ -177,7 +177,7 @@ export const updateSetting = setting => { isShowAlbumName: true, scroll: { enable: true, - location: 0, + locations: {}, }, }, download: { diff --git a/src/renderer/views/List.vue b/src/renderer/views/List.vue index 8e2dcb92..9cdf7f28 100644 --- a/src/renderer/views/List.vue +++ b/src/renderer/views/List.vue @@ -153,9 +153,9 @@ export default { this.listId = this.$route.query.id this.handleScroll = throttle(e => { if (this.routeLeaveLocation) { - this.setListScroll(this.routeLeaveLocation) + this.setListScroll({ id: this.listId, location: this.routeLeaveLocation }) } else { - this.setListScroll(e.target.scrollTop) + this.setListScroll({ id: this.listId, location: e.target.scrollTop }) } }, 1000) }, @@ -173,12 +173,19 @@ export default { if (this.list.length > 150) { setTimeout(() => { this.delayShow = true - if (this.setting.list.scroll.enable && this.setting.list.scroll.location) { - this.$nextTick(() => this.$refs.dom_scrollContent.scrollTo(0, this.setting.list.scroll.location)) - } + this.restoreScroll() }, 200) } else { this.delayShow = true + this.restoreScroll() + } + }, + restoreScroll() { + let location = this.setting.list.scroll.locations[this.listId] + if (this.setting.list.scroll.enable && location) { + this.$nextTick(() => { + this.$refs.dom_scrollContent.scrollTo(0, location) + }) } }, handleDoubleClick(index) { diff --git a/src/renderer/views/Setting.vue b/src/renderer/views/Setting.vue index 58c0c109..bd2198a5 100644 --- a/src/renderer/views/Setting.vue +++ b/src/renderer/views/Setting.vue @@ -180,7 +180,7 @@ export default { isShowAlbumName: true, scroll: { enable: true, - location: 0, + locations: {}, }, }, download: {