Skip to content

Commit

Permalink
fix: pinInput value synchronous update
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetfan committed Dec 15, 2024
1 parent bedf199 commit b1421a5
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
6 changes: 5 additions & 1 deletion apps/web-antd/src/views/_core/authentication/code-login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { $t } from '@vben/locales';
defineOptions({ name: 'CodeLogin' });
const loading = ref(false);
const CODE_LENGTH = 6;
const formSchema = computed((): VbenFormSchema[] => {
return [
Expand All @@ -30,6 +31,7 @@ const formSchema = computed((): VbenFormSchema[] => {
{
component: 'VbenPinInput',
componentProps: {
codeLength: CODE_LENGTH,
createText: (countdown: number) => {
const text =
countdown > 0
Expand All @@ -41,7 +43,9 @@ const formSchema = computed((): VbenFormSchema[] => {
},
fieldName: 'code',
label: $t('authentication.code'),
rules: z.string().min(1, { message: $t('authentication.codeTip') }),
rules: z.string().length(CODE_LENGTH, {
message: $t('authentication.codeTip', [CODE_LENGTH]),
}),
},
];
});
Expand Down
6 changes: 5 additions & 1 deletion apps/web-ele/src/views/_core/authentication/code-login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { $t } from '@vben/locales';
defineOptions({ name: 'CodeLogin' });
const loading = ref(false);
const CODE_LENGTH = 6;
const formSchema = computed((): VbenFormSchema[] => {
return [
Expand All @@ -30,6 +31,7 @@ const formSchema = computed((): VbenFormSchema[] => {
{
component: 'VbenPinInput',
componentProps: {
codeLength: CODE_LENGTH,
createText: (countdown: number) => {
const text =
countdown > 0
Expand All @@ -41,7 +43,9 @@ const formSchema = computed((): VbenFormSchema[] => {
},
fieldName: 'code',
label: $t('authentication.code'),
rules: z.string().min(1, { message: $t('authentication.codeTip') }),
rules: z.string().length(CODE_LENGTH, {
message: $t('authentication.codeTip', [CODE_LENGTH]),
}),
},
];
});
Expand Down
6 changes: 5 additions & 1 deletion apps/web-naive/src/views/_core/authentication/code-login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { $t } from '@vben/locales';
defineOptions({ name: 'CodeLogin' });
const loading = ref(false);
const CODE_LENGTH = 6;
const formSchema = computed((): VbenFormSchema[] => {
return [
Expand All @@ -30,6 +31,7 @@ const formSchema = computed((): VbenFormSchema[] => {
{
component: 'VbenPinInput',
componentProps: {
codeLength: CODE_LENGTH,
createText: (countdown: number) => {
const text =
countdown > 0
Expand All @@ -41,7 +43,9 @@ const formSchema = computed((): VbenFormSchema[] => {
},
fieldName: 'code',
label: $t('authentication.code'),
rules: z.string().min(1, { message: $t('authentication.codeTip') }),
rules: z.string().length(CODE_LENGTH, {
message: $t('authentication.codeTip', [CODE_LENGTH]),
}),
},
];
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ watch(
},
);
watch(inputValue, (val) => {
modelValue.value = val.join('');
});
function handleComplete(e: string[]) {
modelValue.value = e.join('');
emit('complete');
Expand Down
2 changes: 1 addition & 1 deletion packages/locales/src/langs/en-US/authentication.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"qrcodeLogin": "QR Code Login",
"codeSubtitle": "Enter your phone number to start managing your project",
"code": "Security code",
"codeTip": "Security code is required",
"codeTip": "Security code required {0} characters",
"mobile": "Mobile",
"mobileLogin": "Mobile Login",
"mobileTip": "Please enter mobile number",
Expand Down
2 changes: 1 addition & 1 deletion packages/locales/src/langs/zh-CN/authentication.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"qrcodeLogin": "扫码登录",
"codeSubtitle": "请输入您的手机号码以开始管理您的项目",
"code": "验证码",
"codeTip": "请输入验证码",
"codeTip": "请输入{0}位验证码",
"mobile": "手机号码",
"mobileTip": "请输入手机号",
"mobileErrortip": "手机号码格式错误",
Expand Down
6 changes: 5 additions & 1 deletion playground/src/views/_core/authentication/code-login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { $t } from '@vben/locales';
defineOptions({ name: 'CodeLogin' });
const loading = ref(false);
const CODE_LENGTH = 6;
const formSchema = computed((): VbenFormSchema[] => {
return [
Expand All @@ -30,6 +31,7 @@ const formSchema = computed((): VbenFormSchema[] => {
{
component: 'VbenPinInput',
componentProps: {
codeLength: CODE_LENGTH,
createText: (countdown: number) => {
const text =
countdown > 0
Expand All @@ -41,7 +43,9 @@ const formSchema = computed((): VbenFormSchema[] => {
},
fieldName: 'code',
label: $t('authentication.code'),
rules: z.string().min(1, { message: $t('authentication.codeTip') }),
rules: z.string().length(CODE_LENGTH, {
message: $t('authentication.codeTip', [CODE_LENGTH]),
}),
},
];
});
Expand Down

0 comments on commit b1421a5

Please sign in to comment.