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

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 (sortId != null) state.setting.songList.sortId = sortId
if (source != null) state.setting.songList.source = source if (source != null) state.setting.songList.source = source
}, },
setListScroll(state, scrollTop) { setListScroll(state, { id, location }) {
state.setting.list.scroll.location = scrollTop state.setting.list.scroll.locations[id] = location
}, },
setNewVersion(state, val) { setNewVersion(state, val) {
// val.history.forEach(ver => { // val.history.forEach(ver => {

View File

@ -164,7 +164,7 @@ export const isChildren = (parent, children) => {
* @param {*} setting * @param {*} setting
*/ */
export const updateSetting = setting => { export const updateSetting = setting => {
const defaultVersion = '1.0.10' const defaultVersion = '1.0.11'
const defaultSetting = { const defaultSetting = {
version: defaultVersion, version: defaultVersion,
player: { player: {
@ -177,7 +177,7 @@ export const updateSetting = setting => {
isShowAlbumName: true, isShowAlbumName: true,
scroll: { scroll: {
enable: true, enable: true,
location: 0, locations: {},
}, },
}, },
download: { download: {

View File

@ -153,9 +153,9 @@ export default {
this.listId = this.$route.query.id this.listId = this.$route.query.id
this.handleScroll = throttle(e => { this.handleScroll = throttle(e => {
if (this.routeLeaveLocation) { if (this.routeLeaveLocation) {
this.setListScroll(this.routeLeaveLocation) this.setListScroll({ id: this.listId, location: this.routeLeaveLocation })
} else { } else {
this.setListScroll(e.target.scrollTop) this.setListScroll({ id: this.listId, location: e.target.scrollTop })
} }
}, 1000) }, 1000)
}, },
@ -173,12 +173,19 @@ export default {
if (this.list.length > 150) { if (this.list.length > 150) {
setTimeout(() => { setTimeout(() => {
this.delayShow = true this.delayShow = true
if (this.setting.list.scroll.enable && this.setting.list.scroll.location) { this.restoreScroll()
this.$nextTick(() => this.$refs.dom_scrollContent.scrollTo(0, this.setting.list.scroll.location))
}
}, 200) }, 200)
} else { } else {
this.delayShow = true 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) { handleDoubleClick(index) {

View File

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