Commit 2628fb550db0056bbab3467560cb935cf188e34c
1 parent
491ba9a3
refactor(drawer): refactor props detailType to isDetail
Showing
5 changed files
with
15 additions
and
17 deletions
CHANGELOG.zh_CN.md
src/components/Drawer/src/BasicDrawer.tsx
... | ... | @@ -16,7 +16,7 @@ import { FullLoading } from '/@/components/Loading/index'; |
16 | 16 | |
17 | 17 | import { getSlot } from '/@/utils/helper/tsxHelper'; |
18 | 18 | |
19 | -import { DrawerInstance, DrawerProps, DrawerType } from './types'; | |
19 | +import { DrawerInstance, DrawerProps } from './types'; | |
20 | 20 | |
21 | 21 | import { basicProps } from './props'; |
22 | 22 | import { isFunction, isNumber } from '/@/utils/is'; |
... | ... | @@ -54,7 +54,7 @@ export default defineComponent({ |
54 | 54 | }; |
55 | 55 | opt.title = undefined; |
56 | 56 | |
57 | - if (opt.drawerType === DrawerType.DETAIL) { | |
57 | + if (opt.isDetail) { | |
58 | 58 | if (!opt.width) { |
59 | 59 | opt.width = '100%'; |
60 | 60 | } |
... | ... | @@ -157,7 +157,7 @@ export default defineComponent({ |
157 | 157 | |
158 | 158 | function renderHeader() { |
159 | 159 | const { title } = unref(getMergeProps); |
160 | - return props.drawerType === DrawerType.DETAIL ? ( | |
160 | + return props.isDetail ? ( | |
161 | 161 | getSlot(slots, 'title') || ( |
162 | 162 | <Row type="flex" align="middle" class={`${prefixCls}__detail-header`}> |
163 | 163 | {() => ( | ... | ... |
src/components/Drawer/src/props.ts
1 | 1 | import type { PropType } from 'vue'; |
2 | -import { DrawerType } from './types'; | |
3 | 2 | // import {DrawerProps} from './types' |
4 | 3 | export const footerProps = { |
5 | 4 | confirmLoading: Boolean as PropType<boolean>, |
... | ... | @@ -41,9 +40,9 @@ export const footerProps = { |
41 | 40 | }, |
42 | 41 | }; |
43 | 42 | export const basicProps = { |
44 | - drawerType: { | |
45 | - type: Number as PropType<number>, | |
46 | - default: DrawerType.DEFAULT, | |
43 | + isDetail: { | |
44 | + type: Boolean as PropType<boolean>, | |
45 | + default: false, | |
47 | 46 | }, |
48 | 47 | title: { |
49 | 48 | type: String as PropType<string>, | ... | ... |
src/components/Drawer/src/types.ts
... | ... | @@ -20,10 +20,6 @@ export interface ReturnInnerMethods extends DrawerInstance { |
20 | 20 | |
21 | 21 | export type UseDrawerReturnType = [RegisterFn, ReturnMethods]; |
22 | 22 | export type UseDrawerInnerReturnType = [RegisterFn, ReturnInnerMethods]; |
23 | -export enum DrawerType { | |
24 | - DETAIL, | |
25 | - DEFAULT, | |
26 | -} | |
27 | 23 | |
28 | 24 | export interface DrawerFooterProps { |
29 | 25 | showOkBtn: boolean; |
... | ... | @@ -69,7 +65,7 @@ export interface DrawerFooterProps { |
69 | 65 | footerHeight: string | number; |
70 | 66 | } |
71 | 67 | export interface DrawerProps extends DrawerFooterProps { |
72 | - drawerType: DrawerType; | |
68 | + isDetail?: boolean; | |
73 | 69 | loading?: boolean; |
74 | 70 | showDetailBack?: boolean; |
75 | 71 | visible?: boolean; | ... | ... |
src/views/demo/comp/drawer/Drawer5.vue
1 | 1 | <template> |
2 | - <BasicDrawer v-bind="$attrs" :drawerType="DrawerType.DETAIL" title="Drawer Title5"> | |
2 | + <BasicDrawer v-bind="$attrs" :isDetail="true" title="Drawer Title5"> | |
3 | 3 | <p class="h-20">Content Message</p> |
4 | 4 | </BasicDrawer> |
5 | 5 | </template> |
6 | 6 | <script lang="ts"> |
7 | 7 | import { defineComponent } from 'vue'; |
8 | - import { BasicDrawer, DrawerType } from '/@/components/Drawer'; | |
8 | + import { BasicDrawer } from '/@/components/Drawer'; | |
9 | 9 | export default defineComponent({ |
10 | 10 | components: { BasicDrawer }, |
11 | - setup() { | |
12 | - return { DrawerType }; | |
13 | - }, | |
11 | + setup() {}, | |
14 | 12 | }); |
15 | 13 | </script> | ... | ... |