App.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <el-config-provider :locale="lang">
  3. <Suspense>
  4. <router-view></router-view>
  5. </Suspense>
  6. <keep-alive>
  7. <Unity v-if="route.path === '/home'" />
  8. </keep-alive>
  9. </el-config-provider>
  10. </template>
  11. <script setup lang="ts">
  12. import { onMounted, watch } from 'vue'
  13. import { useI18n } from 'vue-i18n'
  14. import iconfontInit from '/@/utils/iconfont'
  15. import { useRoute } from 'vue-router'
  16. import { setTitleFromRoute } from '/@/utils/common'
  17. import { useConfig } from '/@/stores/config'
  18. import { useTerminal } from '/@/stores/terminal'
  19. // modules import mark, Please do not remove.
  20. const config = useConfig()
  21. const route = useRoute()
  22. const terminal = useTerminal()
  23. // 初始化 element 的语言包
  24. const { getLocaleMessage } = useI18n()
  25. const lang = getLocaleMessage(config.lang.defaultLang) as any
  26. onMounted(() => {
  27. iconfontInit()
  28. terminal.init()
  29. // Modules onMounted mark, Please do not remove.
  30. })
  31. // 监听路由变化时更新浏览器标题
  32. watch(
  33. () => route.path,
  34. () => {
  35. setTitleFromRoute()
  36. if( route.path === '/yiqi'){
  37. document.getElementById('app')!.style.setProperty("background","rgb(0,17,52)","important");
  38. // document.getElementById('app')!.style.setProperty("background","#000f2e","important");
  39. }else if(route.path === '/home'){
  40. document.getElementById('app')!.style.setProperty("background","none","important");
  41. }
  42. else {
  43. document.getElementById('app')!.style.setProperty("background","#f5f5f5","important");
  44. }
  45. }
  46. ,{immediate: true}
  47. )
  48. </script>