From 2628fb550db0056bbab3467560cb935cf188e34c Mon Sep 17 00:00:00 2001 From: vben Date: Sun, 25 Oct 2020 15:08:41 +0800 Subject: [PATCH] refactor(drawer): refactor props detailType to isDetail --- CHANGELOG.zh_CN.md | 5 +++++ src/components/Drawer/src/BasicDrawer.tsx | 6 +++--- src/components/Drawer/src/props.ts | 7 +++---- src/components/Drawer/src/types.ts | 6 +----- src/views/demo/comp/drawer/Drawer5.vue | 8 +++----- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 4d0b63095cd..9f575c1ebea 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -5,6 +5,11 @@ - 面包屑支持显示图标 - 新增 tinymce 富文本组件 - 表单新增 submitOnReset 控制是否在重置时重新发起请求 +- 表格新增`sortFn`支持自定义排序 + +### ✨ Refactor + +- Drawer 组件的 detailType 修改为 isDetail ### 🎫 Chores diff --git a/src/components/Drawer/src/BasicDrawer.tsx b/src/components/Drawer/src/BasicDrawer.tsx index 5094b6b1465..37cddfb2119 100644 --- a/src/components/Drawer/src/BasicDrawer.tsx +++ b/src/components/Drawer/src/BasicDrawer.tsx @@ -16,7 +16,7 @@ import { FullLoading } from '/@/components/Loading/index'; import { getSlot } from '/@/utils/helper/tsxHelper'; -import { DrawerInstance, DrawerProps, DrawerType } from './types'; +import { DrawerInstance, DrawerProps } from './types'; import { basicProps } from './props'; import { isFunction, isNumber } from '/@/utils/is'; @@ -54,7 +54,7 @@ export default defineComponent({ }; opt.title = undefined; - if (opt.drawerType === DrawerType.DETAIL) { + if (opt.isDetail) { if (!opt.width) { opt.width = '100%'; } @@ -157,7 +157,7 @@ export default defineComponent({ function renderHeader() { const { title } = unref(getMergeProps); - return props.drawerType === DrawerType.DETAIL ? ( + return props.isDetail ? ( getSlot(slots, 'title') || ( {() => ( diff --git a/src/components/Drawer/src/props.ts b/src/components/Drawer/src/props.ts index 3d2cc84c2f0..24148f0f345 100644 --- a/src/components/Drawer/src/props.ts +++ b/src/components/Drawer/src/props.ts @@ -1,5 +1,4 @@ import type { PropType } from 'vue'; -import { DrawerType } from './types'; // import {DrawerProps} from './types' export const footerProps = { confirmLoading: Boolean as PropType, @@ -41,9 +40,9 @@ export const footerProps = { }, }; export const basicProps = { - drawerType: { - type: Number as PropType, - default: DrawerType.DEFAULT, + isDetail: { + type: Boolean as PropType, + default: false, }, title: { type: String as PropType, diff --git a/src/components/Drawer/src/types.ts b/src/components/Drawer/src/types.ts index 3113bd2f1fb..c3eb9bfbc36 100644 --- a/src/components/Drawer/src/types.ts +++ b/src/components/Drawer/src/types.ts @@ -20,10 +20,6 @@ export interface ReturnInnerMethods extends DrawerInstance { export type UseDrawerReturnType = [RegisterFn, ReturnMethods]; export type UseDrawerInnerReturnType = [RegisterFn, ReturnInnerMethods]; -export enum DrawerType { - DETAIL, - DEFAULT, -} export interface DrawerFooterProps { showOkBtn: boolean; @@ -69,7 +65,7 @@ export interface DrawerFooterProps { footerHeight: string | number; } export interface DrawerProps extends DrawerFooterProps { - drawerType: DrawerType; + isDetail?: boolean; loading?: boolean; showDetailBack?: boolean; visible?: boolean; diff --git a/src/views/demo/comp/drawer/Drawer5.vue b/src/views/demo/comp/drawer/Drawer5.vue index 7d0d72cd874..e7a92513e53 100644 --- a/src/views/demo/comp/drawer/Drawer5.vue +++ b/src/views/demo/comp/drawer/Drawer5.vue @@ -1,15 +1,13 @@