Browse Source

sm4加密参数

q_v1
herenshan112 6 days ago
parent
commit
c38736426b
  1. 16
      src/utils/axios/index.ts
  2. 8
      src/utils/encryptionAndDecryption/sm4Utils.ts
  3. 2
      src/utils/pinia/stores/modules/userOrders.ts
  4. 9
      vite.config.ts

16
src/utils/axios/index.ts

@ -27,13 +27,13 @@ service.interceptors.request.use((config: InternalAxiosRequestConfig) => {
config.headers["user-token"] = userPinia.userToken;
}
console.error('<---------------请求拦截---------->')
console.error('请求拦截----config------>', config.url)
console.error('请求拦截----data------>', config.data)
console.error('<---------------请求拦截---------->')
// if (config.headers['content-type'] === 'application/json') {
// console.error('<---------------请求拦截---------->')
// console.error('请求拦截----config------>', config.url)
// console.error('请求拦截----data------>', config)
// console.error('<---------------请求拦截---------->')
// // if (config.headers['content-type'] === 'application/json') {
let { data, headers } = config
//获取16位随机数
// //获取16位随机数
let randomString = generateRandomString(16)
config.headers['Auth-key'] = randomString
if (data) {
@ -61,8 +61,8 @@ service.interceptors.response.use((response: AxiosResponse) => {
let jsonData = sm4DecryptMethod(data.data, authKey)
response.data.data = JSON.parse(jsonData)
}
console.error('行营结果----解密结构------>', response.config.url)
console.error('行营结果----解密结构------>', response.data)
// console.error('行营结果----解密结构------>', response.config.url)
// console.error('行营结果----解密结构------>', response.data)
// 对响应数据做点什么
const { code, msg } = response.data;
//如果是以下状态直接放行

8
src/utils/encryptionAndDecryption/sm4Utils.ts

@ -59,10 +59,10 @@ const sm4DecryptMethod = (data: string, customKey: string): string => {
}
}
// console.log('SM4解密方法----解密结构---data--->', data)
console.log('SM4解密方法----解密结构----customKey-->', customKey)
console.log('SM4解密方法----解密结构--ivSetup---->', ivSetup)
console.log('SM4解密方法----解密结构---sm4TokenKey--->', sm4TokenKey)
console.log('SM4解密方法----解密结构---appSystemKey--->', appSystemKey)
// console.log('SM4解密方法----解密结构----customKey-->', customKey)
// console.log('SM4解密方法----解密结构--ivSetup---->', ivSetup)
// console.log('SM4解密方法----解密结构---sm4TokenKey--->', sm4TokenKey)
// console.log('SM4解密方法----解密结构---appSystemKey--->', appSystemKey)
return sm4.decrypt(data, appSystemKey, {
iv: ivSetup,
mode: sm4.constants.CBC,

2
src/utils/pinia/stores/modules/userOrders.ts

@ -110,7 +110,7 @@ export const userStror = defineStore("user",() => {
return new Promise<UserInfo>((resolve, reject) => {
getUserInfoIng()
.then((data:any)=>{
// console.log("获取用户信息:角色必须是非null数组!",data);
console.log("获取用户信息:角色必须是非null数组!",data);
nickname.value = data.data.nickname;
avatar.value = data.data.avatar;
roles.value = data.data.roles;

9
vite.config.ts

@ -71,6 +71,15 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
autoInstall: true,
}),
],
build: {
minify: 'terser',
terserOptions: {
compress: {
drop_console: true, // 删除所有 console 语句
drop_debugger: true // 删除所有 debugger 语句
}
}
}
}
})

Loading…
Cancel
Save