App.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. <Setings ref="setingsRef" />
  5. <!-- 检测版本更新 -->
  6. <!-- <Upgrade v-if="isVersion" /> -->
  7. </div>
  8. </template>
  9. <script>
  10. import { mapMutations } from 'vuex';
  11. import Setings from '@/layout/navBars/breadcrumb/setings.vue';
  12. import Upgrade from '@/layout/upgrade/index.vue';
  13. import setting from './setting';
  14. import { Local } from '@/utils/storage.js';
  15. import config from '../package.json';
  16. export default {
  17. name: 'app',
  18. components: { Setings, Upgrade },
  19. provide() {
  20. return {
  21. reload: this.reload,
  22. };
  23. },
  24. data() {
  25. return {
  26. isVersion: false,
  27. };
  28. },
  29. methods: {
  30. ...mapMutations('media', ['setDevice']),
  31. handleWindowResize() {
  32. this.handleMatchMedia();
  33. },
  34. handleMatchMedia() {
  35. const matchMedia = window.matchMedia;
  36. if (matchMedia('(max-width: 600px)').matches) {
  37. var deviceWidth = document.documentElement.clientWidth || window.innerWidth;
  38. let css = 'calc(100vw/7.5)';
  39. document.documentElement.style.fontSize = css;
  40. this.setDevice('Mobile');
  41. } else if (matchMedia('(max-width: 992px)').matches) {
  42. this.setDevice('Tablet');
  43. } else {
  44. this.setDevice('Desktop');
  45. }
  46. },
  47. reload() {
  48. this.isRouterAlive = false;
  49. this.$nextTick(() => {
  50. this.isRouterAlive = true;
  51. });
  52. },
  53. // 布局配置弹窗打开
  54. openSetingsDrawer() {
  55. this.bus.$on('openSetingsDrawer', () => {
  56. this.$refs.setingsRef.openDrawer();
  57. });
  58. },
  59. // 获取缓存中的布局配置
  60. getLayoutThemeConfig() {
  61. if (Local.get('themeConfigPrev')) {
  62. this.$store.dispatch('themeConfig/setThemeConfig', Local.get('themeConfigPrev'));
  63. document.documentElement.style.cssText = Local.get('themeConfigStyle');
  64. } else {
  65. Local.set('themeConfigPrev', this.$store.state.themeConfig.themeConfig);
  66. }
  67. },
  68. getVersion() {
  69. this.isVersion = false;
  70. if (this.$route.path !== `${setting.routePre}/login` && this.$route.path !== '/') {
  71. if ((Local.get('version') && Local.get('version') !== config.version) || !Local.get('version'))
  72. this.isVersion = true;
  73. }
  74. },
  75. },
  76. mounted() {
  77. this.handleMatchMedia();
  78. this.openSetingsDrawer();
  79. this.getLayoutThemeConfig();
  80. this.$nextTick((e) => {
  81. // this.getVersion();
  82. });
  83. },
  84. destroyed() {
  85. this.bus.$off('openSetingsDrawer');
  86. },
  87. };
  88. </script>
  89. <style type="text/css">
  90. .icon {
  91. width: 1em;
  92. height: 1em;
  93. vertical-align: -0.15em;
  94. fill: currentColor;
  95. overflow: hidden;
  96. }
  97. </style>
  98. <style lang="scss">
  99. html,
  100. body {
  101. width: 100%;
  102. height: 100%;
  103. overflow: hidden;
  104. margin: 0;
  105. padding: 0;
  106. }
  107. #app {
  108. width: 100%;
  109. height: 100%;
  110. font-family: PingFang SC, Arial, Microsoft YaHei, sans-serif;
  111. }
  112. .right-box .ivu-color-picker .ivu-select-dropdown {
  113. position: absolute;
  114. // width: 300px !important;
  115. left: -73px !important;
  116. }
  117. </style>