edu/admin/src/App.vue

45 lines
1.2 KiB
Vue
Raw Normal View History

2022-04-08 02:42:44 +00:00
<template>
2022-04-20 04:10:22 +00:00
<router-view v-if="routerAlive" />
2022-04-08 02:42:44 +00:00
</template>
<script lang="ts">
2022-04-20 04:10:22 +00:00
import { defineComponent, ref, nextTick, provide, onMounted } from 'vue'
2022-04-08 02:42:44 +00:00
import { useAdmin } from './core/hooks/app'
export default defineComponent({
setup() {
const { store, route } = useAdmin()
const routerAlive = ref(true)
const reload = () => {
routerAlive.value = false
nextTick(() => {
routerAlive.value = true
})
}
provide('reload', reload)
onMounted(async () => {
// 获取配置
const data = await store.dispatch('app/getConfig')
console.log('data', data)
2022-04-08 02:42:44 +00:00
// 设置网站logo
let favicon: HTMLLinkElement = document.querySelector('link[rel="icon"]')!
if (favicon) {
2022-04-11 06:58:55 +00:00
favicon.href = data.webFavicon
2022-04-08 02:42:44 +00:00
return
}
favicon = document.createElement('link')
favicon.rel = 'icon'
2022-04-11 06:58:55 +00:00
favicon.href = data.webFavicon
2022-04-08 02:42:44 +00:00
document.head.appendChild(favicon)
})
return {
2022-04-20 04:10:22 +00:00
routerAlive
2022-04-08 02:42:44 +00:00
}
}
})
</script>
<style lang="scss">
@import "./assets/font/iconfont.css";
@import "./styles/index.scss";
2022-04-08 02:42:44 +00:00
</style>