refactor(drawer): refactor props detailType to isDetail

This commit is contained in:
vben
2020-10-25 15:08:41 +08:00
parent 491ba9a3cc
commit 2628fb550d
5 changed files with 15 additions and 17 deletions

View File

@@ -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') || (
<Row type="flex" align="middle" class={`${prefixCls}__detail-header`}>
{() => (

View File

@@ -1,5 +1,4 @@
import type { PropType } from 'vue';
import { DrawerType } from './types';
// import {DrawerProps} from './types'
export const footerProps = {
confirmLoading: Boolean as PropType<boolean>,
@@ -41,9 +40,9 @@ export const footerProps = {
},
};
export const basicProps = {
drawerType: {
type: Number as PropType<number>,
default: DrawerType.DEFAULT,
isDetail: {
type: Boolean as PropType<boolean>,
default: false,
},
title: {
type: String as PropType<string>,

View File

@@ -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;