|
@@ -5,6 +5,7 @@
|
|
|
:title-inactive-color="tabConf.titleInactiveColor"
|
|
|
:line-width="tabConf.lineWidth"
|
|
|
:color="tabConf.color"
|
|
|
+ :before-change="beforeTabChange"
|
|
|
v-model="tabActive"
|
|
|
class="j-container"
|
|
|
>
|
|
@@ -55,13 +56,13 @@
|
|
|
/>
|
|
|
</div>
|
|
|
</van-list>
|
|
|
- <Empty v-if="myLibListState.list.length === 0 && myCollectionListState.loaded">暂无数据</Empty>
|
|
|
+ <Empty v-if="myCollectionListState.list.length === 0 && myCollectionListState.loaded">暂无数据</Empty>
|
|
|
</van-tab>
|
|
|
</van-tabs>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
-import { Component, Vue } from 'vue-property-decorator'
|
|
|
+import { Component, Vue, Watch } from 'vue-property-decorator'
|
|
|
import { Tabs, Tab, List } from 'vant'
|
|
|
import { mapState, mapMutations, mapActions } from 'vuex'
|
|
|
import Card from '@/components/docs-card/Card.vue'
|
|
@@ -139,11 +140,22 @@ export default class UserLibrary extends Vue {
|
|
|
return map[this.tabActive] || map[0]
|
|
|
}
|
|
|
|
|
|
+ @Watch('tabActive')
|
|
|
+ onTabChange () {
|
|
|
+ const i: any = this.$data[this.keyForList]
|
|
|
+ this.setScrollTop(i.scrollTop)
|
|
|
+ }
|
|
|
+
|
|
|
created () {
|
|
|
this.tabActive = this.$route.query.tab as string
|
|
|
this.reStoreState()
|
|
|
}
|
|
|
|
|
|
+ beforeTabChange () {
|
|
|
+ this.saveScrollTop()
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
toDocDetail (item: any) {
|
|
|
const { docId: id } = item
|
|
|
this.saveState()
|
|
@@ -188,7 +200,6 @@ export default class UserLibrary extends Vue {
|
|
|
}
|
|
|
|
|
|
reStoreState () {
|
|
|
- console.log('reStoreState')
|
|
|
const listInfo = this.userLibInfo
|
|
|
if (!listInfo || Object.keys(listInfo).length === 0) {
|
|
|
return false
|
|
@@ -211,10 +222,13 @@ export default class UserLibrary extends Vue {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- saveState () {
|
|
|
- console.log('saveState')
|
|
|
+ saveScrollTop () {
|
|
|
const wrapper: any = document.querySelector('.van-tabs__content')
|
|
|
this.$data[this.keyForList].scrollTop = wrapper.scrollTop
|
|
|
+ }
|
|
|
+
|
|
|
+ saveState () {
|
|
|
+ this.saveScrollTop()
|
|
|
const d = {
|
|
|
tabActive: this.tabActive,
|
|
|
myLibListState: this.myLibListState,
|