diff --git a/src/App.vue b/src/App.vue index 85ab498..edce67b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,6 +10,7 @@ import { storeToRefs } from 'pinia' import { useSearchHistory } from './composables/useSearchHistory' import type { LocaleCode } from './plugins/i18n' import Toast from './components/Toast.vue' +import { getPmTagMain } from './api/category' const route = useRoute() const { t } = useI18n() @@ -19,7 +20,7 @@ const localeStore = useLocaleStore() const menuStore = useMenuStore() const localeMenuOpen = ref(false) -const { categoryLayers, layerActiveValues } = storeToRefs(menuStore) +const { categoryTree, categoryLayers, layerActiveValues } = storeToRefs(menuStore) const searchHistory = useSearchHistory() const searchHistoryList = computed(() => searchHistory.list.value) const searchExpanded = ref(false) @@ -105,8 +106,15 @@ function selectHistoryItem(item: string) { onSearchSubmit() } -onMounted(() => { - refreshUserData() +onMounted(async () => { + await nextTick() + console.log('app onMounted') + if (layerActiveValues.value.length == 0) { + const res = await getPmTagMain() + if (res.code === 0 || res.code === 200) { + categoryTree.value = res.data + } + } }) watch( () => userStore.isLoggedIn, @@ -115,11 +123,19 @@ watch( }, { immediate: true }, ) + +async function onMenuClick(id: string) { + if (currentRoute.value != '/') { + router.push('/') + } + await nextTick() + menuStore.onCategorySelect(0, id) +}