mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-03 12:29:14 +08:00
暂存
This commit is contained in:
parent
42b189fc40
commit
8d6d4bb59b
@ -18,6 +18,7 @@
|
||||
"axios": "^1.6.5",
|
||||
"codemirror": "^5.65.16",
|
||||
"codemirror-editor-vue3": "^2.4.1",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dayjs": "^1.11.10",
|
||||
"echarts": "^5.4.3",
|
||||
"js-sha1": "^0.6.0",
|
||||
@ -35,6 +36,7 @@
|
||||
"xterm-addon-fit": "^0.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/node": "^20.10.8",
|
||||
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
||||
"@typescript-eslint/parser": "^6.18.1",
|
||||
|
@ -5,6 +5,7 @@ import { refreshToken } from './user/user'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { GlobalWindow } from '@/interface/common'
|
||||
import CryptoJS from 'crypto-js'
|
||||
|
||||
import Qs from 'qs'
|
||||
import router from '../router'
|
||||
@ -31,6 +32,14 @@ const instance: AxiosInstance = axios.create({
|
||||
|
||||
let refreshTokenIng = false
|
||||
|
||||
const obj2base64 = (obj: { [x: string]: any }) => {
|
||||
const keys = Object.keys(obj)
|
||||
for (const key of keys) {
|
||||
obj[key] = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(obj[key]))
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// 请求拦截
|
||||
instance.interceptors.request.use((config: InternalAxiosRequestConfig) => {
|
||||
const appStore = useAppStore()
|
||||
@ -44,6 +53,13 @@ instance.interceptors.request.use((config: InternalAxiosRequestConfig) => {
|
||||
// 防止 url 出现 //
|
||||
config.url = (routerBase + config.url).replace(new RegExp('//', 'gm'), '/')
|
||||
}
|
||||
// TODO 根据后端返回值做调整
|
||||
if (config.data) {
|
||||
config.data = obj2base64(config.data)
|
||||
}
|
||||
if (config.params) {
|
||||
config.params = obj2base64(config.params)
|
||||
}
|
||||
return config
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user