|
|
|
|
@ -24,11 +24,12 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { onMounted, onUnmounted, ref, computed } from 'vue'
|
|
|
|
|
import { onMounted, onUnmounted, ref, computed, watch } from 'vue'
|
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
import { storeToRefs } from 'pinia'
|
|
|
|
|
import { onLocaleChange, offLocaleChange, setNavigationTitle } from '@/locales'
|
|
|
|
|
import useUserStore from '@/store/modules/user'
|
|
|
|
|
import { getFirstTabBarPath } from '@/utils/permissionMenu'
|
|
|
|
|
import NavBar from '@/components/common/NavBar.vue'
|
|
|
|
|
import TabBar from '@/components/common/TabBar.vue'
|
|
|
|
|
import AppEmptyState from '@/components/common/AppEmptyState.vue'
|
|
|
|
|
@ -39,9 +40,10 @@ import QualitySection from '@/components/dashboard/QualitySection.vue'
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
const pageTitle = computed(() => t('nav.home'))
|
|
|
|
|
const HOME_PATH = '/pages/index'
|
|
|
|
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
const { menus } = storeToRefs(userStore)
|
|
|
|
|
const { menus, permissionInfoLoaded } = storeToRefs(userStore)
|
|
|
|
|
|
|
|
|
|
const homeMenu = computed(() => {
|
|
|
|
|
return (menus.value || []).find((m) => m.name === '首页')
|
|
|
|
|
@ -92,6 +94,27 @@ function goTop() {
|
|
|
|
|
scrollTop.value = 0
|
|
|
|
|
}, 0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function redirectIfHomeUnavailable() {
|
|
|
|
|
if (!userStore.token || !permissionInfoLoaded.value) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (homeMenu.value) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const targetPath = getFirstTabBarPath(menus.value)
|
|
|
|
|
if (targetPath && targetPath !== HOME_PATH) {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: targetPath
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch([permissionInfoLoaded, menus], () => {
|
|
|
|
|
redirectIfHomeUnavailable()
|
|
|
|
|
}, { immediate: true })
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|