feat: 添加验证码验证,用户注册开关

This commit is contained in:
2025-02-13 00:04:28 +08:00
parent 21d128ed66
commit 61d800d3c7
3 changed files with 22 additions and 8 deletions

View File

@@ -35,9 +35,13 @@ export const refreshTokenApi = (data: { refreshToken: string }) => {
export type CaptchaResponse = { export type CaptchaResponse = {
/**验证码ID */ /**验证码ID */
uuid: string; uuid: string | null;
/**验证码 */ /**验证码 */
captcha: string; captcha: string | null;
/**是否开启验证码 */
captcha_enabled: boolean;
/**是否开启注册 */
register_enabled: boolean;
}; };
/** 获取验证码 */ /** 获取验证码 */

View File

@@ -144,6 +144,8 @@ export const useUserStore = defineStore({
username: string; username: string;
password: string; password: string;
loginDay?: number; loginDay?: number;
uuid?: string;
code?: string;
}) { }) {
return new Promise<ResponseResult<LoginResult>>((resolve, reject) => { return new Promise<ResponseResult<LoginResult>>((resolve, reject) => {
getLogin(data) getLogin(data)

View File

@@ -39,6 +39,8 @@ defineOptions({
name: "Login" name: "Login"
}); });
const captcha_enabled = ref<boolean>(true);
const register_enabled = ref<boolean>(true);
const imgCode = ref(""); const imgCode = ref("");
const imgId = ref(""); const imgId = ref("");
const loginDay = ref(7); const loginDay = ref(7);
@@ -116,6 +118,8 @@ const getImgCode = async () => {
if (res.success) { if (res.success) {
imgCode.value = res.data.captcha; imgCode.value = res.data.captcha;
imgId.value = res.data.uuid; 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> </el-form-item>
</Motion> </Motion>
<Motion :delay="200"> <Motion v-if="captcha_enabled" :delay="200">
<el-form-item prop="verifyCode"> <el-form-item prop="verifyCode">
<el-input <el-input
v-model="ruleForm.verifyCode" v-model="ruleForm.verifyCode"
@@ -299,6 +303,7 @@ onMounted(async () => {
class="w-full mt-4" class="w-full mt-4"
size="default" size="default"
type="primary" type="primary"
round
:loading="loading" :loading="loading"
:disabled="disabled" :disabled="disabled"
@click="onLogin(ruleFormRef)" @click="onLogin(ruleFormRef)"
@@ -312,13 +317,13 @@ onMounted(async () => {
<el-form-item> <el-form-item>
<div class="w-full h-[20px] flex justify-between items-center"> <div class="w-full h-[20px] flex justify-between items-center">
<el-button <el-button
v-for="(item, index) in operates" v-if="register_enabled"
:key="index"
class="w-full mt-4" class="w-full mt-4"
size="default" size="default"
@click="useUserStoreHook().SET_CURRENTPAGE(index + 1)" round
@click="useUserStoreHook().SET_CURRENTPAGE(3)"
> >
{{ t(item.title) }} {{ t("login:Register") }}
</el-button> </el-button>
</div> </div>
</el-form-item> </el-form-item>
@@ -330,7 +335,10 @@ onMounted(async () => {
<!-- 二维码登录 --> <!-- 二维码登录 -->
<LoginQrCode v-if="currentPage === 2" /> <LoginQrCode v-if="currentPage === 2" />
<!-- 注册 --> <!-- 注册 -->
<div v-if="register_enabled">
<LoginRegist v-if="currentPage === 3" /> <LoginRegist v-if="currentPage === 3" />
</div>
<!-- 忘记密码 --> <!-- 忘记密码 -->
<LoginUpdate v-if="currentPage === 4" /> <LoginUpdate v-if="currentPage === 4" />
</div> </div>