App.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 themes = localStorage.getItem('themes') || 'default'
  35. this.switchThemes(themes)
  36. },
  37. mounted() {
  38. this.firstTourFalse = localStorage.getItem('firstTourFalse') | true
  39. // 监听页面刷新事件
  40. window.addEventListener('unload', this.setItemFirstTourFalse)
  41. },
  42. methods:{
  43. switchThemes(type) {
  44. const colorType = {
  45. 'default': '#409EFF',
  46. 'dark': '#FF0000',
  47. }
  48. setTimeout(() => {
  49. this.colorChange(colorType[type])
  50. }, 0)
  51. window.document.documentElement.setAttribute( "data-theme", type );
  52. },
  53. colorChange(color) {
  54. this.color = color;
  55. },
  56. setItemFirstTourFalse() {
  57. localStorage.setItem('firstTourFalse', firstTourFalse)
  58. },
  59. reloads(){
  60. this.isRouterAlive = false
  61. this.$nextTick(() => {
  62. this.isRouterAlive = true
  63. })
  64. }
  65. }
  66. }
  67. </script>
  68. <style>
  69. .v-tour__target--highlighted {
  70. box-shadow: 0 0 0 99999px rgba(0,0,0,.4) !important;
  71. }
  72. </style>
  73. <style lang="scss">
  74. body {
  75. margin: 0px;
  76. padding: 0px;
  77. font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
  78. font-size: 14px;
  79. -webkit-font-smoothing: antialiased;
  80. }
  81. #app {
  82. position: absolute;
  83. top: 0px;
  84. bottom: 0px;
  85. width: 100%;
  86. }
  87. .el-submenu [class^=fa] {
  88. vertical-align: baseline;
  89. margin-right: 10px;
  90. }
  91. .el-menu-item [class^=fa] {
  92. vertical-align: baseline;
  93. margin-right: 10px;
  94. }
  95. .toolbar {
  96. background: #f2f2f2;
  97. padding: 10px;
  98. .el-form-item {
  99. margin-bottom: 10px;
  100. }
  101. }
  102. .fade-enter-active,
  103. .fade-leave-active {
  104. transition: all .2s ease;
  105. }
  106. .fade-enter,
  107. .fade-leave-active {
  108. opacity: 0;
  109. }
  110. .resetElEmtClass {
  111. .el-dialog__body {
  112. padding: 0 !important;
  113. }
  114. }
  115. </style>