Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
a760caa483
@ -2,7 +2,6 @@ import createAxios from '/@/utils/axios'
|
|||||||
import { isAdminApp, checkFileMimetype } from '/@/utils/common'
|
import { isAdminApp, checkFileMimetype } from '/@/utils/common'
|
||||||
import { getUrl } from '/@/utils/axios'
|
import { getUrl } from '/@/utils/axios'
|
||||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||||
import { useUserInfo } from '/@/stores/userInfo'
|
|
||||||
import { ElNotification, type UploadRawFile } from 'element-plus'
|
import { ElNotification, type UploadRawFile } from 'element-plus'
|
||||||
import { useSiteConfig } from '/@/stores/siteConfig'
|
import { useSiteConfig } from '/@/stores/siteConfig'
|
||||||
import { state as uploadExpandState, fileUpload as uploadExpand } from '/@/components/mixins/baUpload'
|
import { state as uploadExpandState, fileUpload as uploadExpand } from '/@/components/mixins/baUpload'
|
||||||
@ -27,10 +26,10 @@ export const changeTerminalConfigUrl = '/admin/ajax/changeTerminalConfig'
|
|||||||
export const clearCacheUrl = '/admin/ajax/clearCache'
|
export const clearCacheUrl = '/admin/ajax/clearCache'
|
||||||
|
|
||||||
// 公共
|
// 公共
|
||||||
export const captchaUrl = '/api/captchaImage'
|
export const captchaUrl = '/api/auth/captchaImage'
|
||||||
export const clickCaptchaUrl = '/api/captchaImage'
|
export const clickCaptchaUrl = '/api/auth/captchaImage'
|
||||||
export const checkClickCaptchaUrl = '/api/common/checkClickCaptcha'
|
export const checkClickCaptchaUrl = '/api/common/checkClickCaptcha'
|
||||||
export const refreshTokenUrl = '/api/common/refreshToken'
|
export const refreshTokenUrl = '/api/auth/refreshToken'
|
||||||
|
|
||||||
// api模块(前台)
|
// api模块(前台)
|
||||||
export const apiUploadUrl = '/api/ajax/upload'
|
export const apiUploadUrl = '/api/ajax/upload'
|
||||||
|
@ -8,6 +8,7 @@ import adminBaseRoute from '/@/router/static/adminBase'
|
|||||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||||
import { useConfig } from '/@/stores/config'
|
import { useConfig } from '/@/stores/config'
|
||||||
import { encrypt_aes, decrypt_aes, generateRandomNumber } from './crypto'
|
import { encrypt_aes, decrypt_aes, generateRandomNumber } from './crypto'
|
||||||
|
import { json } from 'stream/consumers'
|
||||||
|
|
||||||
window.requests = []
|
window.requests = []
|
||||||
window.tokenRefreshing = false
|
window.tokenRefreshing = false
|
||||||
@ -48,6 +49,7 @@ function createAxios<Data = any, T = ApiPromise<Data>>(axiosConfig: AxiosRequest
|
|||||||
headers: {
|
headers: {
|
||||||
'think-lang': config.lang.defaultLang,
|
'think-lang': config.lang.defaultLang,
|
||||||
server: true,
|
server: true,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
})
|
})
|
||||||
@ -88,14 +90,14 @@ function createAxios<Data = any, T = ApiPromise<Data>>(axiosConfig: AxiosRequest
|
|||||||
|
|
||||||
if (config.method === 'post' && config.data) {
|
if (config.method === 'post' && config.data) {
|
||||||
// 对data进行加密
|
// 对data进行加密
|
||||||
const formData = new FormData()
|
// const formData = new FormData()
|
||||||
formData.append('param', encrypt_aes(config.data, v))
|
// formData.append('param')
|
||||||
config.data = formData
|
config.data = encrypt_aes(config.data, v)
|
||||||
} else if (config.method === 'get' && config.params) {
|
} else if (config.method === 'get' && config.params) {
|
||||||
// 对params进行加密
|
// 对params进行加密
|
||||||
const formData = new FormData()
|
// const formData = new FormData()
|
||||||
formData.append('param', encrypt_aes(config.params, v))
|
// formData.append('param')
|
||||||
config.params = formData
|
config.params = encrypt_aes(config.params, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动携带token
|
// 自动携带token
|
||||||
@ -120,35 +122,36 @@ function createAxios<Data = any, T = ApiPromise<Data>>(axiosConfig: AxiosRequest
|
|||||||
|
|
||||||
if (response.config.responseType == 'json') {
|
if (response.config.responseType == 'json') {
|
||||||
if (response.data && response.data.code == 401) {
|
if (response.data && response.data.code == 401) {
|
||||||
// if (response.data.code == 409) {
|
if (response.data.code == 409) {
|
||||||
// if (!window.tokenRefreshing) {
|
if (!window.tokenRefreshing) {
|
||||||
// window.tokenRefreshing = true
|
window.tokenRefreshing = true
|
||||||
// return refreshToken()
|
return refreshToken()
|
||||||
// .then((res) => {
|
.then((res) => {
|
||||||
// adminInfo.setToken(res.data.token, 'auth')
|
adminInfo.setToken(res.data.token, 'auth')
|
||||||
// response.headers.token = `${res.data.token}`
|
response.headers.token = `${res.data.accessToken}`
|
||||||
// window.requests.forEach((cb) => cb(res.data.token, 'admin-refresh'))
|
window.requests.forEach((cb) => cb(res.data.accessToken, 'admin-refresh'))
|
||||||
// window.requests = []
|
window.requests = []
|
||||||
// return Axios(response.config)
|
return Axios(response.config)
|
||||||
// })
|
})
|
||||||
// .catch((err) => {
|
.catch((err) => {
|
||||||
// adminInfo.removeToken()
|
adminInfo.removeToken()
|
||||||
// router.push({ name: 'adminLogin' })
|
router.push({ name: 'adminLogin' })
|
||||||
// return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
// })
|
})
|
||||||
// .finally(() => {
|
.finally(() => {
|
||||||
// window.tokenRefreshing = false
|
window.tokenRefreshing = false
|
||||||
// })
|
})
|
||||||
// } else {
|
} else {
|
||||||
// return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
// // 用函数形式将 resolve 存入,等待刷新后再执行
|
// 用函数形式将 resolve 存入,等待刷新后再执行
|
||||||
// window.requests.push((token: string, type: string) => {
|
window.requests.push((token: string, type: string) => {
|
||||||
// response.headers.token = `${token}`
|
const v = response.headers.v
|
||||||
// resolve(Axios(response.config))
|
response.headers.token = encrypt_aes(token, v)
|
||||||
// })
|
resolve(Axios(response.config))
|
||||||
// })
|
})
|
||||||
// }
|
})
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
// if (options.showCodeMessage) {
|
// if (options.showCodeMessage) {
|
||||||
// ElNotification({
|
// ElNotification({
|
||||||
// type: 'error',
|
// type: 'error',
|
||||||
|
@ -117,7 +117,7 @@ const form = reactive({
|
|||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
keep: false,
|
keep: false,
|
||||||
uuid: '',
|
key: '',
|
||||||
code: '',
|
code: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ const onSubmitPre = () => {
|
|||||||
|
|
||||||
const load = () => {
|
const load = () => {
|
||||||
getCaptchaData().then((res) => {
|
getCaptchaData().then((res) => {
|
||||||
form.uuid = res.data.key
|
form.key = res.data.key
|
||||||
state.captcha = 'data:image\/png;base64,' + res.data.img
|
state.captcha = 'data:image\/png;base64,' + res.data.img
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user