Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ba36ce88
authored
Nov 10, 2024
by
Vben
Committed by
GitHub
Nov 10, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: pinInput supports disabled props (#4851)
* feat: pinInput supports disabled props
1 parent
57d5a919
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
10 deletions
packages/@core/ui-kit/shadcn-ui/src/components/pin-input/input.vue
packages/@core/ui-kit/shadcn-ui/src/components/pin-input/types.ts
packages/@core/ui-kit/shadcn-ui/src/components/pin-input/input.vue
View file @
ba36ce8
...
@@ -10,15 +10,18 @@ defineOptions({
...
@@ -10,15 +10,18 @@ defineOptions({
inheritAttrs
:
false
,
inheritAttrs
:
false
,
});
});
const
props
=
withDefaults
(
defineProps
<
PinInputProps
>
(),
{
const
{
btnLoading
:
false
,
codeLength
=
6
,
codeLength
:
6
,
createText
=
async
()
=>
{},
handleSendCode
:
async
()
=>
{},
disabled
=
false
,
maxTime
:
60
,
handleSendCode
=
async
()
=>
{},
});
loading
=
false
,
maxTime
=
60
,
}
=
defineProps
<
PinInputProps
>
();
const
emit
=
defineEmits
<
{
const
emit
=
defineEmits
<
{
complete
:
[];
complete
:
[];
sendError
:
[
error
:
any
];
}
>
();
}
>
();
const
timer
=
ref
<
ReturnType
<
typeof
setTimeout
>>
();
const
timer
=
ref
<
ReturnType
<
typeof
setTimeout
>>
();
...
@@ -30,11 +33,11 @@ const countdown = ref(0);
...
@@ -30,11 +33,11 @@ const countdown = ref(0);
const
btnText
=
computed
(()
=>
{
const
btnText
=
computed
(()
=>
{
const
countdownValue
=
countdown
.
value
;
const
countdownValue
=
countdown
.
value
;
return
props
.
createText
?.(
countdownValue
);
return
createText
?.(
countdownValue
);
});
});
const
btnLoading
=
computed
(()
=>
{
const
btnLoading
=
computed
(()
=>
{
return
props
.
loading
||
countdown
.
value
>
0
;
return
loading
||
countdown
.
value
>
0
;
});
});
watch
(
watch
(
...
@@ -50,10 +53,16 @@ function handleComplete(e: string[]) {
...
@@ -50,10 +53,16 @@ function handleComplete(e: string[]) {
}
}
async
function
handleSend
(
e
:
Event
)
{
async
function
handleSend
(
e
:
Event
)
{
try
{
e
?.
preventDefault
();
e
?.
preventDefault
();
await
props
.
handleSendCode
();
await
handleSendCode
();
countdown
.
value
=
props
.
maxTime
;
countdown
.
value
=
maxTime
;
startCountdown
();
startCountdown
();
}
catch
(
error
)
{
console
.
error
(
'Failed to send code:'
,
error
);
// Consider emitting an error event or showing a notification
emit
(
'sendError'
,
error
);
}
}
}
function
startCountdown
()
{
function
startCountdown
()
{
...
@@ -77,6 +86,7 @@ const id = useId();
...
@@ -77,6 +86,7 @@ const id = useId();
<PinInput
<PinInput
:id=
"id"
:id=
"id"
v-model=
"inputValue"
v-model=
"inputValue"
:disabled=
"disabled"
class=
"flex w-full justify-between"
class=
"flex w-full justify-between"
otp
otp
placeholder=
"○"
placeholder=
"○"
...
@@ -92,6 +102,7 @@ const id = useId();
...
@@ -92,6 +102,7 @@ const id = useId();
/>
/>
</PinInputGroup>
</PinInputGroup>
<VbenButton
<VbenButton
:disabled=
"disabled"
:loading=
"btnLoading"
:loading=
"btnLoading"
class=
"flex-grow"
class=
"flex-grow"
size=
"lg"
size=
"lg"
...
...
packages/@core/ui-kit/shadcn-ui/src/components/pin-input/types.ts
View file @
ba36ce8
...
@@ -9,6 +9,10 @@ interface PinInputProps {
...
@@ -9,6 +9,10 @@ interface PinInputProps {
*/
*/
createText
?:
(
countdown
:
number
)
=>
string
;
createText
?:
(
countdown
:
number
)
=>
string
;
/**
/**
* 是否禁用
*/
disabled
?:
boolean
;
/**
* 自定义验证码发送逻辑
* 自定义验证码发送逻辑
* @returns
* @returns
*/
*/
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment