perf: perf excel comp code

This commit is contained in:
vben
2020-10-20 21:24:27 +08:00
parent 968f791f4b
commit eecde4c7e9
14 changed files with 144 additions and 183 deletions

View File

@@ -19,16 +19,17 @@ export default defineComponent({
const getModeRef = computed(() => {
return appStore.getProjectConfig.permissionMode;
});
/**
* 渲染角色按钮
*/
function renderRoleAuth() {
const { value } = props;
if (!value) {
return getSlot(slots, 'default');
return getSlot(slots);
}
const { hasPermission } = usePermission();
return hasPermission(value) ? getSlot(slots, 'default') : null;
return hasPermission(value) ? getSlot(slots) : null;
}
/**
@@ -38,11 +39,12 @@ export default defineComponent({
function renderCodeAuth() {
const { value } = props;
if (!value) {
return getSlot(slots, 'default');
return getSlot(slots);
}
const { hasPermission } = usePermission();
return hasPermission(value) ? getSlot(slots, 'default') : null;
return hasPermission(value) ? getSlot(slots) : null;
}
return () => {
const mode = unref(getModeRef);
// 基于角色渲染
@@ -53,7 +55,7 @@ export default defineComponent({
if (mode === PermissionModeEnum.BACK) {
return renderCodeAuth();
}
return getSlot(slots, 'default');
return getSlot(slots);
};
},
});