diff --git a/ui/dasadmin/src/utils/axios.ts b/ui/dasadmin/src/utils/axios.ts index fb3c4a6e..1f431a5c 100644 --- a/ui/dasadmin/src/utils/axios.ts +++ b/ui/dasadmin/src/utils/axios.ts @@ -58,7 +58,7 @@ function createAxios>(axiosConfig: AxiosRequest // if (adminBaseRoute.path != '/admin' && isAdminApp() && /^\/admin\//.test(axiosConfig.url!)) { // axiosConfig.url = axiosConfig.url!.replace(/^\/admin\//, adminBaseRoute.path + '.php/') // } - alert(axiosConfig.data) + // alert(axiosConfig.data) // 合并默认请求选项 options = Object.assign( @@ -77,6 +77,7 @@ function createAxios>(axiosConfig: AxiosRequest // 请求拦截 Axios.interceptors.request.use( (config) => { + const v = generateRandomNumber(16) removePending(config) options.CancelDuplicateRequest && addPending(config) // 创建loading实例 @@ -87,15 +88,19 @@ function createAxios>(axiosConfig: AxiosRequest } } + if (config.method === 'post' && config.data) { + // 对data进行加密 + config.data = encrypt_aes(config.data, v) + } else if (config.method === 'get' && config.params) { + // 对params进行加密 + config.params = encrypt_aes(config.params, v) + } + // 自动携带token if (config.headers) { - const v = generateRandomNumber(16) config.headers.v = v const token = adminInfo.getToken() if (token) (config.headers as anyObj).token = encrypt_aes(token, v) - - // const userToken = options.anotherToken || userInfo.getToken() - // if (userToken) (config.headers as anyObj)['token'] = userToken } return config diff --git a/ui/dasadmin/src/utils/crypto.ts b/ui/dasadmin/src/utils/crypto.ts index fe4c899a..58e1b180 100644 --- a/ui/dasadmin/src/utils/crypto.ts +++ b/ui/dasadmin/src/utils/crypto.ts @@ -11,11 +11,11 @@ export function encrypt_aes(plaintText: string, iv: string) { padding: CryptoJS.pad.Pkcs7, }) - const encryptedBase64Str = encryptedData.toString() + // const encryptedBase64Str = encryptedData.toString() - // 需要读取encryptedData上的ciphertext.toString()才能拿到跟Java一样的密文 + // // 需要读取encryptedData上的ciphertext.toString()才能拿到跟Java一样的密文 - const encryptedStr = encryptedData.ciphertext.toString() + // const encryptedStr = encryptedData.ciphertext.toString() return encryptedData.toString(CryptoJS.format.Base64) }