App.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 =
  27. document.documentElement.clientWidth || window.innerWidth;
  28. let css = "calc(100vw/7.5)";
  29. document.documentElement.style.fontSize = css;
  30. this.setDevice("Mobile");
  31. } else if (matchMedia("(max-width: 992px)").matches) {
  32. this.setDevice("Tablet");
  33. } else {
  34. this.setDevice("Desktop");
  35. }
  36. },
  37. reload() {
  38. this.isRouterAlive = false;
  39. this.$nextTick(function () {
  40. this.isRouterAlive = true;
  41. });
  42. },
  43. },
  44. mounted() {
  45. on(window, "resize", this.handleWindowResize);
  46. this.handleMatchMedia();
  47. },
  48. beforeDestroy() {
  49. off(window, "resize", this.handleWindowResize);
  50. },
  51. };
  52. </script>
  53. <style lang="less">
  54. .size {
  55. width: 100%;
  56. height: 100%;
  57. }
  58. html,
  59. body {
  60. .size;
  61. overflow: hidden;
  62. margin: 0;
  63. padding: 0;
  64. }
  65. #app {
  66. .size;
  67. }
  68. .dialog-fade-enter-active {
  69. animation: anim-open 0.3s;
  70. }
  71. .dialog-fade-leave-active {
  72. animation: anim-close 0.3s;
  73. }
  74. @keyframes anim-open {
  75. 0% {
  76. transform: translate3d(100%, 0, 0);
  77. opacity: 0;
  78. }
  79. 100% {
  80. transform: translate3d(0, 0, 0);
  81. opacity: 1;
  82. }
  83. }
  84. @keyframes anim-close {
  85. 0% {
  86. transform: translate3d(0, 0, 0);
  87. opacity: 1;
  88. }
  89. 100% {
  90. transform: translate3d(100%, 0, 0);
  91. opacity: 0;
  92. }
  93. }
  94. .ivu-modal-wrap /deep/ .connect_customerServer_img {
  95. display: none;
  96. }
  97. .right-box .ivu-color-picker .ivu-select-dropdown {
  98. position: absolute;
  99. // width: 300px !important;
  100. left: -73px !important;
  101. }
  102. </style>