commit code.

This commit is contained in:
2022-12-30 01:56:26 +08:00
parent d81542921b
commit 7841e706f6
26 changed files with 378 additions and 273 deletions

View File

@@ -38,7 +38,7 @@
class="txt-btn"
@click="handleBtnGetOTPClick"
size="large"
style="width 100%"
style="width: 100%"
>
获取验证码
</n-button>
@@ -81,24 +81,17 @@
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import type { FormInst, FormItemInst, FormItemRule, FormRules } from 'naive-ui'
import { useMessage } from 'naive-ui'
import { ref } from "vue";
import type { FormInst, FormItemInst, FormItemRule, FormRules } from "naive-ui";
import type { LoginByOTPCommand } from "@/type/commands/LoginCommands";
interface LoginByPasswordCommand {
principal: string
otp: string
rememberMe: boolean
}
const formRef = ref<FormInst | null>(null)
const rPasswordFormItemRef = ref<FormItemInst | null>(null)
const message = useMessage()
const model = ref<LoginByPasswordCommand>({
principal: '',
otp: '',
const formRef = ref<FormInst | null>(null);
const rPasswordFormItemRef = ref<FormItemInst | null>(null);
const model = ref<LoginByOTPCommand>({
principal: "",
otp: "",
rememberMe: false,
})
});
const rules: FormRules = {
principal: [
@@ -106,45 +99,45 @@ const rules: FormRules = {
required: true,
validator(rule: FormItemRule, value: string) {
if (!value) {
return new Error('需要年龄')
return new Error("需要年龄");
} else if (!/^\d*$/.test(value)) {
return new Error('年龄应该为整数')
return new Error("年龄应该为整数");
} else if (Number(value) < 18) {
return new Error('年龄应该超过十八岁')
return new Error("年龄应该超过十八岁");
}
return true
return true;
},
trigger: ['input', 'blur'],
trigger: ["input", "blur"],
},
],
otp: [
{
required: true,
message: '请输入密码',
message: "请输入密码",
},
],
}
};
function handlePasswordInput() {
if (model.value.rememberMe) {
rPasswordFormItemRef.value?.validate({ trigger: 'password-input' })
rPasswordFormItemRef.value?.validate({ trigger: "password-input" });
}
}
function handleBtnLoginClick(e: MouseEvent) {
e.preventDefault()
e.preventDefault();
formRef.value?.validate((errors) => {
if (!errors) {
message.success('验证成功')
window.$message.success("验证成功");
} else {
console.log(errors)
message.error('验证失败')
console.log(errors);
window.$message.error("验证失败");
}
})
});
}
function handleBtnGetOTPClick() {
console.log('handleBtnGetOTPClick')
console.log("handleBtnGetOTPClick");
}
</script>