fix: action绑定

pull/176/head
xingyu4j 2025-07-19 17:22:50 +08:00
parent cf27fd8ce9
commit cc3bf7e8a3
1 changed files with 16 additions and 8 deletions

View File

@ -4,7 +4,7 @@ import type { PropType } from 'vue';
import type { ActionItem, PopConfirm } from './typing'; import type { ActionItem, PopConfirm } from './typing';
import { computed, unref } from 'vue'; import { computed, unref, watch } from 'vue';
import { useAccess } from '@vben/access'; import { useAccess } from '@vben/access';
import { IconifyIcon } from '@vben/icons'; import { IconifyIcon } from '@vben/icons';
@ -60,21 +60,20 @@ function isIfShow(action: ActionItem): boolean {
/** 处理按钮 actions */ /** 处理按钮 actions */
const getActions = computed(() => { const getActions = computed(() => {
return (props.actions || []).filter((action: ActionItem) => isIfShow(action)); const actions = props.actions || [];
return actions.filter((action: ActionItem) => isIfShow(action));
}); });
/** 处理下拉菜单 actions */ /** 处理下拉菜单 actions */
const getDropdownList = computed(() => { const getDropdownList = computed(() => {
return (props.dropDownActions || []).filter((action: ActionItem) => const dropDownActions = props.dropDownActions || [];
isIfShow(action), return dropDownActions.filter((action: ActionItem) => isIfShow(action));
);
}); });
/** Space 组件的 size */ /** Space 组件的 size */
const spaceSize = computed(() => { const spaceSize = computed(() => {
return unref(getActions)?.some((item: ActionItem) => item.type === 'link') const actions = unref(getActions);
? 0 return actions?.some((item: ActionItem) => item.type === 'link') ? 0 : 8;
: 8;
}); });
/** 获取 PopConfirm 属性 */ /** 获取 PopConfirm 属性 */
@ -137,6 +136,15 @@ function handleButtonClick(action: ActionItem) {
action.onClick(); action.onClick();
} }
} }
// props
watch(
() => [props.actions, props.dropDownActions],
() => {
// computed
},
{ deep: true },
);
</script> </script>
<template> <template>