diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 0e15cd1..79b2225 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -2,7 +2,7 @@ - diff --git a/frontend/src/components/appcard/AppCard.vue b/frontend/src/components/appcard/AppCard.vue index de7cc81..3f1846d 100644 --- a/frontend/src/components/appcard/AppCard.vue +++ b/frontend/src/components/appcard/AppCard.vue @@ -247,6 +247,7 @@ onMounted(() => { }); function goAppDetails() { + console.log('click app'); if (props.disabled) { return; } diff --git a/frontend/src/pages/application/CategoryPage.vue b/frontend/src/pages/application/CategoryPage.vue index afa0c28..f447b59 100644 --- a/frontend/src/pages/application/CategoryPage.vue +++ b/frontend/src/pages/application/CategoryPage.vue @@ -192,43 +192,53 @@ const topLoading = ref(true); const latestLoading = ref(true); const { t } = useI18n(); -onMounted(async () => { +onMounted(() => { topTitle.value = `Top App in ${categoryRef.value}`; latestTitle.value = `Latest App in ${categoryRef.value}`; - await fetchData(true); + fetchData(true); }); -async function fetchData(showLoading = false) { +function fetchData(showLoading = false) { if (showLoading) { pageLoading.value = true; topLoading.value = true; latestLoading.value = true; } - const all = await appStore.getPageData(categoryRef.value); - if (all && all.data) { - console.log(all.data); - pageData.value = all.data; - pageLoading.value = false; + appStore + .getPageData(categoryRef.value) + .then((all) => { + if (all && all.data) { + pageData.value = all.data; + const top = pageData.value.find( + (item: any) => item.type === 'Default Topic' && item.id === 'Hottest' + ); + if (top) { + getTop(categoryRef.value.toLowerCase()) + .then((list) => { + topApps.value = list; + }) + .finally(() => { + topLoading.value = false; + }); + } - const top = pageData.value.find( - (item: any) => item.type === 'Default Topic' && item.id === 'Hottest' - ); - if (top) { - topApps.value = await getTop(categoryRef.value.toLowerCase()); - topLoading.value = false; - } - - const latest = pageData.value.find( - (item: any) => item.type === 'Default Topic' && item.id === 'Newest' - ); - if (latest) { - latestApps.value = await getLatest(categoryRef.value.toLowerCase()); - latestLoading.value = false; - } - } - pageLoading.value = false; - topLoading.value = false; - latestLoading.value = false; + const latest = pageData.value.find( + (item: any) => item.type === 'Default Topic' && item.id === 'Newest' + ); + if (latest) { + getLatest(categoryRef.value.toLowerCase()) + .then((list) => { + latestApps.value = list; + }) + .finally(() => { + latestLoading.value = false; + }); + } + } + }) + .finally(() => { + pageLoading.value = false; + }); } const clickList = (type: string) => { diff --git a/frontend/src/pages/application/HomePage.vue b/frontend/src/pages/application/HomePage.vue index f920a0d..b9dae5f 100644 --- a/frontend/src/pages/application/HomePage.vue +++ b/frontend/src/pages/application/HomePage.vue @@ -206,42 +206,52 @@ const pageData = ref(); const appStore = useAppStore(); const { t } = useI18n(); -onMounted(async () => { - await fetchData(true); +onMounted(() => { + fetchData(true); }); -async function fetchData(showLoading = false) { +function fetchData(showLoading = false) { if (showLoading) { pageLoading.value = true; topLoading.value = true; latestLoading.value = true; } - const all = await appStore.getPageData(CATEGORIES_TYPE.LOCAL.ALL); - console.log(all); - if (all && all.data) { - console.log(all.data); - pageData.value = all.data; - pageLoading.value = false; + appStore + .getPageData(CATEGORIES_TYPE.LOCAL.ALL) + .then((all) => { + if (all && all.data) { + pageData.value = all.data; - const top = pageData.value.find( - (item: any) => item.type === 'Default Topic' && item.id === 'Hottest' - ); - if (top) { - topApps.value = await getTop(); - topLoading.value = false; - } + const top = pageData.value.find( + (item: any) => item.type === 'Default Topic' && item.id === 'Hottest' + ); + if (top) { + getTop() + .then((list) => { + topApps.value = list; + }) + .finally(() => { + topLoading.value = false; + }); + } - const latest = pageData.value.find( - (item: any) => item.type === 'Default Topic' && item.id === 'Newest' - ); - if (latest) { - latestApps.value = await getLatest(); - latestLoading.value = false; - } - } - pageLoading.value = false; - topLoading.value = false; - latestLoading.value = false; + const latest = pageData.value.find( + (item: any) => item.type === 'Default Topic' && item.id === 'Newest' + ); + if (latest) { + getLatest() + .then((list) => { + latestApps.value = list; + }) + .finally(() => { + latestLoading.value = false; + }); + } + } + }) + .finally(() => { + pageLoading.value = false; + }); } const clickList = (type: string) => { diff --git a/frontend/src/stores/app.ts b/frontend/src/stores/app.ts index 8118f9e..5481887 100644 --- a/frontend/src/stores/app.ts +++ b/frontend/src/stores/app.ts @@ -34,7 +34,6 @@ import { CFG_TYPE } from 'src/constants/config'; export type AppState = { tempAppMap: Record; - initialized: boolean; pageData: [] | null; installApps: AppStoreInfo[]; updateApps: AppStoreInfo[]; @@ -46,7 +45,6 @@ export const useAppStore = defineStore('app', { state: () => { return { tempAppMap: {}, - initialized: false, installApps: [], updateApps: [], pageData: null, @@ -55,11 +53,13 @@ export const useAppStore = defineStore('app', { } as AppState; }, actions: { + async prefetch() { + this.pageData = await getPage(); + }, async init() { console.log('app init'); await this.loadApps(); console.log('app init requests completed'); - this.initialized = true; }, async loadApps() { @@ -68,9 +68,6 @@ export const useAppStore = defineStore('app', { }, async getPageData(category: string): Promise { - if (!this.pageData) { - this.pageData = await getPage(); - } if (!this.pageData || this.pageData.length == 0) { return null; }