App.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. provide<GlobalPopup>('globalPopup', {
  19. showSuccess: (message?: string) => {
  20. notificationTiop({
  21. message: message || '成功',
  22. type: 'success',
  23. title: "提示",
  24. duration: 2000
  25. })
  26. }, //!SECTION 成功
  27. showError: (message?: string) => notificationTiop({
  28. message: message || '失败',
  29. type: 'error',
  30. title: "提示",
  31. duration: 2000
  32. }), //!SECTION 失败
  33. showWarning: (message: string) => notificationTiop({
  34. message,
  35. type: 'warning',
  36. title: "提示",
  37. duration: 2000
  38. }), //!SECTION 警告
  39. showInfo: (message: string) => notificationTiop({
  40. message,
  41. type: 'info',
  42. title: "提示",
  43. duration: 2000
  44. }), //!SECTION 文本
  45. })
  46. const notificationTiop = (options: NotificationParamsTyped) => {
  47. ElNotification.closeAll()
  48. ElNotification(options)
  49. }
  50. onMounted(() => {
  51. // 重置 primary 主题颜色
  52. document.body.style.setProperty('--el-color-primary', '#075985')
  53. document.body.style.setProperty('--el-color-primary-light-3', '#518baa')
  54. document.body.style.setProperty('--el-color-primary-light-5', '#83acc2')
  55. document.body.style.setProperty('--el-color-primary-light-7', '#b5cdda')
  56. document.body.style.setProperty('--el-color-primary-light-8', '#cddee7')
  57. document.body.style.setProperty('--el-color-primary-light-9', '#e6eef3')
  58. document.body.style.setProperty('--el-color-primary-dark-2', '#06476a')
  59. })
  60. </script>
  61. <style lang="scss">
  62. html,
  63. body,
  64. #app,
  65. .layouts {
  66. width: 100%;
  67. height: 100%;
  68. /* overflow: hidden; */
  69. min-width: 800px;
  70. }
  71. * {
  72. font-family: '微软雅黑';
  73. }
  74. /* home 页面的动画 */
  75. .router_animate-enter-active {
  76. animation: slideInLeft 0.5s;
  77. }
  78. .router_animate-leave-active {
  79. animation: slideOutLeft 0s;
  80. }
  81. /* app 路由动画 */
  82. .ranimate-enter-active {
  83. animation: fadeIn 1s;
  84. }
  85. .ranimate-leave-active {
  86. animation: fadeIn 0s;
  87. }
  88. .drawerVisClass {
  89. .el-drawer__body {
  90. padding: 0 !important;
  91. }
  92. }
  93. </style>