加解密支持
This commit is contained in:
@@ -11,6 +11,10 @@ document.addEventListener('plusready', function() {
|
||||
|
||||
// 添加请求拦截器
|
||||
axios.interceptors.request.use(function (config) {
|
||||
// 对所有POST请加密,必须是json数据提交,不支持表单
|
||||
if (config.method == "post") {
|
||||
config.data = EncryptData(JSON.stringify(config.data));
|
||||
}
|
||||
var token = localStorage.getItem("user_token");
|
||||
config.headers.Authorization = token;
|
||||
config.headers.appVersion = localVersion;
|
||||
@@ -26,6 +30,10 @@ axios.interceptors.response.use(function (response) {
|
||||
}catch(e){
|
||||
|
||||
}
|
||||
// 返回字符串表示需要解密操作
|
||||
if(typeof(response.data) == "string"){
|
||||
response.data = DecryptData(response.data);
|
||||
}
|
||||
return response;
|
||||
}, function (error) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user