修复对多列表滚动条位置恢复的支持

pull/96/head
lyswhut 2019-10-03 18:42:26 +08:00
parent 6498305ec8
commit f4c65516d0
4 changed files with 17 additions and 10 deletions

View File

@ -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 => {

View File

@ -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: {

View File

@ -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) {

View File

@ -180,7 +180,7 @@ export default {
isShowAlbumName: true,
scroll: {
enable: true,
location: 0,
locations: {},
},
},
download: {