fix: bug
This commit is contained in:
@@ -429,11 +429,12 @@ const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes: constantRoutes
|
||||
})
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
// token
|
||||
if (!router.options.history.state.back) {
|
||||
getToken();
|
||||
await getToken();
|
||||
}
|
||||
console.log(2);
|
||||
if (!to.meta.noRedirectLogin) {
|
||||
if (window.self === window.top) {
|
||||
// window.parent.location.href = 'https://yip-uat.dctest.digitalyili.com/login';
|
||||
@@ -452,20 +453,19 @@ router.beforeEach((to, from, next) => {
|
||||
next()
|
||||
})
|
||||
|
||||
const getToken = () => {
|
||||
jsonp(jsonpUrl, {
|
||||
appId: "yip",
|
||||
remoteIp: window.returnCitySN?window.returnCitySN["cip"]:"127.0.0.1",
|
||||
callbackQuery: "jsonpCallback",
|
||||
})
|
||||
.then((res) => {
|
||||
localStorage.setItem("plantToken", res.data.tokenid);
|
||||
store.commit("common/M_COMMON_SET_TOKEN", res.data.tokenid);
|
||||
console.log("成功");
|
||||
const getToken = async () => {
|
||||
try {
|
||||
const res = await jsonp(jsonpUrl, {
|
||||
appId: "yip",
|
||||
remoteIp: window.returnCitySN?window.returnCitySN["cip"]:"127.0.0.1",
|
||||
callbackQuery: "jsonpCallback",
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("错误");
|
||||
});
|
||||
localStorage.setItem("plantToken", res.data.tokenid);
|
||||
store.commit("common/M_COMMON_SET_TOKEN", res.data.tokenid);
|
||||
console.log("成功");
|
||||
} catch (error) {
|
||||
console.log("错误");
|
||||
}
|
||||
};
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user