From 0da4733d765fa6d115da03ba7b14c4bdefd0c1cd Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Mon, 30 Sep 2024 17:41:47 +0800 Subject: [PATCH] 1 --- src/main.js | 36 +++++++++++++++++++++++------------- src/permission.js | 4 +--- src/utils/index.js | 5 +++++ 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/main.js b/src/main.js index 5b694c8..1348c54 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,5 @@ import Vue from 'vue' - +import { getQueryParam } from '@/utils' import 'normalize.css/normalize.css' // A modern alternative to CSS resets import ElementUI from 'element-ui' @@ -75,18 +75,28 @@ if (window.__POWERED_BY_WUJIE__) { window.__WUJIE_UNMOUNT = () => { instance.$destroy(); }; -} else { - if (window.top !== window.self) { - // 当前页面在iframe中 - window._IN_IFRAME = true; - window.addEventListener("message",function (e) { - const { module_name, auth_token } = e.data; - window.MODULE_NAME = module_name; - console.log('token',auth_token) - setToken(auth_token) - router.push('/') - }) - } +} +else if(window.top !== window.self) { + // 当前页面在iframe中 + window._IN_IFRAME = true; + + setToken(getQueryParam('auth_token')) + window.MODULE_NAME = getQueryParam('module_name') + new Vue({ + router, + store, + render: h => h(App) + }).$mount("#app") + router.push('/') + // window.addEventListener("message",function (e) { + // const { module_name, auth_token } = e.data; + // window.MODULE_NAME = module_name; + // console.log('token',auth_token) + // + // }) + +} +else { new Vue({ router, store, diff --git a/src/permission.js b/src/permission.js index ac3a513..ab42591 100644 --- a/src/permission.js +++ b/src/permission.js @@ -3,7 +3,7 @@ import store from './store' import { Message } from 'element-ui' import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style -import { getToken } from '@/utils/auth' // get token from cookie +import { getToken, setToken } from '@/utils/auth' // get token from cookie import getPageTitle from '@/utils/get-page-title' NProgress.configure({ showSpinner: false }) // NProgress Configuration @@ -16,10 +16,8 @@ router.beforeEach(async(to, from, next) => { // set page title document.title = getPageTitle(to.meta.title) - // determine whether the user has logged in const hasToken = getToken() - console.log(4444,hasToken) if (hasToken) { if (to.path === '/login') { // if is logged in, redirect to the home page diff --git a/src/utils/index.js b/src/utils/index.js index 9562b36..5014f54 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -180,3 +180,8 @@ export function throttle(fn, interval, immediate=true) { } } + +export function getQueryParam(param) { + const params = new URLSearchParams(window.location.search.substring(1)); + return params.get(param); +}