From 36a66a049ede70db1f0cbb39c194bf1747e7958e Mon Sep 17 00:00:00 2001 From: icebergtsn Date: Tue, 3 Sep 2024 19:38:44 +0800 Subject: [PATCH] feat: hide model page --- frontend/src/App.vue | 14 ++---- frontend/src/api/private/user.ts | 4 +- frontend/src/layouts/MainLayout.vue | 10 ++-- .../src/pages/recommend/RecommendPage.vue | 50 +++++++++---------- frontend/src/stores/app.ts | 6 +-- 5 files changed, 40 insertions(+), 44 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 79b2225..505b5b2 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -9,27 +9,21 @@ import { useSocketStore } from 'src/stores/websocketStore'; import { BtNotify, NotifyDefinedType } from '@bytetrade/ui'; import { bus, BUS_EVENT } from 'src/utils/bus'; import { useUserStore } from 'src/stores/user'; -import { useSettingStore } from 'src/stores/setting'; // import { testSatisfies } from 'src/utils/version'; export default { - async preFetch() { - const appStore = useAppStore(); - const userStore = useUserStore(); - const settingStore = useSettingStore(); - await appStore.prefetch(); - userStore.init(); - appStore.init(); - settingStore.init(); - }, setup() { const appStore = useAppStore(); const websocketStore = useSocketStore(); + const userStore = useUserStore(); onMounted(async () => { if (!appStore.isPublic) { // testSatisfies(); websocketStore.start(); + await appStore.prefetch(); + userStore.init(); + appStore.init(); } bus.on(BUS_EVENT.APP_BACKEND_ERROR, onErrorMessage); diff --git a/frontend/src/api/private/user.ts b/frontend/src/api/private/user.ts index 24f9ee0..68ee246 100644 --- a/frontend/src/api/private/user.ts +++ b/frontend/src/api/private/user.ts @@ -93,7 +93,9 @@ export async function getOperateHistory(source: string): Promise { } } -export async function getAppsBriefInfoByStatus(state: APP_STATUS[]) { +export async function getAppsBriefInfoByStatus( + state: APP_STATUS[] +): Promise<[]> { try { const response: any = await axios.get('/app-store/v1/apps/app', { params: { diff --git a/frontend/src/layouts/MainLayout.vue b/frontend/src/layouts/MainLayout.vue index 268edb7..5a85146 100644 --- a/frontend/src/layouts/MainLayout.vue +++ b/frontend/src/layouts/MainLayout.vue @@ -152,12 +152,12 @@ const itemsRef = ref([ label: t('main.recommendation'), key: MENU_TYPE.Application.Recommendation, icon: 'sym_r_featured_play_list' - }, - { - label: t('main.models'), - key: MENU_TYPE.Application.Models, - icon: 'sym_r_neurology' } + // { + // label: t('main.models'), + // key: MENU_TYPE.Application.Models, + // icon: 'sym_r_neurology' + // } ] } ]); diff --git a/frontend/src/pages/recommend/RecommendPage.vue b/frontend/src/pages/recommend/RecommendPage.vue index a8fadac..cb86294 100644 --- a/frontend/src/pages/recommend/RecommendPage.vue +++ b/frontend/src/pages/recommend/RecommendPage.vue @@ -87,8 +87,8 @@ const latestLoading = ref(true); const pageData = ref(); const appStore = useAppStore(); -onMounted(async () => { - await fetchData(true); +onMounted(() => { + fetchData(true); }); async function fetchData(showLoading = false) { @@ -96,31 +96,31 @@ async function fetchData(showLoading = false) { pageLoading.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; - - const latest = pageData.value.find( - (item: any) => item.type === 'Default Topic' && item.id === 'Newest' - ); - if (latest) { - // await Promise.all([ - // getRecommendApps(CATEGORIES_TYPE.SERVER.News), - // getRecommendApps(CATEGORIES_TYPE.SERVER.Sports), - // getRecommendApps(CATEGORIES_TYPE.SERVER.LifeStyle) - // ]).then(([array1, array2, array3]) => { - // latestApps.value = [...array1, ...array2, ...array3]; - // }); - latestApps.value = await getRecommendApps(); + appStore + .getPageData(CATEGORIES_TYPE.LOCAL.ALL) + .then((all) => { + console.log(all); + if (all && all.data) { + pageData.value = all.data; + pageLoading.value = false; + const latest = pageData.value.find( + (item: any) => item.type === 'Default Topic' && item.id === 'Newest' + ); + if (latest) { + getRecommendApps() + .then((data) => { + latestApps.value = data; + }) + .finally(() => { + latestLoading.value = false; + }); + } + } + }) + .finally(() => { latestLoading.value = false; - } - } - pageLoading.value = false; - latestLoading.value = false; + }); } diff --git a/frontend/src/stores/app.ts b/frontend/src/stores/app.ts index 5481887..8f229d3 100644 --- a/frontend/src/stores/app.ts +++ b/frontend/src/stores/app.ts @@ -34,7 +34,7 @@ import { CFG_TYPE } from 'src/constants/config'; export type AppState = { tempAppMap: Record; - pageData: [] | null; + pageData: []; installApps: AppStoreInfo[]; updateApps: AppStoreInfo[]; queue: AsyncQueue; @@ -47,7 +47,7 @@ export const useAppStore = defineStore('app', { tempAppMap: {}, installApps: [], updateApps: [], - pageData: null, + pageData: [], isPublic: !!process.env.PUBLIC_URL, queue: new AsyncQueue() } as AppState; @@ -69,7 +69,7 @@ export const useAppStore = defineStore('app', { async getPageData(category: string): Promise { if (!this.pageData || this.pageData.length == 0) { - return null; + await this.prefetch(); } switch (category) { case CATEGORIES_TYPE.LOCAL.ALL: