App.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import ColFooter from '@/components/col-footer'
  2. import ColHeader from '@/components/col-header'
  3. import { ElConfigProvider, ElDialog } from 'element-plus'
  4. import { zhCn } from '@/helpers/zhCn'
  5. import { defineComponent } from 'vue'
  6. import { RouterView } from 'vue-router'
  7. import Login from './login'
  8. import styles from './App.module.less'
  9. import { getUserInfo, state } from '@/state'
  10. import silder from '@/components/silder'
  11. // 加载样式放到main文件里面会导致打包卡顿,打包时间过长
  12. import '../style/index.css'
  13. import 'normalize.css'
  14. import 'element-plus/dist/index.css'
  15. import 'vue3-lottie/dist/style.css'
  16. import { useSubjectClearly } from '@/helpers/hooks'
  17. export default defineComponent({
  18. components: { silder },
  19. name: 'App',
  20. async created() {
  21. // console.log('user start')
  22. try {
  23. if (state.user.data?.userId) {
  24. // 获取用户信息
  25. await getUserInfo()
  26. } else {
  27. useSubjectClearly()
  28. }
  29. } catch {}
  30. // console.log('user end')
  31. },
  32. render() {
  33. return (
  34. <>
  35. {/* 263.5 footer, 70 header */}
  36. <ColHeader />
  37. <div
  38. style={{
  39. minHeight: 'calc(100vh - 422px)',
  40. background: '#fff'
  41. }}
  42. >
  43. <ElConfigProvider locale={zhCn} message={{ max: 1 }}>
  44. <RouterView></RouterView>
  45. </ElConfigProvider>
  46. </div>
  47. <silder></silder>
  48. <ColFooter />
  49. {/* 登录弹窗 */}
  50. <div class={styles.loginContainer}>
  51. <ElDialog
  52. modelValue={state.loginPopupStatus}
  53. onUpdate:modelValue={val => (state.loginPopupStatus = val)}
  54. closeOnClickModal={false}
  55. closeOnPressEscape={false}
  56. >
  57. {state.loginPopupStatus && (
  58. <Login
  59. onClose={() => {
  60. clearTimeout(state.loginPopupTimer)
  61. state.loginPopupStatus = false
  62. }}
  63. />
  64. )}
  65. </ElDialog>
  66. </div>
  67. </>
  68. )
  69. }
  70. })