mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-15 22:06:45 +08:00
---fix bug
This commit is contained in:
@@ -35,3 +35,4 @@ export const USER_PERMISSION = "/admin/thirdApi/permission/listByUser";
|
||||
export const VALIDATE_TOKEN = "/admin/thirdApi/validateToken";
|
||||
export const REFRESH_TOKEN = "/admin/thirdApi/refreshToken";
|
||||
export const LOGOUT = "/admin/thirdApi/logOut";
|
||||
export const USER_INFO = "/admin/CheckUser/userInfo";
|
||||
|
||||
@@ -415,7 +415,7 @@ export async function request(_url, params) {
|
||||
}else if(res.code=== 1001){
|
||||
request(REFRESH_TOKEN).then((res)=>{
|
||||
if(res.code===0 || res.code === 200){
|
||||
setCookie('token',res.data)
|
||||
|
||||
return request(_url, params)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -17,8 +17,7 @@ import "@/assets/scss/common.scss"
|
||||
import Antd from 'ant-design-vue';
|
||||
import 'ant-design-vue/dist/antd.css';
|
||||
import {request} from "@/api/request";
|
||||
import {USER_PERMISSION, VALIDATE_TOKEN} from "@/api/apis";
|
||||
import * as api2 from "@/api";
|
||||
import {USER_INFO, USER_PERMISSION, VALIDATE_TOKEN} from "@/api/apis";
|
||||
import * as api1 from "@/api/index1";
|
||||
import {getCookieForName} from "@/api/method";
|
||||
// import axios from 'axios'
|
||||
@@ -34,12 +33,13 @@ app.config.warnHandler = () => null;
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (!getCookieForName("token")) {
|
||||
window.location.href = process.env.VUE_APP_LOGIN_URL + encodeURIComponent(window.location.protocol + process.env.VUE_APP_BOE_API_URL + process.env.VUE_APP_BASE + router.currentRoute.value.fullPath)
|
||||
return
|
||||
}
|
||||
//第一次进入 没有用户信息
|
||||
if(!store.state.userInfo.userId){
|
||||
try{
|
||||
await request(VALIDATE_TOKEN)
|
||||
await getUserInfo();
|
||||
await getUserInfo()
|
||||
await getUserPermission();
|
||||
init()
|
||||
next();
|
||||
@@ -58,7 +58,7 @@ async function getUserPermission() {
|
||||
})
|
||||
}
|
||||
async function getUserInfo() {
|
||||
const userInfo = await api2.userInfo();
|
||||
const userInfo = await request(USER_INFO);
|
||||
store.commit("SET_USER", userInfo.data.data);
|
||||
}
|
||||
async function initDict(key) {
|
||||
|
||||
Reference in New Issue
Block a user