Skip to content

Commit

Permalink
perf: remove optional chain
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 23, 2020
1 parent 144fde8 commit e034d1b
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 275 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
## Wip

### ✨ Features

- 面包屑支持显示图标
- 新增 tinymce 富文本组件

### 🎫 Chores

- 删除代码内的可选链语法

### 🐛 Bug Fixes

- 修复抽屉组件自动高度及显示 footer 显示问题
- 修复表单查询后重置回默认值
- 修复菜单没有子节点时显示折叠的问题
- 修复面包屑显示样式问题
- 修复 modal 在 destroyOnClose=true 时多次打开拖拽失效

# 2.0.0-rc.4 (2020-10-21)

Expand Down
2 changes: 2 additions & 0 deletions src/components/Authority/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Authority from './src/index.vue';
export default Authority;
61 changes: 0 additions & 61 deletions src/components/Authority/index.tsx

This file was deleted.

65 changes: 65 additions & 0 deletions src/components/Authority/src/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<script lang="ts">
import { defineComponent, PropType, computed, unref } from 'vue';
import { PermissionModeEnum } from '/@/enums/appEnum';
import { RoleEnum } from '/@/enums/roleEnum';
import { usePermission } from '/@/hooks/web/usePermission';
import { appStore } from '/@/store/modules/app';
import { getSlot } from '/@/utils/helper/tsxHelper';
export default defineComponent({
name: 'Authority',
props: {
// 指定角色可见
value: {
type: [Number, Array, String] as PropType<RoleEnum | RoleEnum[]>,
default: '',
},
},
setup(props, { slots }) {
const getModeRef = computed(() => {
return appStore.getProjectConfig.permissionMode;
});
/**
* 渲染角色按钮
*/
function renderRoleAuth() {
const { value } = props;
if (!value) {
return getSlot(slots);
}
const { hasPermission } = usePermission();
return hasPermission(value) ? getSlot(slots) : null;
}
/**
* 渲染编码按钮
* 这里只判断是否包含,具体实现可以根据项目自行写逻辑
*/
function renderCodeAuth() {
const { value } = props;
if (!value) {
return getSlot(slots);
}
const { hasPermission } = usePermission();
return hasPermission(value) ? getSlot(slots) : null;
}
return () => {
const mode = unref(getModeRef);
// 基于角色渲染
if (mode === PermissionModeEnum.ROLE) {
return renderRoleAuth();
}
// 基于后台编码渲染
if (mode === PermissionModeEnum.BACK) {
return renderCodeAuth();
}
return getSlot(slots);
};
},
});
</script>
2 changes: 1 addition & 1 deletion src/components/Basic/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { default as BasicArrow } from './src/BasicArrow.vue';
export { default as BasicHelp } from './src/BasicHelp';
export { default as BasicHelp } from './src/BasicHelp.vue';
export { default as BasicTitle } from './src/BasicTitle.vue';
19 changes: 0 additions & 19 deletions src/components/Basic/src/BasicHelp.less

This file was deleted.

107 changes: 0 additions & 107 deletions src/components/Basic/src/BasicHelp.tsx

This file was deleted.

Loading

0 comments on commit e034d1b

Please sign in to comment.