App.vue 2.4 KB

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