change: loading performance
This commit is contained in:
parent
7c8be0ccb9
commit
716b5535ae
14 changed files with 129 additions and 98 deletions
15
plugins/global.ts
Normal file
15
plugins/global.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import type Global from "../types/single/global";
|
||||
|
||||
export default defineNuxtPlugin(async (nuxtApp) => {
|
||||
const globalState = useState<Global | null>("global", () => null);
|
||||
|
||||
if (!globalState.value) {
|
||||
const { findOne } = useStrapi();
|
||||
const { data: global } = await useAsyncData("global", () => findOne<Global>("global"), {
|
||||
server: true,
|
||||
lazy: false,
|
||||
default: () => {},
|
||||
});
|
||||
globalState.value = global.value?.data ?? null;
|
||||
}
|
||||
});
|
25
plugins/sitemap.ts
Normal file
25
plugins/sitemap.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import type Page from "../types/collection/page";
|
||||
import type Global from "../types/single/global";
|
||||
|
||||
export default defineNuxtPlugin(async (nuxtApp) => {
|
||||
const pageState = useState<Page[]>("sitemap_pages", () => []);
|
||||
|
||||
if (!pageState.value) {
|
||||
const { find } = useStrapi();
|
||||
const { data: page_res } = await useAsyncData(
|
||||
"sitemap_pages",
|
||||
() =>
|
||||
find<Page>("pages", {
|
||||
filters: {
|
||||
ref_only_access: false,
|
||||
},
|
||||
}),
|
||||
{
|
||||
server: true,
|
||||
lazy: false,
|
||||
default: () => {},
|
||||
}
|
||||
);
|
||||
pageState.value = page_res.value?.data ?? [];
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue