You've already forked AstralRinth
forked from didirus/AstralRinth
Search loading anim (#1036)
This commit is contained in:
@@ -284,7 +284,8 @@
|
|||||||
class="pagination-before"
|
class="pagination-before"
|
||||||
@switch-page="onSearchChange"
|
@switch-page="onSearchChange"
|
||||||
/>
|
/>
|
||||||
<div v-if="results && results.hits && results.hits.length === 0" class="no-results">
|
<LogoAnimated v-if="searchLoading && !noLoad"></LogoAnimated>
|
||||||
|
<div v-else-if="results && results.hits && results.hits.length === 0" class="no-results">
|
||||||
<p>No results found for your query!</p>
|
<p>No results found for your query!</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="search-results-container">
|
<div v-else class="search-results-container">
|
||||||
@@ -336,6 +337,7 @@ import ProjectCard from '~/components/ui/ProjectCard'
|
|||||||
import Pagination from '~/components/ui/Pagination'
|
import Pagination from '~/components/ui/Pagination'
|
||||||
import SearchFilter from '~/components/ui/search/SearchFilter'
|
import SearchFilter from '~/components/ui/search/SearchFilter'
|
||||||
import Checkbox from '~/components/ui/Checkbox'
|
import Checkbox from '~/components/ui/Checkbox'
|
||||||
|
import LogoAnimated from '~/components/brand/LogoAnimated'
|
||||||
|
|
||||||
import ClientIcon from '~/assets/images/categories/client.svg'
|
import ClientIcon from '~/assets/images/categories/client.svg'
|
||||||
import ServerIcon from '~/assets/images/categories/server.svg'
|
import ServerIcon from '~/assets/images/categories/server.svg'
|
||||||
@@ -351,6 +353,7 @@ import Promotion from '~/components/ads/Promotion.vue'
|
|||||||
|
|
||||||
export default defineNuxtComponent({
|
export default defineNuxtComponent({
|
||||||
components: {
|
components: {
|
||||||
|
LogoAnimated,
|
||||||
Promotion,
|
Promotion,
|
||||||
ProjectCard,
|
ProjectCard,
|
||||||
Pagination,
|
Pagination,
|
||||||
@@ -465,11 +468,13 @@ export default defineNuxtComponent({
|
|||||||
(x) => x.id === route.path.substring(1, route.path.length - 1)
|
(x) => x.id === route.path.substring(1, route.path.length - 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const noLoad = ref(false)
|
||||||
const {
|
const {
|
||||||
data: rawResults,
|
data: rawResults,
|
||||||
refresh: refreshSearch,
|
refresh: refreshSearch,
|
||||||
pending,
|
pending: searchLoading,
|
||||||
} = useLazyFetch(() => {
|
} = useLazyFetch(
|
||||||
|
() => {
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
const base = process.server ? config.apiBaseUrl : config.public.apiBaseUrl
|
const base = process.server ? config.apiBaseUrl : config.public.apiBaseUrl
|
||||||
|
|
||||||
@@ -506,7 +511,9 @@ export default defineNuxtComponent({
|
|||||||
)
|
)
|
||||||
} else if (projectType.value.id === 'datapack') {
|
} else if (projectType.value.id === 'datapack') {
|
||||||
formattedFacets.push(
|
formattedFacets.push(
|
||||||
data.$tag.loaderData.dataPackLoaders.map((x) => `categories:'${encodeURIComponent(x)}'`)
|
data.$tag.loaderData.dataPackLoaders.map(
|
||||||
|
(x) => `categories:'${encodeURIComponent(x)}'`
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,15 +575,14 @@ export default defineNuxtComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return `${base}${url}`
|
return `${base}${url}`
|
||||||
})
|
},
|
||||||
|
{
|
||||||
watch(pending, (newVal) => {
|
transform(hits) {
|
||||||
if (newVal) {
|
noLoad.value = false
|
||||||
startLoading()
|
return hits
|
||||||
} else {
|
},
|
||||||
stopLoading()
|
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
const results = shallowRef(toRaw(rawResults))
|
const results = shallowRef(toRaw(rawResults))
|
||||||
const pageCount = computed(() =>
|
const pageCount = computed(() =>
|
||||||
@@ -584,6 +590,9 @@ export default defineNuxtComponent({
|
|||||||
)
|
)
|
||||||
|
|
||||||
const onSearchChange = (newPageNumber) => {
|
const onSearchChange = (newPageNumber) => {
|
||||||
|
noLoad.value = true
|
||||||
|
console.log(noLoad.value)
|
||||||
|
|
||||||
currentPage.value = newPageNumber
|
currentPage.value = newPageNumber
|
||||||
|
|
||||||
if (query.value === null) {
|
if (query.value === null) {
|
||||||
@@ -674,6 +683,8 @@ export default defineNuxtComponent({
|
|||||||
projectType,
|
projectType,
|
||||||
onSearchChange,
|
onSearchChange,
|
||||||
getSearchUrl,
|
getSearchUrl,
|
||||||
|
searchLoading,
|
||||||
|
noLoad,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
Reference in New Issue
Block a user