feat: 添加验证码验证,用户注册开关
This commit is contained in:
@@ -35,9 +35,13 @@ export const refreshTokenApi = (data: { refreshToken: string }) => {
|
||||
|
||||
export type CaptchaResponse = {
|
||||
/**验证码ID */
|
||||
uuid: string;
|
||||
uuid: string | null;
|
||||
/**验证码 */
|
||||
captcha: string;
|
||||
captcha: string | null;
|
||||
/**是否开启验证码 */
|
||||
captcha_enabled: boolean;
|
||||
/**是否开启注册 */
|
||||
register_enabled: boolean;
|
||||
};
|
||||
|
||||
/** 获取验证码 */
|
||||
|
||||
@@ -144,6 +144,8 @@ export const useUserStore = defineStore({
|
||||
username: string;
|
||||
password: string;
|
||||
loginDay?: number;
|
||||
uuid?: string;
|
||||
code?: string;
|
||||
}) {
|
||||
return new Promise<ResponseResult<LoginResult>>((resolve, reject) => {
|
||||
getLogin(data)
|
||||
|
||||
@@ -39,6 +39,8 @@ defineOptions({
|
||||
name: "Login"
|
||||
});
|
||||
|
||||
const captcha_enabled = ref<boolean>(true);
|
||||
const register_enabled = ref<boolean>(true);
|
||||
const imgCode = ref("");
|
||||
const imgId = ref("");
|
||||
const loginDay = ref(7);
|
||||
@@ -116,6 +118,8 @@ const getImgCode = async () => {
|
||||
if (res.success) {
|
||||
imgCode.value = res.data.captcha;
|
||||
imgId.value = res.data.uuid;
|
||||
captcha_enabled.value = res.data.captcha_enabled;
|
||||
register_enabled.value = res.data.register_enabled;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -238,7 +242,7 @@ onMounted(async () => {
|
||||
</el-form-item>
|
||||
</Motion>
|
||||
|
||||
<Motion :delay="200">
|
||||
<Motion v-if="captcha_enabled" :delay="200">
|
||||
<el-form-item prop="verifyCode">
|
||||
<el-input
|
||||
v-model="ruleForm.verifyCode"
|
||||
@@ -299,6 +303,7 @@ onMounted(async () => {
|
||||
class="w-full mt-4"
|
||||
size="default"
|
||||
type="primary"
|
||||
round
|
||||
:loading="loading"
|
||||
:disabled="disabled"
|
||||
@click="onLogin(ruleFormRef)"
|
||||
@@ -312,13 +317,13 @@ onMounted(async () => {
|
||||
<el-form-item>
|
||||
<div class="w-full h-[20px] flex justify-between items-center">
|
||||
<el-button
|
||||
v-for="(item, index) in operates"
|
||||
:key="index"
|
||||
v-if="register_enabled"
|
||||
class="w-full mt-4"
|
||||
size="default"
|
||||
@click="useUserStoreHook().SET_CURRENTPAGE(index + 1)"
|
||||
round
|
||||
@click="useUserStoreHook().SET_CURRENTPAGE(3)"
|
||||
>
|
||||
{{ t(item.title) }}
|
||||
{{ t("login:Register") }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
@@ -330,7 +335,10 @@ onMounted(async () => {
|
||||
<!-- 二维码登录 -->
|
||||
<LoginQrCode v-if="currentPage === 2" />
|
||||
<!-- 注册 -->
|
||||
<div v-if="register_enabled">
|
||||
<LoginRegist v-if="currentPage === 3" />
|
||||
</div>
|
||||
|
||||
<!-- 忘记密码 -->
|
||||
<LoginUpdate v-if="currentPage === 4" />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user