feat:增加获取用户信息以及token失效跳到登录页

This commit is contained in:
lixg
2022-11-25 15:13:20 +08:00
parent 1dd90d9b1e
commit 762dbf90a7
8 changed files with 81 additions and 13 deletions

View File

@@ -2,11 +2,12 @@
* @Author: lixg lixg@dongwu-inc.com
* @Date: 2022-11-21 14:32:52
* @LastEditors: lixg lixg@dongwu-inc.com
* @LastEditTime: 2022-11-23 09:59:26
* @LastEditTime: 2022-11-25 15:05:34
* @FilePath: /fe-manage/src/api/config.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import axios from "axios";
// import { getCookie } from '../api/method'
// const Qs = require("qs");
// axios.defaults.headers.post["Content-Type"] =
@@ -24,8 +25,9 @@ const http = axios.create({
http.interceptors.request.use(
(config) => {
const token = localStorage.getItem("token");
// const token = getCookie('token')
// console.log('token', token)
if (token) {
// config.headers.token = token;
config.headers.token = token; //测试1111
} else {
console.log("当前请求页面无token,请执行操作!!!");
@@ -44,12 +46,15 @@ http.interceptors.request.use(
http.interceptors.response.use(
(response) => {
// console.log('response', response)
const {
data: { code, msg },
} = response;
// console.log('code', code)
if (code === 0 || code === 200) {
return response;
} else {
// window.open("https://u-pre.boe.com/web/", '_self');
console.log("api %o", msg);
}
return response;