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
@@ -5,6 +5,11 @@ | @@ -5,6 +5,11 @@ | ||
5 | - 面包屑支持显示图标 | 5 | - 面包屑支持显示图标 |
6 | - 新增 tinymce 富文本组件 | 6 | - 新增 tinymce 富文本组件 |
7 | - 表单新增 submitOnReset 控制是否在重置时重新发起请求 | 7 | - 表单新增 submitOnReset 控制是否在重置时重新发起请求 |
8 | +- 表格新增`sortFn`支持自定义排序 | ||
9 | + | ||
10 | +### ✨ Refactor | ||
11 | + | ||
12 | +- Drawer 组件的 detailType 修改为 isDetail | ||
8 | 13 | ||
9 | ### 🎫 Chores | 14 | ### 🎫 Chores |
10 | 15 |
src/components/Drawer/src/BasicDrawer.tsx
@@ -16,7 +16,7 @@ import { FullLoading } from '/@/components/Loading/index'; | @@ -16,7 +16,7 @@ import { FullLoading } from '/@/components/Loading/index'; | ||
16 | 16 | ||
17 | import { getSlot } from '/@/utils/helper/tsxHelper'; | 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 | import { basicProps } from './props'; | 21 | import { basicProps } from './props'; |
22 | import { isFunction, isNumber } from '/@/utils/is'; | 22 | import { isFunction, isNumber } from '/@/utils/is'; |
@@ -54,7 +54,7 @@ export default defineComponent({ | @@ -54,7 +54,7 @@ export default defineComponent({ | ||
54 | }; | 54 | }; |
55 | opt.title = undefined; | 55 | opt.title = undefined; |
56 | 56 | ||
57 | - if (opt.drawerType === DrawerType.DETAIL) { | 57 | + if (opt.isDetail) { |
58 | if (!opt.width) { | 58 | if (!opt.width) { |
59 | opt.width = '100%'; | 59 | opt.width = '100%'; |
60 | } | 60 | } |
@@ -157,7 +157,7 @@ export default defineComponent({ | @@ -157,7 +157,7 @@ export default defineComponent({ | ||
157 | 157 | ||
158 | function renderHeader() { | 158 | function renderHeader() { |
159 | const { title } = unref(getMergeProps); | 159 | const { title } = unref(getMergeProps); |
160 | - return props.drawerType === DrawerType.DETAIL ? ( | 160 | + return props.isDetail ? ( |
161 | getSlot(slots, 'title') || ( | 161 | getSlot(slots, 'title') || ( |
162 | <Row type="flex" align="middle" class={`${prefixCls}__detail-header`}> | 162 | <Row type="flex" align="middle" class={`${prefixCls}__detail-header`}> |
163 | {() => ( | 163 | {() => ( |
src/components/Drawer/src/props.ts
1 | import type { PropType } from 'vue'; | 1 | import type { PropType } from 'vue'; |
2 | -import { DrawerType } from './types'; | ||
3 | // import {DrawerProps} from './types' | 2 | // import {DrawerProps} from './types' |
4 | export const footerProps = { | 3 | export const footerProps = { |
5 | confirmLoading: Boolean as PropType<boolean>, | 4 | confirmLoading: Boolean as PropType<boolean>, |
@@ -41,9 +40,9 @@ export const footerProps = { | @@ -41,9 +40,9 @@ export const footerProps = { | ||
41 | }, | 40 | }, |
42 | }; | 41 | }; |
43 | export const basicProps = { | 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 | title: { | 47 | title: { |
49 | type: String as PropType<string>, | 48 | type: String as PropType<string>, |
src/components/Drawer/src/types.ts
@@ -20,10 +20,6 @@ export interface ReturnInnerMethods extends DrawerInstance { | @@ -20,10 +20,6 @@ export interface ReturnInnerMethods extends DrawerInstance { | ||
20 | 20 | ||
21 | export type UseDrawerReturnType = [RegisterFn, ReturnMethods]; | 21 | export type UseDrawerReturnType = [RegisterFn, ReturnMethods]; |
22 | export type UseDrawerInnerReturnType = [RegisterFn, ReturnInnerMethods]; | 22 | export type UseDrawerInnerReturnType = [RegisterFn, ReturnInnerMethods]; |
23 | -export enum DrawerType { | ||
24 | - DETAIL, | ||
25 | - DEFAULT, | ||
26 | -} | ||
27 | 23 | ||
28 | export interface DrawerFooterProps { | 24 | export interface DrawerFooterProps { |
29 | showOkBtn: boolean; | 25 | showOkBtn: boolean; |
@@ -69,7 +65,7 @@ export interface DrawerFooterProps { | @@ -69,7 +65,7 @@ export interface DrawerFooterProps { | ||
69 | footerHeight: string | number; | 65 | footerHeight: string | number; |
70 | } | 66 | } |
71 | export interface DrawerProps extends DrawerFooterProps { | 67 | export interface DrawerProps extends DrawerFooterProps { |
72 | - drawerType: DrawerType; | 68 | + isDetail?: boolean; |
73 | loading?: boolean; | 69 | loading?: boolean; |
74 | showDetailBack?: boolean; | 70 | showDetailBack?: boolean; |
75 | visible?: boolean; | 71 | visible?: boolean; |
src/views/demo/comp/drawer/Drawer5.vue
1 | <template> | 1 | <template> |
2 | - <BasicDrawer v-bind="$attrs" :drawerType="DrawerType.DETAIL" title="Drawer Title5"> | 2 | + <BasicDrawer v-bind="$attrs" :isDetail="true" title="Drawer Title5"> |
3 | <p class="h-20">Content Message</p> | 3 | <p class="h-20">Content Message</p> |
4 | </BasicDrawer> | 4 | </BasicDrawer> |
5 | </template> | 5 | </template> |
6 | <script lang="ts"> | 6 | <script lang="ts"> |
7 | import { defineComponent } from 'vue'; | 7 | import { defineComponent } from 'vue'; |
8 | - import { BasicDrawer, DrawerType } from '/@/components/Drawer'; | 8 | + import { BasicDrawer } from '/@/components/Drawer'; |
9 | export default defineComponent({ | 9 | export default defineComponent({ |
10 | components: { BasicDrawer }, | 10 | components: { BasicDrawer }, |
11 | - setup() { | ||
12 | - return { DrawerType }; | ||
13 | - }, | 11 | + setup() {}, |
14 | }); | 12 | }); |
15 | </script> | 13 | </script> |