接口进行加密
All checks were successful
site-dist-deploy / build-and-deploy (push) Successful in 1m42s

This commit is contained in:
speakeloudest 2026-01-26 03:38:18 -08:00
parent e768e0f9f0
commit 7a2cf6b8f8

View File

@ -153,27 +153,27 @@ export default class Request {
...config.extraConfig, ...config.extraConfig,
} }
// if (config.data && !(config.data instanceof FormData)) { if (config.data && !(config.data instanceof FormData)) {
// const plainText = JSON.stringify(config.data) const plainText = JSON.stringify(config.data)
// config.data = HiAesUtil.encryptData(plainText, encryptionKey) config.data = HiAesUtil.encryptData(plainText, encryptionKey)
// } }
//
// if (config.method?.toLowerCase() === 'get' || config.params) { if (config.method?.toLowerCase() === 'get' || config.params) {
// const paramsToEncrypt = config.params || {} const paramsToEncrypt = config.params || {}
// const plainParamsText = JSON.stringify(paramsToEncrypt) const plainParamsText = JSON.stringify(paramsToEncrypt)
// const encryptedParams = HiAesUtil.encryptData(plainParamsText, encryptionKey) const encryptedParams = HiAesUtil.encryptData(plainParamsText, encryptionKey)
//
// config.params = { config.params = {
// data: encryptedParams.data, data: encryptedParams.data,
// time: encryptedParams.time, time: encryptedParams.time,
// } }
// } }
config.headers = mergeExtraConfig.formatHeader({ config.headers = mergeExtraConfig.formatHeader({
...this.config.headers, ...this.config.headers,
...config.headers, ...config.headers,
lang: 'zh_CN', lang: 'zh_CN',
// 'login-type': 'device', 'login-type': 'device',
...(mergeExtraConfig.withToken && { ...(mergeExtraConfig.withToken && {
[mergeExtraConfig.tokenKey]: mergeExtraConfig.getToken(), [mergeExtraConfig.tokenKey]: mergeExtraConfig.getToken(),
}), }),
@ -193,21 +193,22 @@ export default class Request {
this.axiosInstance.interceptors.response.use( this.axiosInstance.interceptors.response.use(
(response: ResponseType) => { (response: ResponseType) => {
const { data, config } = response const { data, config } = response
const responseData = response.data.data let responseData = response.data.data
// if (responseData && responseData.data && responseData.time) { if (responseData && responseData.data && responseData.time) {
// try { try {
// const decryptedStr = HiAesUtil.decryptData( const decryptedStr = HiAesUtil.decryptData(
// responseData.data, responseData.data,
// responseData.time, responseData.time,
// encryptionKey, encryptionKey,
// ) )
// responseData = JSON.parse(decryptedStr) console.log('decryptedStr', JSON.parse(decryptedStr))
// } catch (e) { responseData = JSON.parse(decryptedStr)
// console.error('解密失败:', e) } catch (e) {
// return Promise.reject({ message: '数据解密异常' }) console.error('解密失败:', e)
// } return Promise.reject({ message: '数据解密异常' })
// } }
}
axiosCanceler.removePending(config) axiosCanceler.removePending(config)
if (data.code !== 200) { if (data.code !== 200) {