diff --git a/src/utils/request.js b/src/utils/request.js index 74bdf0f..ca28620 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -13,7 +13,7 @@ const service = axios.create({ service.interceptors.request.use((config) => { if (localStorage.getItem("token")) { - config.headers.sessionId = localStorage.getItem("token"); + config.headers.Authorization = localStorage.getItem("token"); } return config; }); @@ -41,6 +41,7 @@ service.interceptors.response.use( // }); if (res.code === 401) { Message({ message: res.msg, type: "error", duration: 1500 }); + localStorage.removeItem("token"); router.push("/login"); } diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 77cfb99..6bdb596 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -78,7 +78,7 @@ export default { loginJoggle(this.userInfo) .then((res) => { if (res.code == 200) { - this.$store.commit("SET_TOKEN", res.data.sessionId); //将token保存在vuex中 + this.$store.commit("SET_TOKEN", res.data.token); //将token保存在vuex中 this.$store.commit("SET_USERINFO", res.data); //将用户信息保存在vuex中 console.log(res.data); if (res.data.role == 5) { diff --git a/vue.config.js b/vue.config.js index 6b3a306..33bdd63 100644 --- a/vue.config.js +++ b/vue.config.js @@ -22,8 +22,8 @@ module.exports = defineConfig({ "/api": { //表示拦截以/api开头的请求路径 //target: "http://47.96.238.157:8093", //阿里云服务器环境 - target: "http://180.166.218.222:40080", //dell - //target: "http://192.168.50.7:8093", //dell + //target: "http://180.166.218.222:40080", //dell + target: "http://192.168.1.190:90", //dell // target: "http://192.168.50.42:81", //东视 changOrigin: true, //是否开启跨域 pathRewrite: {