@@ -4,7 +4,7 @@ import type { PropType } from 'vue';
44
55import type { ActionItem , PopConfirm } from ' ./typing' ;
66
7- import { computed , unref } from ' vue' ;
7+ import { computed , unref , watch } from ' vue' ;
88
99import { useAccess } from ' @vben/access' ;
1010import { IconifyIcon } from ' @vben/icons' ;
@@ -60,21 +60,20 @@ function isIfShow(action: ActionItem): boolean {
6060
6161/** 处理按钮 actions */
6262const getActions = computed (() => {
63- return (props .actions || []).filter ((action : ActionItem ) => isIfShow (action ));
63+ const actions = props .actions || [];
64+ return actions .filter ((action : ActionItem ) => isIfShow (action ));
6465});
6566
6667/** 处理下拉菜单 actions */
6768const getDropdownList = computed (() => {
68- return (props .dropDownActions || []).filter ((action : ActionItem ) =>
69- isIfShow (action ),
70- );
69+ const dropDownActions = props .dropDownActions || [];
70+ return dropDownActions .filter ((action : ActionItem ) => isIfShow (action ));
7171});
7272
7373/** Space 组件的 size */
7474const spaceSize = computed (() => {
75- return unref (getActions )?.some ((item : ActionItem ) => item .type === ' link' )
76- ? 0
77- : 8 ;
75+ const actions = unref (getActions );
76+ return actions ?.some ((item : ActionItem ) => item .type === ' link' ) ? 0 : 8 ;
7877});
7978
8079/** 获取 PopConfirm 属性 */
@@ -137,6 +136,15 @@ function handleButtonClick(action: ActionItem) {
137136 action .onClick ();
138137 }
139138}
139+
140+ // 监听props变化,强制重新计算
141+ watch (
142+ () => [props .actions , props .dropDownActions ],
143+ () => {
144+ // 这里不需要额外处理,computed会自动重新计算
145+ },
146+ { deep: true },
147+ );
140148 </script >
141149
142150<template >
0 commit comments