index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <el-container class="layout-container" :class="{ blur: mainContainer.isBlur }">
  3. <el-header class="layout-header">
  4. <div class="title-container">
  5. <span v-for="item in title" class="title-text">{{ item }}</span>
  6. </div>
  7. </el-header>
  8. <el-main class="layout-main">
  9. <el-scrollbar class="layout-main-scrollbar" ref="mainScrollbarRef">
  10. <router-view v-slot="{ Component }">
  11. <transition name="el-zoom-in-center" mode="out-in">
  12. <keep-alive :include="state.keepAliveComponentNameList">
  13. <component :is="Component" :key="state.componentKey" />
  14. </keep-alive>
  15. </transition>
  16. </router-view>
  17. </el-scrollbar>
  18. </el-main>
  19. </el-container>
  20. </template>
  21. <script lang="ts" setup>
  22. import { reactive, ref, onBeforeMount, onMounted, provide } from 'vue';
  23. import { useRoute } from 'vue-router';
  24. import { useUserInfo } from '@/stores/userInfo';
  25. import router from '@/router/index';
  26. const userInfo = useUserInfo();
  27. const route = useRoute();
  28. const title = ref('排水管网运维养护虚拟仿真教学平台');
  29. const state: {
  30. componentKey: string;
  31. keepAliveComponentNameList: string[];
  32. } = reactive({
  33. componentKey: route.path,
  34. keepAliveComponentNameList: [],
  35. });
  36. const mainContainer = reactive({
  37. isBlur: false,
  38. });
  39. provide('mainContainer', mainContainer);
  40. onBeforeMount(() => {
  41. if (userInfo.userType != 0) {
  42. userInfo.removeToken();
  43. router.push({ path: '/' });
  44. }
  45. });
  46. onMounted(() => {
  47. if (route.path == '/train') {
  48. router.push({ path: '/train/list' });
  49. }
  50. });
  51. </script>
  52. <style lang="scss" scoped>
  53. .layout-container {
  54. height: 100%;
  55. width: 100%;
  56. background-image: url(/src/assets/student/bg.jpg);
  57. background-size: 100% auto;
  58. background-repeat: no-repeat;
  59. background-position: center center;
  60. background-color: #000911;
  61. &.blur {
  62. filter: blur(20px);
  63. }
  64. .el-main {
  65. padding: 0;
  66. }
  67. }
  68. .layout-header {
  69. background-image: url(/src/assets/student/header.png);
  70. background-size: 100% 100%;
  71. text-align: center;
  72. height: 6rem;
  73. line-height: 5rem;
  74. font-size: 2rem;
  75. color: white;
  76. position: relative;
  77. z-index: 2;
  78. }
  79. @keyframes fadeIn {
  80. 0% {
  81. opacity: 0;
  82. transform: translateY(-2rem);
  83. }
  84. 100% {
  85. opacity: 1;
  86. transform: translateY(0);
  87. }
  88. }
  89. .title-text {
  90. display: inline-block;
  91. animation-name: fadeIn;
  92. animation-duration: 1s;
  93. animation-timing-function: ease;
  94. animation-fill-mode: both;
  95. }
  96. @for $i from 1 through 16 {
  97. .title-text:nth-child(#{$i}) {
  98. animation-delay: #{$i * 0.05}s;
  99. }
  100. }
  101. </style>