App.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 } 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. </script>
  50. <style>
  51. html,
  52. body,
  53. #app,
  54. .layouts {
  55. width: 100%;
  56. height: 100%;
  57. /* overflow: hidden; */
  58. min-width: 650px;
  59. }
  60. * {
  61. font-family: '微软雅黑';
  62. }
  63. /* home 页面的动画 */
  64. .router_animate-enter-active {
  65. animation: slideInLeft 0.5s;
  66. }
  67. .router_animate-leave-active {
  68. animation: slideOutLeft 0s;
  69. }
  70. /* app 路由动画 */
  71. .ranimate-enter-active {
  72. animation: fadeIn 1s;
  73. }
  74. .ranimate-leave-active {
  75. animation: fadeIn 0s;
  76. }
  77. </style>