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 f0e9e55a
authored
Apr 14, 2025
by
Netfan
Committed by
GitHub
Apr 14, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: alert support customize `footer` (#5940)
* Alert组件支持自定义footer
1 parent
ff882745
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
1 deletions
docs/src/components/common-ui/vben-alert.md
docs/src/demos/vben-alert/confirm/index.vue
packages/@core/ui-kit/popup-ui/src/alert/alert.ts
packages/@core/ui-kit/popup-ui/src/alert/alert.vue
docs/src/components/common-ui/vben-alert.md
View file @
f0e9e55
...
@@ -69,8 +69,14 @@ export type AlertProps = {
...
@@ -69,8 +69,14 @@ export type AlertProps = {
contentClass
?:
string
;
contentClass
?:
string
;
/** 执行beforeClose回调期间,在内容区域显示一个loading遮罩*/
/** 执行beforeClose回调期间,在内容区域显示一个loading遮罩*/
contentMasking
?:
boolean
;
contentMasking
?:
boolean
;
/** 弹窗底部内容(与按钮在同一个容器中) */
footer
?:
Component
|
string
;
/** 弹窗的图标(在标题的前面) */
/** 弹窗的图标(在标题的前面) */
icon
?:
Component
|
IconType
;
icon
?:
Component
|
IconType
;
/**
* 弹窗遮罩模糊效果
*/
overlayBlur
?:
number
;
/** 是否显示取消按钮 */
/** 是否显示取消按钮 */
showCancel
?:
boolean
;
showCancel
?:
boolean
;
/** 弹窗标题 */
/** 弹窗标题 */
...
...
docs/src/demos/vben-alert/confirm/index.vue
View file @
f0e9e55
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
h
,
ref
}
from
'vue'
;
import
{
alert
,
confirm
,
VbenButton
}
from
'@vben/common-ui'
;
import
{
alert
,
confirm
,
VbenButton
}
from
'@vben/common-ui'
;
import
{
Checkbox
,
message
}
from
'ant-design-vue'
;
function
showConfirm
()
{
function
showConfirm
()
{
confirm
(
'This is an alert message'
)
confirm
(
'This is an alert message'
)
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -18,6 +22,34 @@ function showIconConfirm() {
...
@@ -18,6 +22,34 @@ function showIconConfirm() {
});
});
}
}
function
showfooterConfirm
()
{
const
checked
=
ref
(
false
);
confirm
({
cancelText
:
'不要虾扯蛋'
,
confirmText
:
'是的,我们都是NPC'
,
content
:
'刚才发生的事情,为什么我似乎早就经历过一般?\n我甚至能在事情发生过程中潜意识里预知到接下来会发生什么。\n\n听起来挺玄乎的,你有过这种感觉吗?'
,
footer
:
()
=>
h
(
Checkbox
,
{
checked
:
checked
.
value
,
class
:
'flex-1'
,
'onUpdate:checked'
:
(
v
)
=>
(
checked
.
value
=
v
),
},
'不再提示'
,
),
icon
:
'question'
,
title
:
'未解之谜'
,
}).
then
(()
=>
{
if
(
checked
.
value
)
{
message
.
success
(
'我不会再拿这个问题烦你了'
);
}
else
{
message
.
info
(
'下次还要继续问你哟'
);
}
});
}
function
showAsyncConfirm
()
{
function
showAsyncConfirm
()
{
confirm
({
confirm
({
beforeClose
({
isConfirm
})
{
beforeClose
({
isConfirm
})
{
...
@@ -37,6 +69,7 @@ function showAsyncConfirm() {
...
@@ -37,6 +69,7 @@ function showAsyncConfirm() {
<div
class=
"flex gap-4"
>
<div
class=
"flex gap-4"
>
<VbenButton
@
click=
"showConfirm"
>
Confirm
</VbenButton>
<VbenButton
@
click=
"showConfirm"
>
Confirm
</VbenButton>
<VbenButton
@
click=
"showIconConfirm"
>
Confirm With Icon
</VbenButton>
<VbenButton
@
click=
"showIconConfirm"
>
Confirm With Icon
</VbenButton>
<VbenButton
@
click=
"showfooterConfirm"
>
Confirm With Footer
</VbenButton>
<VbenButton
@
click=
"showAsyncConfirm"
>
Async Confirm
</VbenButton>
<VbenButton
@
click=
"showAsyncConfirm"
>
Async Confirm
</VbenButton>
</div>
</div>
</
template
>
</
template
>
packages/@core/ui-kit/popup-ui/src/alert/alert.ts
View file @
f0e9e55
...
@@ -34,6 +34,8 @@ export type AlertProps = {
...
@@ -34,6 +34,8 @@ export type AlertProps = {
contentClass
?:
string
;
contentClass
?:
string
;
/** 执行beforeClose回调期间,在内容区域显示一个loading遮罩*/
/** 执行beforeClose回调期间,在内容区域显示一个loading遮罩*/
contentMasking
?:
boolean
;
contentMasking
?:
boolean
;
/** 弹窗底部内容(与按钮在同一个容器中) */
footer
?:
Component
|
string
;
/** 弹窗的图标(在标题的前面) */
/** 弹窗的图标(在标题的前面) */
icon
?:
Component
|
IconType
;
icon
?:
Component
|
IconType
;
/**
/**
...
...
packages/@core/ui-kit/popup-ui/src/alert/alert.vue
View file @
f0e9e55
...
@@ -157,7 +157,11 @@ async function handleOpenChange(val: boolean) {
...
@@ -157,7 +157,11 @@ async function handleOpenChange(val: boolean) {
</div>
</div>
<VbenLoading
v-if=
"loading && contentMasking"
:spinning=
"loading"
/>
<VbenLoading
v-if=
"loading && contentMasking"
:spinning=
"loading"
/>
</AlertDialogDescription>
</AlertDialogDescription>
<div
class=
"flex justify-end gap-x-2"
:class=
"`justify-$
{buttonAlign}`">
<div
class=
"flex items-center justify-end gap-x-2"
:class=
"`justify-$
{buttonAlign}`"
>
<VbenRenderContent
:content=
"footer"
/>
<AlertDialogCancel
v-if=
"showCancel"
as-child
>
<AlertDialogCancel
v-if=
"showCancel"
as-child
>
<component
<component
:is=
"components.DefaultButton || VbenButton"
:is=
"components.DefaultButton || VbenButton"
...
...
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