App.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div id="app">
  3. <v-tour name="myTour" :steps="steps" :options="myOptions" :callbacks="myCallbacks" v-if="tourFlg"></v-tour>
  4. <transition name="fade" mode="out-in">
  5. <!-- <keep-alive>
  6. <router-view v-if='$route.meta != null && $route.meta.keepAlive'/>
  7. </keep-alive> -->
  8. <router-view v-if="isRouterAlive"/>
  9. </transition>
  10. <themeCom :color="color" @color-update="colorChange" v-show="false" />
  11. </div>
  12. </template>
  13. <script>
  14. import themeCom from "@/components/themeCom";
  15. export default {
  16. name: 'app',
  17. components: {
  18. themeCom
  19. },
  20. //父组件中返回要传给下级的数据
  21. provide() {
  22. return {
  23. reloads: this.reloads,
  24. }
  25. },
  26. data(){
  27. return{
  28. isRouterAlive:true,
  29. firstTourFalse: false,
  30. color: '#409EFF'
  31. }
  32. },
  33. created() {
  34. const windowsUrl = location.href
  35. if(windowsUrl.indexOf('style=new') > 0) {
  36. localStorage.setItem('themes', 'dark')
  37. }
  38. const themes = localStorage.getItem('themes') || 'default'
  39. this.switchThemes(themes)
  40. },
  41. mounted() {
  42. this.firstTourFalse = localStorage.getItem('firstTourFalse') | true
  43. // 监听页面刷新事件
  44. window.addEventListener('unload', this.setItemFirstTourFalse)
  45. },
  46. methods:{
  47. switchThemes(type) {
  48. const colorType = {
  49. 'default': '#409EFF',
  50. 'dark': '#FF0000',
  51. }
  52. setTimeout(() => {
  53. this.colorChange(colorType[type])
  54. }, 0)
  55. window.document.documentElement.setAttribute( "data-theme", type );
  56. },
  57. colorChange(color) {
  58. this.color = color;
  59. },
  60. setItemFirstTourFalse() {
  61. localStorage.setItem('firstTourFalse', firstTourFalse)
  62. },
  63. reloads(){
  64. this.isRouterAlive = false
  65. this.$nextTick(() => {
  66. this.isRouterAlive = true
  67. })
  68. }
  69. }
  70. }
  71. </script>
  72. <style>
  73. .v-tour__target--highlighted {
  74. box-shadow: 0 0 0 99999px rgba(0,0,0,.4) !important;
  75. }
  76. </style>
  77. <style lang="scss">
  78. body {
  79. margin: 0px;
  80. padding: 0px;
  81. font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
  82. font-size: 14px;
  83. -webkit-font-smoothing: antialiased;
  84. }
  85. #app {
  86. position: absolute;
  87. top: 0px;
  88. bottom: 0px;
  89. width: 100%;
  90. }
  91. .el-submenu [class^=fa] {
  92. vertical-align: baseline;
  93. margin-right: 10px;
  94. }
  95. .el-menu-item [class^=fa] {
  96. vertical-align: baseline;
  97. margin-right: 10px;
  98. }
  99. .toolbar {
  100. background: #f2f2f2;
  101. padding: 10px;
  102. .el-form-item {
  103. margin-bottom: 10px;
  104. }
  105. }
  106. .fade-enter-active,
  107. .fade-leave-active {
  108. transition: all .2s ease;
  109. }
  110. .fade-enter,
  111. .fade-leave-active {
  112. opacity: 0;
  113. }
  114. .resetElEmtClass {
  115. .el-dialog__body {
  116. padding: 0 !important;
  117. }
  118. }
  119. </style>