App.vue 4.1 KB

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