diff --git a/docs/src/components/common-ui/vben-alert.md b/docs/src/components/common-ui/vben-alert.md
index 61caac6d..6541b665 100644
--- a/docs/src/components/common-ui/vben-alert.md
+++ b/docs/src/components/common-ui/vben-alert.md
@@ -12,6 +12,12 @@ Alert提供的功能与Modal类似,但只适用于简单应用场景。例如
:::
+::: tip 注意
+
+Alert提供的快捷方法alert、confirm、prompt动态创建的弹窗在已打开的情况下,不支持HMR(热更新),代码变更后需要关闭这些弹窗后重新打开。
+
+:::
+
::: tip README
下方示例代码中的,存在一些主题色未适配、样式缺失的问题,这些问题只在文档内会出现,实际使用并不会有这些问题,可忽略,不必纠结。
@@ -32,6 +38,23 @@ Alert提供的功能与Modal类似,但只适用于简单应用场景。例如
+## useAlertContext
+
+当弹窗的content、footer、icon使用自定义组件时,在这些组件中可以使用 `useAlertContext` 获取当前弹窗的上下文对象,用来主动控制弹窗。
+
+::: tip 注意
+
+`useAlertContext`只能用在setup或者函数式组件中。
+
+:::
+
+### Methods
+
+| 方法 | 描述 | 类型 | 版本要求 |
+| --------- | ------------------ | -------- | -------- |
+| doConfirm | 调用弹窗的确认操作 | ()=>void | >5.5.4 |
+| doCancel | 调用弹窗的取消操作 | ()=>void | >5.5.4 |
+
## 类型说明
```ts
@@ -69,8 +92,14 @@ export type AlertProps = {
contentClass?: string;
/** 执行beforeClose回调期间,在内容区域显示一个loading遮罩*/
contentMasking?: boolean;
+ /** 弹窗底部内容(与按钮在同一个容器中) */
+ footer?: Component | string;
/** 弹窗的图标(在标题的前面) */
icon?: Component | IconType;
+ /**
+ * 弹窗遮罩模糊效果
+ */
+ overlayBlur?: number;
/** 是否显示取消按钮 */
showCancel?: boolean;
/** 弹窗标题 */
diff --git a/docs/src/components/common-ui/vben-api-component.md b/docs/src/components/common-ui/vben-api-component.md
index 17b8d306..2c84e56b 100644
--- a/docs/src/components/common-ui/vben-api-component.md
+++ b/docs/src/components/common-ui/vben-api-component.md
@@ -151,16 +151,17 @@ function fetchApi(): Promise> {
| options | 直接传入选项数据,也作为api返回空数据时的后备数据 | `OptionsItem[]` | - | - |
| visibleEvent | 触发重新请求数据的事件名 | `string` | - | - |
| loadingSlot | 目标组件的插槽名称,用来显示一个"加载中"的图标 | `string` | - | - |
-| autoSelect | 自动设置选项 | `'first' \| 'last' \| 'none'\| false` | `false` | >5.5.4 |
+| autoSelect | 自动设置选项 | `'first' \| 'last' \| 'one'\| ((item: OptionsItem[]) => OptionsItem) \| false` | `false` | >5.5.4 |
#### autoSelect 自动设置选项
如果当前值为undefined,在选项数据成功加载之后,自动从备选项中选择一个作为当前值。默认值为`false`,即不自动选择选项。注意:该属性不应用于多选组件。可选值有:
-- `first`:自动选择第一个选项
-- `last`:自动选择最后一个选项
-- `one`:有且仅有一个选项时,自动选择它
-- false:不自动选择选项
+- `"first"`:自动选择第一个选项
+- `"last"`:自动选择最后一个选项
+- `"one"`:有且仅有一个选项时,自动选择它
+- `自定义函数`:自定义选择逻辑,函数的参数为options,返回值为选择的选项
+- `false`:不自动选择选项
### Methods
@@ -168,3 +169,5 @@ function fetchApi(): Promise> {
| --- | --- | --- | --- |
| getComponentRef | 获取被包装的组件的实例 | ()=>T | >5.5.4 |
| updateParam | 设置接口请求参数(将与params属性合并) | (newParams: Record)=>void | >5.5.4 |
+| getOptions | 获取已加载的选项数据 | ()=>OptionsItem[] | >5.5.4 |
+| getValue | 获取当前值 | ()=>any | >5.5.4 |
diff --git a/docs/src/components/common-ui/vben-drawer.md b/docs/src/components/common-ui/vben-drawer.md
index 16accf0e..0eedb01b 100644
--- a/docs/src/components/common-ui/vben-drawer.md
+++ b/docs/src/components/common-ui/vben-drawer.md
@@ -127,13 +127,14 @@ const [Drawer, drawerApi] = useVbenDrawer({
除了上面的属性类型包含`slot`,还可以通过插槽来自定义弹窗的内容。
-| 插槽名 | 描述 |
-| -------------- | ------------------- |
-| default | 默认插槽 - 弹窗内容 |
-| prepend-footer | 取消按钮左侧 |
-| append-footer | 取消按钮右侧 |
-| close-icon | 关闭按钮图标 |
-| extra | 额外内容(标题右侧) |
+| 插槽名 | 描述 |
+| -------------- | -------------------------------------------------- |
+| default | 默认插槽 - 弹窗内容 |
+| prepend-footer | 取消按钮左侧 |
+| center-footer | 取消按钮和确认按钮中间(不使用 footer 插槽时有效) |
+| append-footer | 确认按钮右侧 |
+| close-icon | 关闭按钮图标 |
+| extra | 额外内容(标题右侧) |
### drawerApi
diff --git a/docs/src/components/common-ui/vben-modal.md b/docs/src/components/common-ui/vben-modal.md
index 39b88cf9..56ff6d3c 100644
--- a/docs/src/components/common-ui/vben-modal.md
+++ b/docs/src/components/common-ui/vben-modal.md
@@ -60,7 +60,6 @@ Modal 内的内容一般业务中,会比较复杂,所以我们可以将 moda
- `VbenModal` 组件对与参数的处理优先级是 `slot` > `props` > `state`(通过api更新的状态以及useVbenModal参数)。如果你已经传入了 `slot` 或者 `props`,那么 `setState` 将不会生效,这种情况下你可以通过 `slot` 或者 `props` 来更新状态。
- 如果你使用到了 `connectedComponent` 参数,那么会存在 2 个`useVbenModal`, 此时,如果同时设置了相同的参数,那么以内部为准(也就是没有设置 connectedComponent 的代码)。比如 同时设置了 `onConfirm`,那么以内部的 `onConfirm` 为准。`onOpenChange`事件除外,内外都会触发。
-- 使用了`connectedComponent`参数时,可以配置`destroyOnClose`属性来决定当关闭弹窗时,是否要销毁`connectedComponent`组件(重新创建`connectedComponent`组件,这将会把其内部所有的变量、状态、数据等恢复到初始状态。)。
- 如果弹窗的默认行为不符合你的预期,可以在`src\bootstrap.ts`中修改`setDefaultModalProps`的参数来设置默认的属性,如默认隐藏全屏按钮,修改默认ZIndex等。
:::
@@ -84,7 +83,7 @@ const [Modal, modalApi] = useVbenModal({
| --- | --- | --- | --- |
| appendToMain | 是否挂载到内容区域(默认挂载到body) | `boolean` | `false` |
| connectedComponent | 连接另一个Modal组件 | `Component` | - |
-| destroyOnClose | 关闭时销毁`connectedComponent` | `boolean` | `false` |
+| destroyOnClose | 关闭时销毁 | `boolean` | `false` |
| title | 标题 | `string\|slot` | - |
| titleTooltip | 标题提示信息 | `string\|slot` | - |
| description | 描述信息 | `string\|slot` | - |
@@ -138,11 +137,12 @@ const [Modal, modalApi] = useVbenModal({
除了上面的属性类型包含`slot`,还可以通过插槽来自定义弹窗的内容。
-| 插槽名 | 描述 |
-| -------------- | ------------------- |
-| default | 默认插槽 - 弹窗内容 |
-| prepend-footer | 取消按钮左侧 |
-| append-footer | 取消按钮右侧 |
+| 插槽名 | 描述 |
+| -------------- | -------------------------------------------------- |
+| default | 默认插槽 - 弹窗内容 |
+| prepend-footer | 取消按钮左侧 |
+| center-footer | 取消按钮和确认按钮中间(不使用 footer 插槽时有效) |
+| append-footer | 确认按钮右侧 |
### modalApi
diff --git a/docs/src/demos/vben-alert/confirm/index.vue b/docs/src/demos/vben-alert/confirm/index.vue
index 4dba6308..723445d9 100644
--- a/docs/src/demos/vben-alert/confirm/index.vue
+++ b/docs/src/demos/vben-alert/confirm/index.vue
@@ -1,6 +1,10 @@
diff --git a/playground/src/views/examples/modal/auto-height-demo.vue b/playground/src/views/examples/modal/auto-height-demo.vue
index 28939a62..5e8f7ad0 100644
--- a/playground/src/views/examples/modal/auto-height-demo.vue
+++ b/playground/src/views/examples/modal/auto-height-demo.vue
@@ -16,15 +16,18 @@ const [Modal, modalApi] = useVbenModal({
},
onOpenChange(isOpen) {
if (isOpen) {
- handleUpdate(10);
+ handleUpdate();
}
},
});
-function handleUpdate(len: number) {
+function handleUpdate(len?: number) {
modalApi.setState({ confirmDisabled: true, loading: true });
setTimeout(() => {
- list.value = Array.from({ length: len }, (_v, k) => k + 1);
+ list.value = Array.from(
+ { length: len ?? Math.floor(Math.random() * 10) + 1 },
+ (_v, k) => k + 1,
+ );
modalApi.setState({ confirmDisabled: false, loading: false });
}, 2000);
}
@@ -40,7 +43,7 @@ function handleUpdate(len: number) {
{{ item }}
-
+
diff --git a/playground/src/views/examples/modal/in-content-demo.vue b/playground/src/views/examples/modal/in-content-demo.vue
index b51d363f..7ffe7b77 100644
--- a/playground/src/views/examples/modal/in-content-demo.vue
+++ b/playground/src/views/examples/modal/in-content-demo.vue
@@ -24,7 +24,7 @@ const value = ref();
title="基础弹窗示例"
title-tooltip="标题提示内容"
>
- 此弹窗指定在内容区域打开
-
+ 此弹窗指定在内容区域打开,并且在关闭之后弹窗内容不会被销毁
+
diff --git a/playground/src/views/examples/modal/index.vue b/playground/src/views/examples/modal/index.vue
index 7401737a..3ed6cdea 100644
--- a/playground/src/views/examples/modal/index.vue
+++ b/playground/src/views/examples/modal/index.vue
@@ -198,7 +198,7 @@ async function openPrompt() {
-
+
在内容区域打开弹窗的示例
diff --git a/playground/src/views/system/menu/data.ts b/playground/src/views/system/menu/data.ts
index 75190b4a..ee787e50 100644
--- a/playground/src/views/system/menu/data.ts
+++ b/playground/src/views/system/menu/data.ts
@@ -11,7 +11,7 @@ export function getMenuTypeOptions() {
value: 'catalog',
},
{ color: 'default', label: $t('system.menu.typeMenu'), value: 'menu' },
- { color: 'error', label: $t('system.menu.typeButton'), value: 'button' },
+ { color: 'error', label: $t('system.menu.typeButton'), value: 'action' },
{
color: 'success',
label: $t('system.menu.typeEmbedded'),
diff --git a/playground/src/views/system/menu/modules/form.vue b/playground/src/views/system/menu/modules/form.vue
index 3cf40e35..6701a2e5 100644
--- a/playground/src/views/system/menu/modules/form.vue
+++ b/playground/src/views/system/menu/modules/form.vue
@@ -241,10 +241,10 @@ const schema: VbenFormSchema[] = [
component: 'Input',
dependencies: {
rules: (values) => {
- return values.type === 'button' ? 'required' : null;
+ return values.type === 'action' ? 'required' : null;
},
show: (values) => {
- return ['button', 'catalog', 'embedded', 'menu'].includes(values.type);
+ return ['action', 'catalog', 'embedded', 'menu'].includes(values.type);
},
triggerFields: ['type'],
},
@@ -277,7 +277,7 @@ const schema: VbenFormSchema[] = [
},
dependencies: {
show: (values) => {
- return values.type !== 'button';
+ return values.type !== 'action';
},
triggerFields: ['type'],
},
@@ -295,7 +295,7 @@ const schema: VbenFormSchema[] = [
},
dependencies: {
show: (values) => {
- return values.type !== 'button';
+ return values.type !== 'action';
},
triggerFields: ['type'],
},
@@ -314,7 +314,7 @@ const schema: VbenFormSchema[] = [
},
dependencies: {
show: (values) => {
- return values.type !== 'button';
+ return values.type !== 'action';
},
triggerFields: ['type'],
},
@@ -325,7 +325,7 @@ const schema: VbenFormSchema[] = [
component: 'Divider',
dependencies: {
show: (values) => {
- return !['button', 'link'].includes(values.type);
+ return !['action', 'link'].includes(values.type);
},
triggerFields: ['type'],
},
@@ -372,7 +372,7 @@ const schema: VbenFormSchema[] = [
component: 'Checkbox',
dependencies: {
show: (values) => {
- return !['button'].includes(values.type);
+ return !['action'].includes(values.type);
},
triggerFields: ['type'],
},
@@ -402,7 +402,7 @@ const schema: VbenFormSchema[] = [
component: 'Checkbox',
dependencies: {
show: (values) => {
- return !['button', 'link'].includes(values.type);
+ return !['action', 'link'].includes(values.type);
},
triggerFields: ['type'],
},
@@ -417,7 +417,7 @@ const schema: VbenFormSchema[] = [
component: 'Checkbox',
dependencies: {
show: (values) => {
- return !['button', 'link'].includes(values.type);
+ return !['action', 'link'].includes(values.type);
},
triggerFields: ['type'],
},