From f4c65516d0f1d4a8115e94ca77236cf1651a6123 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Thu, 3 Oct 2019 18:42:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=B9=E5=A4=9A=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=BB=9A=E5=8A=A8=E6=9D=A1=E4=BD=8D=E7=BD=AE=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/store/mutations.js | 4 ++-- src/renderer/utils/index.js | 4 ++-- src/renderer/views/List.vue | 17 ++++++++++++----- src/renderer/views/Setting.vue | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) 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: {