App.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <!-- <router-view></router-view> -->
  3. <router-view v-slot="{ Component }">
  4. <transition name="ranimate">
  5. <component :is="Component" />
  6. </transition>
  7. </router-view>
  8. </template>
  9. <script setup lang="ts">
  10. import { provide, onMounted } from 'vue'
  11. import { useStore } from '@/store/index'
  12. import { ElNotification, NotificationParamsTyped } from 'element-plus'
  13. const { setAsyncRoutesMark } = useStore()
  14. window.addEventListener('beforeunload', () => beforeunloadFn())
  15. const beforeunloadFn = (() => {
  16. setAsyncRoutesMark(false)
  17. })
  18. // 消息提示弹窗
  19. provide<GlobalPopup>('globalPopup', {
  20. showSuccess: (message?: string) => {
  21. notificationTiop({
  22. message: message || '成功',
  23. type: 'success',
  24. title: "提示",
  25. duration: 2000
  26. })
  27. }, //!SECTION 成功
  28. showError: (message?: string) => notificationTiop({
  29. message: message || '失败',
  30. type: 'error',
  31. title: "提示",
  32. duration: 2000
  33. }), //!SECTION 失败
  34. showWarning: (message: string) => notificationTiop({
  35. message,
  36. type: 'warning',
  37. title: "提示",
  38. duration: 2000
  39. }), //!SECTION 警告
  40. showInfo: (message: string) => notificationTiop({
  41. message,
  42. type: 'info',
  43. title: "提示",
  44. duration: 2000
  45. }), //!SECTION 文本
  46. })
  47. const notificationTiop = (options: NotificationParamsTyped) => {
  48. ElNotification.closeAll()
  49. ElNotification(options)
  50. }
  51. onMounted(() => {
  52. // 重置 primary 主题颜色
  53. document.body.style.setProperty('--el-color-primary', '#075985')
  54. document.body.style.setProperty('--el-color-primary-light-3', '#518baa')
  55. document.body.style.setProperty('--el-color-primary-light-5', '#83acc2')
  56. document.body.style.setProperty('--el-color-primary-light-7', '#b5cdda')
  57. document.body.style.setProperty('--el-color-primary-light-8', '#cddee7')
  58. document.body.style.setProperty('--el-color-primary-light-9', '#e6eef3')
  59. document.body.style.setProperty('--el-color-primary-dark-2', '#06476a')
  60. })
  61. </script>
  62. <style lang="scss">
  63. html,
  64. body,
  65. #app,
  66. .layouts {
  67. width: 100%;
  68. height: 100%;
  69. overflow: hidden;
  70. min-width: 800px;
  71. }
  72. * {
  73. font-family: '微软雅黑';
  74. }
  75. /* home 页面的动画 */
  76. .router_animate-enter-active {
  77. animation: slideInLeft 0.5s;
  78. }
  79. .router_animate-leave-active {
  80. animation: slideOutLeft 0s;
  81. }
  82. /* app 路由动画 */
  83. .ranimate-enter-active {
  84. animation: fadeIn 1s;
  85. }
  86. .ranimate-leave-active {
  87. animation: fadeIn 0s;
  88. }
  89. .drawerVisClass {
  90. .el-drawer__body {
  91. padding: 0 !important;
  92. }
  93. }
  94. // 重置样式
  95. .el-loading-mask {
  96. z-index: 1900 !important;
  97. }
  98. </style>