|
@@ -11,33 +11,45 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-
|
|
|
<script>
|
|
|
-import { queryUserInfo } from '@/api/app'
|
|
|
+import { queryUserInfo } from "@/api/app";
|
|
|
export default {
|
|
|
- name: 'app',
|
|
|
- async created() {
|
|
|
- let params = this.$route.query
|
|
|
- if(params.Authorization) {
|
|
|
- localStorage.setItem('Authorization', decodeURI(params.Authorization))
|
|
|
- localStorage.setItem('userInfo', decodeURI(params.Authorization))
|
|
|
+ name: "app",
|
|
|
+ async created() {
|
|
|
+ try {
|
|
|
+ const Authorization = this.getQueryVariable('Authorization')
|
|
|
+ if (Authorization) {
|
|
|
+ localStorage.setItem("Authorization", decodeURI(Authorization));
|
|
|
+ localStorage.setItem("userInfo", decodeURI(Authorization));
|
|
|
}
|
|
|
- const Authorization = localStorage.getItem('Authorization')
|
|
|
- const userInfo = localStorage.getItem('userInfo')
|
|
|
- if(userInfo || Authorization) {
|
|
|
- await queryUserInfo().then(res => {
|
|
|
- const result = res.data || null
|
|
|
- const tenantId = result.tenantId || 0
|
|
|
- sessionStorage.setItem('tenantId', tenantId)
|
|
|
- })
|
|
|
+ const auth = localStorage.getItem("Authorization");
|
|
|
+ const userInfo = localStorage.getItem("userInfo");
|
|
|
+ if (userInfo || auth) {
|
|
|
+ await queryUserInfo().then((res) => {
|
|
|
+ const result = res.data || null;
|
|
|
+ const tenantId = result.tenantId || 0;
|
|
|
+ sessionStorage.setItem("tenantId", tenantId);
|
|
|
+ });
|
|
|
}
|
|
|
- },
|
|
|
- async mounted() {
|
|
|
- if(document.querySelector('#m_loading')) {
|
|
|
- document.querySelector('#m_loading').remove()
|
|
|
+ } catch(e) {}
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getQueryVariable(variable) {
|
|
|
+ if (window.location.hash.indexOf("?") < 0) {
|
|
|
+ return null;
|
|
|
}
|
|
|
- }
|
|
|
-}
|
|
|
+ let query = window.location.hash.split("?")[1]
|
|
|
+ let vars = query.split("&");
|
|
|
+ for (let i = 0; i < vars.length; i++) {
|
|
|
+ let pair = vars[i].split("=");
|
|
|
+ if (pair[0] == variable) {
|
|
|
+ return pair[1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return (false);
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|