main-web/src/App.vue

45 lines
1.2 KiB
Vue
Raw Normal View History

2024-08-20 12:11:33 +00:00
<template>
2024-08-21 01:17:14 +00:00
<el-config-provider namespace="czhj" :locale="zhCn">
2024-08-20 12:11:33 +00:00
<router-view v-if="showMainApp"></router-view>
<Home v-else-if="getToken()"></Home>
</el-config-provider>
</template>
<script setup lang="ts">
import { onMounted, computed } from 'vue'
import { useStore } from 'vuex'
import { useRoute, useRouter } from 'vue-router'
import { getToken } from '@/utils/auth'
import Home from './layouts/home.vue'
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
const store = useStore()
store.dispatch('GetPageConfigs')
const route = useRoute()
const router = useRouter()
onMounted(() => {
// 偶发后退无效问题 hack
window.addEventListener(
'hashchange',
() => {
const currentPath = window.location.hash.slice(1)
if (route.path !== currentPath) {
router.push(currentPath)
}
},
false
)
// 移除loading
setTimeout(() => {
const el = document.getElementsByClassName('loading')[0]
;(el?.parentElement as HTMLElement)?.removeChild(el)
}, 1000 * 2)
})
const showMainApp = computed(() => {
return ['/login', '/sso', '/lockme', '/redirect', '/404', '/license', '/jump'].includes(route.path)
})
</script>
<style lang="scss">
@import './css/index.scss';
</style>