change: loading performance
This commit is contained in:
parent
7c8be0ccb9
commit
716b5535ae
14 changed files with 129 additions and 98 deletions
|
@ -12,14 +12,13 @@ import type Event from "../types/collection/event";
|
|||
import type Operation from "../types/collection/operation";
|
||||
import type Vehicle from "../types/collection/vehicle";
|
||||
import type Page from "../types/collection/page";
|
||||
import provideGlobal from "../composables/provideGlobal";
|
||||
|
||||
const {
|
||||
params: { slug: params },
|
||||
} = useRoute();
|
||||
const { findOne, find } = useStrapi();
|
||||
|
||||
const sitemap = await calculateSitemap();
|
||||
const sitemap = useSitemap();
|
||||
|
||||
const detail = ref<Article | Operation | Event | Vehicle | undefined>(undefined);
|
||||
|
||||
|
@ -27,10 +26,10 @@ const activePath = computed(() => {
|
|||
return "/" + (Array.isArray(params) ? params.join("/") : params);
|
||||
});
|
||||
const activePageBySitemap = computed(() => {
|
||||
return sitemap.find((s) => s.path == activePath.value);
|
||||
return sitemap.value.find((s) => s.path == activePath.value);
|
||||
});
|
||||
const similarestPage = computed(() => {
|
||||
return sitemap.reduce(
|
||||
return sitemap.value.reduce(
|
||||
(bestMatch, current) => {
|
||||
const currentMatchLength = current.path
|
||||
.split("/")
|
||||
|
@ -49,23 +48,27 @@ const similarestPage = computed(() => {
|
|||
);
|
||||
});
|
||||
|
||||
const { data: pages } = await useAsyncData("pages", () =>
|
||||
findOne<Page | Array<Page>>("pages", similarestPage.value?.document, {
|
||||
populate: {
|
||||
populate: "*",
|
||||
content: {
|
||||
const { data: pages } = await useAsyncData(
|
||||
() =>
|
||||
findOne<Page | Array<Page>>("pages", similarestPage.value?.document, {
|
||||
populate: {
|
||||
populate: "*",
|
||||
content: {
|
||||
populate: "*",
|
||||
},
|
||||
hero: {
|
||||
populate: "*",
|
||||
},
|
||||
},
|
||||
hero: {
|
||||
populate: "*",
|
||||
filters: {
|
||||
...(!similarestPage.value?.document
|
||||
? { slug: Array.isArray(params) ? params.join("~") : params, ref_only_access: false }
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
filters: {
|
||||
...(!similarestPage.value?.document
|
||||
? { slug: Array.isArray(params) ? params.join("~") : params, ref_only_access: false }
|
||||
: {}),
|
||||
},
|
||||
})
|
||||
}),
|
||||
{
|
||||
default: () => null,
|
||||
}
|
||||
);
|
||||
const page = computed(() => {
|
||||
return Array.isArray(pages.value?.data) ? pages.value.data[0] : pages.value?.data;
|
||||
|
@ -100,7 +103,7 @@ if (isCollectionDetail) {
|
|||
];
|
||||
|
||||
for (const element of collectionOfDetail) {
|
||||
const { data: details } = await useAsyncData("detail", () =>
|
||||
const { data: details } = await useAsyncData(() =>
|
||||
find<Article | Operation | Event | Vehicle>(element ?? "", {
|
||||
populate: "*",
|
||||
filters: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue