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