token问题修复6

This commit is contained in:
2023-08-23 14:07:07 +08:00
parent 82cf12f5a4
commit f2740ea750

View File

@ -10,14 +10,18 @@ const service = axios.create({
},
timeout: 10000
})
const urlParams = new URLSearchParams(window.location.search);
let token = urlParams.get('token') ;
localStorage.setItem('token', token);
const token1 = localStorage.getItem('token');
this.$toast("token" + token1)
service.interceptors.request.use(
config => {
config.data = config.contentType ? config.data : qs.stringify(config.data)
config.headers['Content-Type'] = config.contentType || 'application/x-www-form-urlencoded'
const urlParams = new URLSearchParams(window.location.search);
// const tokenParams=this.$route.params?.token
const token = urlParams.get('token') ;
// this.$toast("token" + token)
const token = localStorage.getItem('token');
// const urlParams = new URLSearchParams(window.location.search);
// const token = urlParams.get('token') ;
// let token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzemwiLCJhdWQiOlsic3VwcGxpZXItYXBwIl0sIm5iZiI6MTY5MjY4MDk1MywidXNlcl9pbmZvIjp7InVzZXJJZCI6NTQ1ODUsInBob25lIjoiMTc2MzAwMzU2NTgiLCJuYW1lIjoi5bCP5a6LIiwic3VwcGxpZXJOYW1lIjoi5LiK5rW35a6J55WFQSIsInN1cHBsaWVySWQiOjExMjgsInN1cHBsaWVyVHlwZSI6MSwidXNlcm5hbWUiOiJzemwiLCJ1c2VyVHlwZSI6IkFQUCIsImF1dGhvcml0aWVzIjpbXX0sInNjb3BlIjpbImFsbCJdLCJpc3MiOiJodHRwczovL3Npbm9hc3Npc3QuY29tIiwiZXhwIjoxNjkyNzY3MzUzLCJpYXQiOjE2OTI2ODA5NTN9.GClSyBkWX_LedBuO2h6xoBHyL3xsgFeGp_zirimAuTk'
config.headers['Authorization'] = `${token}`;
return config