|
@@ -8,11 +8,10 @@ import { getSuffixAfterPrefix, showNextAction } from '@/utils/prefixUrl'
|
|
|
import { getCurrentLocaleLang } from '@/utils/lang'
|
|
|
import { enterpriseRefreshToken, userRefreshToken } from '@/api/common'
|
|
|
import { getToken, getRefreshToken, setToken, setRefreshToken, getIsEnterprise } from '@/utils/auth'
|
|
|
+import { encryptionFun } from '@/utils/openEncryption'
|
|
|
import { rewardEventTrackClick } from '@/api/integral'
|
|
|
import errorCode from './errorCode'
|
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
|
-import { generateUUID } from "@/utils/index"
|
|
|
-import { sha256 } from 'js-sha256'
|
|
|
|
|
|
// import { resetRouter } from '@/router'
|
|
|
// import { deleteUserCache } from '@/hooks/web/useCache'
|
|
@@ -78,30 +77,7 @@ service.interceptors.request.use(
|
|
|
}
|
|
|
|
|
|
// 开启参数加密
|
|
|
- if (config.openEncryption) {
|
|
|
- // 1.请求的参数json // 携带的json一下,url拼接参数的直接用,没有参数不拼接
|
|
|
- const jsonData = config.data ? JSON.stringify({...config.data}) :
|
|
|
- config.params ? qs.stringify({...config.params}, { allowDots: true }) :
|
|
|
- config.url.split('?')?.length>1 ? config.url.split('?')[1] : ''
|
|
|
- // 2.固定的参数初始化成字符串
|
|
|
- const supHeaders = {
|
|
|
- appId: 'test', // 与后端协商一致使用
|
|
|
- nonce: generateUUID(), // 前端生成唯一参数
|
|
|
- timestamp: new Date().getTime(),
|
|
|
- }
|
|
|
- const appSecret = '123456' // 与后端协商一致使用
|
|
|
- const staticHeadersStr = Object.keys(supHeaders).reduce((str, key) => {
|
|
|
- str = str ? str + `&${key}=${supHeaders[key]}` : `${key}=${supHeaders[key]}`
|
|
|
- return str
|
|
|
- }, '') + appSecret
|
|
|
-
|
|
|
- // 3.固定参数和请求参数拼接(拼接1和2)// signString
|
|
|
- const finalStr = jsonData + staticHeadersStr
|
|
|
- // 加密字符串
|
|
|
- if (finalStr) supHeaders.sign = sha256(finalStr)
|
|
|
- // 4.请求头加参数: appId + nonce + timestamp + sign // 顺序不能变
|
|
|
- if (supHeaders) Object.keys(supHeaders).forEach(key => { (config).headers[key] = supHeaders[key] })
|
|
|
- }
|
|
|
+ if (config.openEncryption) encryptionFun(config)
|
|
|
|
|
|
// 设置租户
|
|
|
if (tenantEnable && tenantEnable === 'true') {
|