mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-04-25 07:57:18 +08:00
feat: 使用后端服务器获取验证码
This commit is contained in:
parent
95a9675c7c
commit
76efc1d28c
@ -29,7 +29,10 @@ defineOptions({
|
|||||||
name: "Login"
|
name: "Login"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO 当请求验证码过于频繁的话 服务器会报错 但是前端没有反应 这块需要处理一下, 通过axios处理一下
|
||||||
const captchaCodeBase64 = ref("");
|
const captchaCodeBase64 = ref("");
|
||||||
|
const isCaptchaOn = ref(false);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const checked = ref(false);
|
const checked = ref(false);
|
||||||
@ -80,23 +83,21 @@ function onkeypress({ code }: KeyboardEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCaptchaCode() {
|
async function getCaptchaCode() {
|
||||||
CommonAPI.getCaptchaCode().then(res => {
|
await CommonAPI.getCaptchaCode().then(res => {
|
||||||
|
isCaptchaOn.value = res.data.isCaptchaOn;
|
||||||
captchaCodeBase64.value = `data:image/gif;base64,${res.data.img}`;
|
captchaCodeBase64.value = `data:image/gif;base64,${res.data.img}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(() => {
|
||||||
window.document.addEventListener("keypress", onkeypress);
|
window.document.addEventListener("keypress", onkeypress);
|
||||||
|
getCaptchaCode();
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
window.document.removeEventListener("keypress", onkeypress);
|
window.document.removeEventListener("keypress", onkeypress);
|
||||||
});
|
});
|
||||||
|
|
||||||
// watch(imgCode, value => {
|
|
||||||
// useUserStoreHook().SET_VERIFYCODE(value);
|
|
||||||
// });
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -167,7 +168,7 @@ onBeforeUnmount(() => {
|
|||||||
</Motion>
|
</Motion>
|
||||||
|
|
||||||
<Motion :delay="200">
|
<Motion :delay="200">
|
||||||
<el-form-item prop="verifyCode">
|
<el-form-item v-if="isCaptchaOn" prop="verifyCode">
|
||||||
<el-input
|
<el-input
|
||||||
clearable
|
clearable
|
||||||
v-model="ruleForm.verifyCode"
|
v-model="ruleForm.verifyCode"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user