App.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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(options)
  48. }
  49. onMounted(() => {
  50. // 重置 primary 主题颜色
  51. document.body.style.setProperty('--el-color-primary', '#075985')
  52. document.body.style.setProperty('--el-color-primary-light-3', '#518baa')
  53. document.body.style.setProperty('--el-color-primary-light-5', '#83acc2')
  54. document.body.style.setProperty('--el-color-primary-light-7', '#b5cdda')
  55. document.body.style.setProperty('--el-color-primary-light-8', '#cddee7')
  56. document.body.style.setProperty('--el-color-primary-light-9', '#e6eef3')
  57. document.body.style.setProperty('--el-color-primary-dark-2', '#06476a')
  58. })
  59. </script>
  60. <style lang="scss">
  61. html,
  62. body,
  63. #app,
  64. .layouts {
  65. width: 100%;
  66. height: 100%;
  67. /* overflow: hidden; */
  68. min-width: 800px;
  69. }
  70. * {
  71. font-family: '微软雅黑';
  72. }
  73. /* home 页面的动画 */
  74. .router_animate-enter-active {
  75. animation: slideInLeft 0.5s;
  76. }
  77. .router_animate-leave-active {
  78. animation: slideOutLeft 0s;
  79. }
  80. /* app 路由动画 */
  81. .ranimate-enter-active {
  82. animation: fadeIn 1s;
  83. }
  84. .ranimate-leave-active {
  85. animation: fadeIn 0s;
  86. }
  87. .drawerVisClass {
  88. .el-drawer__body {
  89. padding: 0 !important;
  90. }
  91. }
  92. </style>