App.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. <Setings ref="setingsRef" />
  5. <Upgrade v-if="isVersion" />
  6. </div>
  7. </template>
  8. <script>
  9. import { on, off } from 'iview/src/utils/dom';
  10. import { setMatchMedia } from 'iview/src/utils/assist';
  11. import { mapMutations } from 'vuex';
  12. import Setings from '@/layout/navBars/breadcrumb/setings.vue';
  13. import Upgrade from '@/layout/upgrade/index.vue';
  14. import setting from './setting';
  15. import { Local } from '@/utils/storage.js';
  16. import config from '../package.json';
  17. setMatchMedia();
  18. export default {
  19. name: 'app',
  20. components: { Setings, Upgrade },
  21. provide() {
  22. return {
  23. reload: this.reload,
  24. };
  25. },
  26. data() {
  27. return {
  28. isVersion: false,
  29. };
  30. },
  31. methods: {
  32. ...mapMutations('media', ['setDevice']),
  33. handleWindowResize() {
  34. this.handleMatchMedia();
  35. },
  36. handleMatchMedia() {
  37. const matchMedia = window.matchMedia;
  38. if (matchMedia('(max-width: 600px)').matches) {
  39. var deviceWidth = document.documentElement.clientWidth || window.innerWidth;
  40. let css = 'calc(100vw/7.5)';
  41. document.documentElement.style.fontSize = css;
  42. this.setDevice('Mobile');
  43. } else if (matchMedia('(max-width: 992px)').matches) {
  44. this.setDevice('Tablet');
  45. } else {
  46. this.setDevice('Desktop');
  47. }
  48. },
  49. reload() {
  50. this.isRouterAlive = false;
  51. this.$nextTick(function () {
  52. this.isRouterAlive = true;
  53. });
  54. },
  55. // 布局配置弹窗打开
  56. openSetingsDrawer() {
  57. this.bus.$on('openSetingsDrawer', () => {
  58. this.$refs.setingsRef.openDrawer();
  59. });
  60. },
  61. // 获取缓存中的布局配置
  62. getLayoutThemeConfig() {
  63. if (Local.get('themeConfigPrev')) {
  64. this.$store.dispatch('themeConfig/setThemeConfig', Local.get('themeConfigPrev'));
  65. document.documentElement.style.cssText = Local.get('themeConfigStyle');
  66. } else {
  67. Local.set('themeConfigPrev', this.$store.state.themeConfig.themeConfig);
  68. }
  69. },
  70. getVersion() {
  71. this.isVersion = false;
  72. if (this.$route.path !== `${setting.routePre}/login` && this.$route.path !== '/') {
  73. if ((Local.get('version') && Local.get('version') !== config.version) || !Local.get('version'))
  74. this.isVersion = true;
  75. }
  76. },
  77. },
  78. mounted() {
  79. on(window, 'resize', this.handleWindowResize);
  80. this.handleMatchMedia();
  81. this.openSetingsDrawer();
  82. this.getLayoutThemeConfig();
  83. this.$nextTick((e) => {
  84. // this.getVersion();
  85. });
  86. },
  87. beforeDestroy() {
  88. off(window, 'resize', this.handleWindowResize);
  89. },
  90. destroyed() {
  91. this.bus.$off('openSetingsDrawer');
  92. },
  93. };
  94. </script>
  95. <style lang="less">
  96. .size {
  97. width: 100%;
  98. height: 100%;
  99. }
  100. html,
  101. body {
  102. .size;
  103. overflow: hidden;
  104. margin: 0;
  105. padding: 0;
  106. }
  107. #app {
  108. .size;
  109. font-family: PingFang SC, Arial, Microsoft YaHei, sans-serif;
  110. }
  111. .dialog-fade-enter-active {
  112. animation: anim-open 0.3s;
  113. }
  114. .dialog-fade-leave-active {
  115. animation: anim-close 0.3s;
  116. }
  117. @keyframes anim-open {
  118. 0% {
  119. transform: translate3d(100%, 0, 0);
  120. opacity: 0;
  121. }
  122. 100% {
  123. transform: translate3d(0, 0, 0);
  124. opacity: 1;
  125. }
  126. }
  127. @keyframes anim-close {
  128. 0% {
  129. transform: translate3d(0, 0, 0);
  130. opacity: 1;
  131. }
  132. 100% {
  133. transform: translate3d(100%, 0, 0);
  134. opacity: 0;
  135. }
  136. }
  137. .ivu-modal-wrap /deep/ .connect_customerServer_img {
  138. display: none;
  139. }
  140. .right-box .ivu-color-picker .ivu-select-dropdown {
  141. position: absolute;
  142. // width: 300px !important;
  143. left: -73px !important;
  144. }
  145. </style>