App.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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': '#075985',
  51. }
  52. setTimeout(() => {
  53. this.colorChange(colorType[type])
  54. }, 0)
  55. if(type == 'dark') {
  56. document.title = '临床工时通'
  57. }
  58. window.document.documentElement.setAttribute( "data-theme", type );
  59. },
  60. colorChange(color) {
  61. this.color = color;
  62. },
  63. setItemFirstTourFalse() {
  64. localStorage.setItem('firstTourFalse', firstTourFalse)
  65. },
  66. reloads(){
  67. this.isRouterAlive = false
  68. this.$nextTick(() => {
  69. this.isRouterAlive = true
  70. })
  71. }
  72. }
  73. }
  74. </script>
  75. <style>
  76. .v-tour__target--highlighted {
  77. box-shadow: 0 0 0 99999px rgba(0,0,0,.4) !important;
  78. }
  79. .el-tree-resetStyles .el-tree-node__content {
  80. height: auto !important;
  81. }
  82. </style>
  83. <style lang="scss">
  84. body {
  85. margin: 0px;
  86. padding: 0px;
  87. font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
  88. font-size: 14px;
  89. -webkit-font-smoothing: antialiased;
  90. }
  91. #app {
  92. position: absolute;
  93. top: 0px;
  94. bottom: 0px;
  95. width: 100%;
  96. }
  97. .el-submenu [class^=fa] {
  98. vertical-align: baseline;
  99. margin-right: 10px;
  100. }
  101. .el-menu-item [class^=fa] {
  102. vertical-align: baseline;
  103. margin-right: 10px;
  104. }
  105. .toolbar {
  106. background: #f2f2f2;
  107. padding: 10px;
  108. .el-form-item {
  109. margin-bottom: 10px;
  110. }
  111. }
  112. .fade-enter-active,
  113. .fade-leave-active {
  114. transition: all .2s ease;
  115. }
  116. .fade-enter,
  117. .fade-leave-active {
  118. opacity: 0;
  119. }
  120. .resetElEmtClass {
  121. .el-dialog__body {
  122. padding: 0 !important;
  123. }
  124. }
  125. </style>