2020-06-29 16:49:33 +00:00
|
|
|
<template>
|
2020-09-25 17:01:08 +00:00
|
|
|
<main
|
|
|
|
id="content"
|
|
|
|
@scroll="$route.name === 'Search' ? handleContentScroll($event) : null"
|
|
|
|
ref="content"
|
|
|
|
aria-label="main content"
|
|
|
|
>
|
2020-06-29 16:49:33 +00:00
|
|
|
<div id="container">
|
2020-09-15 20:44:29 +00:00
|
|
|
<BaseLoadingPlaceholder id="search_placeholder" text="Searching..." :hidden="!loading" />
|
2020-09-15 20:51:50 +00:00
|
|
|
|
2020-09-17 19:17:53 +00:00
|
|
|
<keep-alive>
|
|
|
|
<router-view
|
2020-09-21 17:12:14 +00:00
|
|
|
v-if="!$route.meta.notKeepAlive"
|
2020-09-17 19:17:53 +00:00
|
|
|
v-show="!loading"
|
|
|
|
:key="$route.fullPath"
|
|
|
|
:perform-scrolled-search="performScrolledSearch"
|
2020-09-21 17:12:14 +00:00
|
|
|
exclude=""
|
2020-09-17 19:17:53 +00:00
|
|
|
></router-view>
|
|
|
|
</keep-alive>
|
2020-09-21 17:12:14 +00:00
|
|
|
|
|
|
|
<router-view
|
|
|
|
v-if="$route.meta.notKeepAlive"
|
|
|
|
v-show="!loading"
|
|
|
|
:key="$route.fullPath"
|
|
|
|
:perform-scrolled-search="performScrolledSearch"
|
|
|
|
exclude=""
|
|
|
|
></router-view>
|
2020-06-29 16:49:33 +00:00
|
|
|
</div>
|
2020-09-25 17:01:08 +00:00
|
|
|
</main>
|
2020-06-29 16:49:33 +00:00
|
|
|
</template>
|
|
|
|
|
2020-09-15 20:44:29 +00:00
|
|
|
<style lang="scss">
|
|
|
|
#container {
|
|
|
|
margin: 0 auto;
|
|
|
|
max-width: 1280px;
|
|
|
|
width: var(--container-width);
|
|
|
|
}
|
|
|
|
|
2020-09-25 17:01:08 +00:00
|
|
|
main {
|
2020-09-15 20:44:29 +00:00
|
|
|
background-color: var(--main-background);
|
2020-09-25 17:01:08 +00:00
|
|
|
padding-right: 5px;
|
2020-09-15 20:44:29 +00:00
|
|
|
width: 100%;
|
|
|
|
height: calc(100vh - 93px);
|
|
|
|
overflow-y: scroll;
|
|
|
|
overflow-x: hidden;
|
|
|
|
|
|
|
|
&::-webkit-scrollbar {
|
|
|
|
width: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&::-webkit-scrollbar-track {
|
|
|
|
background: var(--main-background);
|
|
|
|
}
|
2020-06-29 16:49:33 +00:00
|
|
|
|
2020-09-15 20:44:29 +00:00
|
|
|
&::-webkit-scrollbar-thumb {
|
|
|
|
background: var(--main-scroll);
|
|
|
|
border-radius: 4px;
|
|
|
|
width: 6px;
|
|
|
|
padding: 0px 2px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
2020-06-29 16:49:33 +00:00
|
|
|
|
2020-09-15 20:44:29 +00:00
|
|
|
<script>
|
2020-07-16 22:11:28 +00:00
|
|
|
import { debounce } from '@/utils/utils'
|
2020-09-15 20:44:29 +00:00
|
|
|
import BaseLoadingPlaceholder from '@components/BaseLoadingPlaceholder.vue'
|
2020-07-06 19:55:28 +00:00
|
|
|
|
2020-06-29 16:49:33 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
2020-09-15 20:44:29 +00:00
|
|
|
BaseLoadingPlaceholder
|
2020-07-06 19:55:28 +00:00
|
|
|
},
|
|
|
|
data: () => ({
|
2020-09-17 16:31:07 +00:00
|
|
|
performScrolledSearch: false,
|
2020-09-15 20:44:29 +00:00
|
|
|
loading: false
|
2020-07-06 19:55:28 +00:00
|
|
|
}),
|
2020-09-15 20:44:29 +00:00
|
|
|
mounted() {
|
|
|
|
this.$root.$on('updateSearchLoadingState', loading => {
|
|
|
|
this.loading = loading
|
|
|
|
})
|
2020-09-24 16:44:49 +00:00
|
|
|
|
|
|
|
this.$router.beforeEach((to, from, next) => {
|
|
|
|
this.$refs.content.scrollTo(0, 0)
|
|
|
|
next()
|
|
|
|
})
|
2020-09-17 16:31:07 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleContentScroll: debounce(async function () {
|
|
|
|
if (this.$refs.content.scrollTop + this.$refs.content.clientHeight < this.$refs.content.scrollHeight) return
|
|
|
|
this.performScrolledSearch = true
|
2020-07-06 19:55:28 +00:00
|
|
|
|
2020-09-17 16:31:07 +00:00
|
|
|
await this.$nextTick()
|
2020-07-06 19:55:28 +00:00
|
|
|
|
2020-09-17 16:31:07 +00:00
|
|
|
this.performScrolledSearch = false
|
|
|
|
}, 100)
|
|
|
|
}
|
2020-06-29 16:49:33 +00:00
|
|
|
}
|
|
|
|
</script>
|