[AppleScript] 纯文本查看 复制代码
getActiveUser: function(){ let uid = this.getCookie("uid")
if(uid){
let activeUserStr = this.getUserSession("activeUser");
return JSON.parse(activeUserStr); }else{
this.delUserSession("activeUser")
}
}, //获取jwt令牌 getJwt : function(){
let activeUser = this.getActiveUser()
if(activeUser){
return activeUser.jwt
}
},
//解析jwt令牌,获取用户信息
getUserInfoFromJwt : function (jwt) {
if(!jwt){
return ;
}
var jwtDecodeVal = jwtDecode(jwt);
if (!jwtDecodeVal) {
return ;
}
let activeUser={}
//console.log(jwtDecodeVal)
activeUser.utype = jwtDecodeVal.utype || '';
activeUser.username = jwtDecodeVal.name || '';
activeUser.userpic = jwtDecodeVal.userpic || '';
activeUser.userid = jwtDecodeVal.userid || '';
activeUser.authorities = jwtDecodeVal.authorities || '';
activeUser.uid = jwtDecodeVal.jti || '';
activeUser.jwt = jwt;
return activeUser;
},
[AppleScript] 纯文本查看 复制代码
import axios from 'axios'
// 添加请求拦截器 axios.interceptors.request.use(function (config) {
// 在发送请求向header添加jwt let jwt = utilApi.getJwt()
if(jwt){
config.headers['Authorization'] = 'Bearer '+jwt
}
return config; }, function (error) {
return Promise.reject(error); });
[AppleScript] 纯文本查看 复制代码
@PreAuthorize("hasAuthority('course_teachplan_list')")
@Override public TeachplanNode findTeachplanList(@PathVariable("courseId") String courseId) {
return courseService.findTeachplanList(courseId); }
// 响应拦截 axios.interceptors.response.use(data => {
console.log("data=")
console.log(data)
if(data && data.data){
if(data.data.code && data.data.code =='10001'){
//需要登录
window.location = "http://ucenter.xuecheng.com/#/login?returnUrl="+ Base64.encode(window.location)
}else if(data.data.code && data.data.code =='10002'){
Message.error('您没有此操作的权限,请与客服联系!
');
}