fix: bug
This commit is contained in:
@@ -5,6 +5,11 @@ import TemplateMarket from './route.templateMarket'
|
||||
import Contact from './route.contact'
|
||||
import DocumentLibrary from './route.documentLibrary'
|
||||
import DataStatistics from './route.datastatistics'
|
||||
import { jsonp } from "vue-jsonp";
|
||||
import { jsonpUrl } from "../config.js";
|
||||
import { useStore } from "vuex";
|
||||
|
||||
const store = useStore();
|
||||
|
||||
const constantRoutes = [
|
||||
// {
|
||||
@@ -425,6 +430,10 @@ const router = createRouter({
|
||||
routes: constantRoutes
|
||||
})
|
||||
router.beforeEach((to, from, next) => {
|
||||
// token
|
||||
if (!router.options.history.state.back) {
|
||||
getToken();
|
||||
}
|
||||
if (!to.meta.noRedirectLogin) {
|
||||
if (window.self === window.top) {
|
||||
// window.parent.location.href = 'https://yip-uat.dctest.digitalyili.com/login';
|
||||
@@ -432,7 +441,7 @@ router.beforeEach((to, from, next) => {
|
||||
}
|
||||
if(!to.meta.permission) {
|
||||
next()
|
||||
return
|
||||
return
|
||||
}
|
||||
if(!JSON.parse(localStorage.getItem('plantUserInfo'))[to.meta.permission]) {
|
||||
next({
|
||||
@@ -442,4 +451,21 @@ 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("成功");
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("错误");
|
||||
});
|
||||
};
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user