完成请求和响应的加解密

soul2/encrypt
soul2 1 year ago
parent 2fb35a89d2
commit a5961850fd
  1. 12
      src/utils/request.js
  2. 8
      src/views/qr/qrImage.vue

@ -23,7 +23,7 @@ service.interceptors.request.use(
if (config.data && config.method === 'post') {
let sourceBody = JSON.stringify(config.data)
config.data = aes.encrypt(JSON.stringify(config.data))
console.log('加密请求参数 ', sourceBody, ' -> ', config.data)
// console.log('加密请求参数 ', sourceBody, ' -> ', config.data)
}
if (store.getters.token) {
@ -54,8 +54,14 @@ service.interceptors.response.use(
* You can also judge the status by HTTP Status Code
*/
response => {
const res = response.data
console.log('服务器响应 -> ', res)
// console.log(response)
// console.log(JSON.stringify(response.headers))
const source = response.data
if (response.headers['encrypt'] != null) {
response.data = aes.decrypt(response.data)
}
// console.log(`响应数据解密: ${source} -> ${response.data}`)
const res = JSON.parse(response.data)
// if the custom code is not 0, it is judged as an error.
if (res.code !== 0) {
Message({

@ -45,10 +45,10 @@ export default {
},
mounted() {
if (this.row !== null) {
this.edit = JSON.parse(JSON.stringify(this.row))
// console.log(this.edit)
}
// if (this.row !== null) {
// this.edit = JSON.parse(JSON.stringify(this.row))
// // console.log(this.edit)
// }
},
methods: {
closeDialog() {

Loading…
Cancel
Save