整合前端仓库并保留提交历史
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { ref } from 'vue'
|
||||
import { getCaptchaImage } from '@/api/system'
|
||||
|
||||
interface CaptchaFormData {
|
||||
captcha_code: string
|
||||
captcha_key: string
|
||||
}
|
||||
|
||||
interface CaptchaResponse {
|
||||
code: number
|
||||
msg: string
|
||||
data: {
|
||||
uuid: string
|
||||
base64: string
|
||||
}
|
||||
}
|
||||
|
||||
export function useCaptcha(formData: CaptchaFormData) {
|
||||
const image = ref('')
|
||||
|
||||
const refresh = async () => {
|
||||
try {
|
||||
const res = await getCaptchaImage() as CaptchaResponse
|
||||
if (res.code === 0 && res.data) {
|
||||
formData.captcha_key = res.data.uuid
|
||||
formData.captcha_code = ''
|
||||
image.value = res.data.base64.replace(/\r\n/g, '')
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取验证码失败:', e)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
image,
|
||||
refresh
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user