From 5949e8fb3fc84b23000884e71e95c7c1c9e9a4f0 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Mon, 28 Sep 2020 01:33:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=88=91=E7=9A=84=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=BB=9A=E5=8A=A8=E6=9D=A1=E4=BD=8D=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/views/List.vue | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/renderer/views/List.vue b/src/renderer/views/List.vue index 79b75cba..ea07d804 100644 --- a/src/renderer/views/List.vue +++ b/src/renderer/views/List.vue @@ -86,7 +86,6 @@ export default { // isShowEditBtn: false, isShowDownloadMultiple: false, delayShow: false, - routeLeaveLocation: null, isShowListAdd: false, isShowListAddMultiple: false, delayTimeout: null, @@ -289,18 +288,14 @@ export default { // }, beforeRouteLeave(to, from, next) { this.clearDelayTimeout() - this.routeLeaveLocation = (this.list.length && this.$refs.dom_scrollContent.scrollTop) || 0 + this.setListScroll({ id: this.listId, location: (this.list.length && this.$refs.dom_scrollContent.scrollTop) || 0 }) next() }, created() { this.listId = this.$route.query.id || this.defaultList.id this.setPrevSelectListId(this.listId) - this.handleScroll = throttle(e => { - if (this.routeLeaveLocation) { - this.setListScroll({ id: this.listId, location: this.routeLeaveLocation }) - } else { - this.setListScroll({ id: this.listId, location: e.target.scrollTop }) - } + this.handleSaveScroll = throttle((listId, location) => { + this.setListScroll({ id: listId, location }) }, 1000) this.listenEvent() }, @@ -310,6 +305,7 @@ export default { }, beforeDestroy() { this.unlistenEvent() + this.setListScroll({ id: this.listId, location: (this.list.length && this.$refs.dom_scrollContent.scrollTop) || 0 }) }, methods: { ...mapMutations(['setPrevSelectListId']), @@ -369,6 +365,9 @@ export default { this.restoreScroll(this.$route.query.scrollIndex, false) } }, + handleScroll(e) { + this.handleSaveScroll(this.listId, e.target.scrollTop) + }, clearDelayTimeout() { if (this.delayTimeout) { clearTimeout(this.delayTimeout)