App.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <div id="app">
  3. <router-view class="router-view" v-slot="{ Component }">
  4. <transition :name="transitionName">
  5. <!-- 缓存组件,但是进入编辑页面就会有问题 -->
  6. <!-- <keep-alive include="device,deviceSet,role"><component :is="Component" /></keep-alive> -->
  7. <component :is="Component" v-if="!$route.meta.keepAlive" />
  8. </transition>
  9. <keep-alive>
  10. <component :is="Component" v-if="$route.meta.keepAlive" />
  11. </keep-alive>
  12. </router-view>
  13. </div>
  14. </template>
  15. <script>
  16. import { reactive, toRefs } from "vue";
  17. import { useRouter } from "vue-router";
  18. import { getLocal } from "@/common/js/utils";
  19. export default {
  20. setup() {
  21. const router = useRouter();
  22. const state = reactive({
  23. transitionName: "slide-left",
  24. });
  25. router.beforeEach((to, from, next) => {
  26. const token = getLocal("token");
  27. // token为空跳转登陆页面
  28. if (!token && to.path !== "/login") {
  29. // next(`/login?redirect=${to.fullPath}`)
  30. }
  31. if (to.meta.index > from.meta.index) {
  32. state.transitionName = "slide-left"; // 向左滑动
  33. } else if (to.meta.index < from.meta.index) {
  34. // 由次级到主级
  35. state.transitionName = "slide-right";
  36. } else {
  37. state.transitionName = ""; // 同级无过渡效果
  38. }
  39. next();
  40. });
  41. return { ...toRefs(state) };
  42. },
  43. };
  44. </script>
  45. <style lang="less">
  46. // 宽度动态
  47. // width: -moz-calc(100% - 70px);
  48. // width: -webkit-calc(100% - 70px);
  49. // width: calc(100% - 70px);
  50. /* 导入全局样式 */
  51. @import "./common/style/global.less";
  52. // 改变全局vant的样式
  53. :root {
  54. --van-blue: #4d6add !important;
  55. --vangreen: #4d6add !important;
  56. --van-field-label-color: #404d74 !important;
  57. }
  58. .cust_vantBorder {
  59. .van-cell {
  60. display: flex;
  61. align-items: center;
  62. }
  63. // .van-field__value {
  64. // border: 1px solid #b9bad0;
  65. // border-radius: 2px;
  66. // height: 38px;
  67. // line-height: 38px;
  68. // padding-left: 6px;
  69. // }
  70. .van-field__body {
  71. border: 1px solid #dddde8;
  72. border-radius: 2px;
  73. height: 38px;
  74. line-height: 38px;
  75. padding-left: 6px;
  76. }
  77. }
  78. // 下边框线条
  79. .kBordBott {
  80. border-bottom: 1px solid #fafafd;
  81. }
  82. html,
  83. body,
  84. #app,
  85. div,
  86. span,
  87. p {
  88. // color: #404d74 !important;
  89. }
  90. html {
  91. height: 100%;
  92. // overflow: hidden;
  93. }
  94. body {
  95. height: 100%;
  96. // overflow-x: hidden;
  97. // overflow-y: auto;
  98. }
  99. #app {
  100. height: 100%;
  101. font-family: "Avenir", Helvetica, Arial, sans-serif;
  102. -webkit-font-smoothing: antialiased;
  103. -moz-osx-font-smoothing: grayscale;
  104. // text-align: center;
  105. color: #2c3e50;
  106. }
  107. .router-view {
  108. width: 100%;
  109. height: auto;
  110. position: absolute;
  111. top: 0;
  112. bottom: 0;
  113. margin: 0 auto;
  114. -webkit-overflow-scrolling: touch;
  115. }
  116. .slide-right-enter-active,
  117. .slide-right-leave-active,
  118. .slide-left-enter-active,
  119. .slide-left-leave-active {
  120. height: 100%;
  121. will-change: transform;
  122. transition: all 500ms;
  123. position: absolute;
  124. backface-visibility: hidden;
  125. }
  126. .slide-right-enter {
  127. opacity: 0;
  128. transform: translate3d(-100%, 0, 0);
  129. }
  130. .slide-right-leave-active {
  131. opacity: 0;
  132. transform: translate3d(100%, 0, 0);
  133. }
  134. .slide-left-enter {
  135. opacity: 0;
  136. transform: translate3d(100%, 0, 0);
  137. }
  138. .slide-left-leave-active {
  139. opacity: 0;
  140. transform: translate3d(-100%, 0, 0);
  141. }
  142. .van-badge--fixed {
  143. z-index: 1000;
  144. }
  145. /* 滚动条样式 */
  146. ::-webkit-scrollbar {
  147. /* 1 */
  148. width: 8px;
  149. height: 8px;
  150. background: linear-gradient(to right,
  151. transparent 3px,
  152. #565656 4px,
  153. transparent 6px),
  154. linear-gradient(to bottom, transparent 3px, #565656 4px, transparent 6px);
  155. }
  156. ::-webkit-scrollbar-button {
  157. /* 2 */
  158. width: 8px;
  159. height: 8px;
  160. border-radius: 2px;
  161. background-color: #0667a0;
  162. }
  163. ::-webkit-scrollbar-button:hover {
  164. background-color: #29a7f0;
  165. cursor: pointer;
  166. }
  167. ::-webkit-scrollbar-thumb {
  168. /* 5 */
  169. background-color: #006ac7;
  170. border-radius: 2px;
  171. }
  172. ::-webkit-scrollbar-corner {
  173. /* 6 */
  174. width: 8px;
  175. height: 8px;
  176. border-radius: 50%;
  177. background-color: #565656;
  178. }
  179. ::-webkit-scrollbar {
  180. &-thumb {
  181. border-radius: 10px;
  182. background-color: #d2d2d2;
  183. &:hover {
  184. background-color: #bfbfbf;
  185. // background: #A7A7A7;
  186. }
  187. }
  188. &-button {
  189. display: none;
  190. }
  191. &-track {
  192. background: #eee;
  193. border-radius: 10px;
  194. }
  195. }
  196. </style>