App.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div id="app">
  3. <transition name="fade">
  4. <keep-alive>
  5. <router-view v-if="$route.meta.keepAlive" />
  6. </keep-alive>
  7. </transition>
  8. <transition name="fade">
  9. <router-view v-if="!$route.meta.keepAlive" />
  10. </transition>
  11. </div>
  12. </template>
  13. <script>
  14. import { queryUserInfo } from "@/api/app";
  15. export default {
  16. name: "app",
  17. async created() {
  18. try {
  19. let Authorization = this.getQueryVariable('Authorization')
  20. Authorization = Authorization ? Authorization.split('+')[1] : null
  21. if (Authorization) {
  22. localStorage.setItem("Authorization", ('bearer ' + Authorization));
  23. localStorage.setItem("userInfo", ('bearer ' + Authorization));
  24. }
  25. const auth = localStorage.getItem("Authorization");
  26. const userInfo = localStorage.getItem("userInfo");
  27. if (userInfo || auth) {
  28. await queryUserInfo().then((res) => {
  29. const result = res.data || null;
  30. const tenantId = result.tenantId || 0;
  31. sessionStorage.setItem("tenantId", tenantId);
  32. });
  33. }
  34. } catch(e) {}
  35. },
  36. async mounted() {
  37. if(document.querySelector('#m_loading')) {
  38. document.querySelector('#m_loading').remove()
  39. }
  40. },
  41. methods: {
  42. getQueryVariable(variable) {
  43. if (window.location.hash.indexOf("?") < 0) {
  44. return null;
  45. }
  46. let query = window.location.hash.split("?")[1]
  47. let vars = query.split("&");
  48. for (let i = 0; i < vars.length; i++) {
  49. let pair = vars[i].split("=");
  50. if (pair[0] == variable) {
  51. return pair[1];
  52. }
  53. }
  54. return (false);
  55. },
  56. },
  57. };
  58. </script>
  59. <style lang="less">
  60. @import url("./assets/commonLess/common");
  61. #app {
  62. font-family: "Avenir", Helvetica, Arial, sans-serif;
  63. -webkit-font-smoothing: antialiased;
  64. -moz-osx-font-smoothing: grayscale;
  65. background: #f3f4f8;
  66. // overflow-x: hidden;
  67. // overflow-y: auto;
  68. user-select: none;
  69. -webkit-text-size-adjust: none !important;
  70. }
  71. // /deep/.van-icon.van-icon-success{
  72. // }
  73. // .fade-enter-active,
  74. // .fade-leave-active {
  75. // transition: opacity 0.5s;
  76. // }
  77. // .fade-enter,
  78. // .fade-leave-active {
  79. // opacity: 0;
  80. // }
  81. body {
  82. -webkit-text-size-adjust: none !important;
  83. }
  84. </style>