App.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div class="main">
  3. <Header @scroll-update="scrollUpdate"></Header>
  4. <el-scrollbar ref="pagescrollbar" view-style="height:100%">
  5. <router-view />
  6. <Footer></Footer>
  7. </el-scrollbar>
  8. </div>
  9. </template>
  10. <script>
  11. import { defineAsyncComponent } from "vue";
  12. import api from "@/api/common";
  13. export default {
  14. name: "App",
  15. components: {
  16. Header: defineAsyncComponent(() =>
  17. import("@/components/AppVue/Header.vue")
  18. ),
  19. Footer: defineAsyncComponent(() => import("@/components/AppVue/Footer.vue"))
  20. },
  21. mounted() {
  22. let that = this;
  23. document.querySelector("#app").style.transform = `scale(${this.getScale()}) translate(-50%, 0%)`
  24. document.querySelector("#app").style.height = window.innerHeight / this.getScale() + "px"
  25. window.onresize = () => {
  26. document.querySelector("#app").style.transform = `scale(${this.getScale()}) translate(-50%, 0%)`
  27. document.querySelector("#app").style.height = window.innerHeight / this.getScale() + "px"
  28. }
  29. this.$nextTick(() => {
  30. this.scrollUpdate();
  31. });
  32. api.login({
  33. userName: systemConfig.defaultAccount.userName,
  34. password: systemConfig.defaultAccount.password,
  35. clientId: "1",
  36. serviceId: "0",
  37. }).then((result) => {
  38. if (result.code == 200) {
  39. that.$store.commit("setUserInfo", result.content);
  40. that.$store.commit("setToken", result.message);
  41. that.$store.commit("setUserState", true);
  42. } else {
  43. that.$message({
  44. type: "error",
  45. message: result.content,
  46. });
  47. }
  48. }).catch((err) => {
  49. that.$message({
  50. type: "error",
  51. message: "服务器忙碌,请稍后重试!",
  52. });
  53. });
  54. },
  55. methods: {
  56. scrollUpdate() {
  57. let that = this;
  58. setTimeout(() => {
  59. that.$refs.pagescrollbar.update();
  60. }, 1000);
  61. },
  62. getScale() {
  63. const ww = window.innerWidth / 1920
  64. // const wh = window.innerHeight / 945
  65. // return ww < wh ? ww : wh;
  66. return ww
  67. }
  68. }
  69. };
  70. </script>
  71. <style lang="less">
  72. body,
  73. html {
  74. width: 100vw;
  75. height: 100vh;
  76. margin: 0 0;
  77. padding: 0 0;
  78. overflow: hidden;
  79. }
  80. #app {
  81. // width: 100vw;
  82. // height: 100vw;
  83. width: 1920px;
  84. height: 100%;
  85. position: fixed;
  86. left: 50%;
  87. top: 0%;
  88. transform-origin: left top;
  89. transform: translate(-50%, 0%);
  90. }
  91. .main {
  92. width: 100%;
  93. height: 100%;
  94. margin: 0 auto;
  95. overflow: hidden;
  96. .el-scrollbar {
  97. width: 100%;
  98. // height: calc(100% - 90px);
  99. box-sizing: border-box;
  100. overflow: hidden;
  101. }
  102. }
  103. </style>