App.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. import { on, off } from 'iview/src/utils/dom';
  8. import { setMatchMedia } from 'iview/src/utils/assist';
  9. import { mapMutations } from 'vuex';
  10. setMatchMedia();
  11. export default {
  12. name: 'app',
  13. provide() {
  14. return {
  15. reload: this.reload,
  16. };
  17. },
  18. methods: {
  19. ...mapMutations('media', ['setDevice']),
  20. handleWindowResize() {
  21. this.handleMatchMedia();
  22. },
  23. handleMatchMedia() {
  24. const matchMedia = window.matchMedia;
  25. if (matchMedia('(max-width: 600px)').matches) {
  26. var deviceWidth = document.documentElement.clientWidth || window.innerWidth;
  27. let css = 'calc(100vw/7.5)';
  28. document.documentElement.style.fontSize = css;
  29. this.setDevice('Mobile');
  30. } else if (matchMedia('(max-width: 992px)').matches) {
  31. this.setDevice('Tablet');
  32. } else {
  33. this.setDevice('Desktop');
  34. }
  35. },
  36. reload() {
  37. this.isRouterAlive = false;
  38. this.$nextTick(function () {
  39. this.isRouterAlive = true;
  40. });
  41. },
  42. },
  43. mounted() {
  44. on(window, 'resize', this.handleWindowResize);
  45. this.handleMatchMedia();
  46. },
  47. beforeDestroy() {
  48. off(window, 'resize', this.handleWindowResize);
  49. },
  50. };
  51. </script>
  52. <style lang="less">
  53. .size {
  54. width: 100%;
  55. height: 100%;
  56. }
  57. html,
  58. body {
  59. .size;
  60. overflow: hidden;
  61. margin: 0;
  62. padding: 0;
  63. }
  64. #app {
  65. .size;
  66. }
  67. .dialog-fade-enter-active {
  68. animation: anim-open 0.3s;
  69. }
  70. .dialog-fade-leave-active {
  71. animation: anim-close 0.3s;
  72. }
  73. @keyframes anim-open {
  74. 0% {
  75. transform: translate3d(100%, 0, 0);
  76. opacity: 0;
  77. }
  78. 100% {
  79. transform: translate3d(0, 0, 0);
  80. opacity: 1;
  81. }
  82. }
  83. @keyframes anim-close {
  84. 0% {
  85. transform: translate3d(0, 0, 0);
  86. opacity: 1;
  87. }
  88. 100% {
  89. transform: translate3d(100%, 0, 0);
  90. opacity: 0;
  91. }
  92. }
  93. .ivu-modal-wrap /deep/ .connect_customerServer_img {
  94. display: none;
  95. }
  96. .right-box .ivu-color-picker .ivu-select-dropdown {
  97. position: absolute;
  98. // width: 300px !important;
  99. left: -73px !important;
  100. }
  101. </style>