diff --git a/.eslintrc b/.eslintrc index 2be111b..5e603ec 100755 --- a/.eslintrc +++ b/.eslintrc @@ -1,6 +1,3 @@ { - "extends": "react-app", - "rules": { - "react/react-in-jsx-scope": "off" - } + "extends": "react-app" } diff --git a/src/components/DynamicEngine/index.tsx b/src/components/DynamicEngine/index.tsx index ddfc243..10e95f7 100644 --- a/src/components/DynamicEngine/index.tsx +++ b/src/components/DynamicEngine/index.tsx @@ -2,7 +2,7 @@ import { dynamic } from 'umi'; import Loading from '../LoadingCp'; import { useMemo, memo, FC } from 'react'; import React from 'react'; -import { UnionData, AllTemplateType } from './schema'; +import { AllTemplateType } from './schema'; const needList = ['Tab', 'Carousel', 'Upload', 'Video', 'Icon']; const DynamicFunc = (type: AllTemplateType) => @@ -33,11 +33,12 @@ const DynamicFunc = (type: AllTemplateType) => type DynamicType = { isTpl: boolean; - config: UnionData<'config'>; + config: { [key: string]: any }; type: AllTemplateType; }; const DynamicEngine = memo((props: DynamicType) => { const { type, config, isTpl } = props; + console.log(config); const Dynamic = useMemo(() => { return (DynamicFunc(type) as unknown) as FC; // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/components/DynamicEngine/schema.ts b/src/components/DynamicEngine/schema.ts index b0fcee5..40003a4 100644 --- a/src/components/DynamicEngine/schema.ts +++ b/src/components/DynamicEngine/schema.ts @@ -75,12 +75,7 @@ export type CarouselImgTypeItem = BasicDataImgUrl; export type CarouselImgType = BasicDataSource; export interface CarouselSchema extends SchemaBasicImplement { - editData: [ - CarouselEditItem<'direction'>, - CarouselEditItem<'swipeable'>, - CarouselEditItem<'autoPlay'>, - CarouselEditItem<'imgList'>, - ]; + editData: Array>; config: CarouselConfigType; } //__________________________________________ @@ -104,13 +99,7 @@ export interface TextEditItem { } export interface TextSchema extends SchemaBasicImplement { - editData: [ - TextEditItem<'text'>, - TextEditItem<'color'>, - TextEditItem<'fontSize'>, - TextEditItem<'align'>, - TextEditItem<'lineHeight'>, - ]; + editData: Array>; config: TextConfigType; } @@ -140,14 +129,7 @@ export type TabEditItem = { }; export interface TabSchema extends SchemaBasicImplement { - editData: [ - TabEditItem<'tabs'>, - TabEditItem<'activeColor'>, - TabEditItem<'color'>, - TabEditItem<'fontSize'>, - TabEditItem<'imgSize'>, - TabEditItem<'sourceData'>, - ]; + editData: Array>; config: TabConfigType; } //__________________________________________ @@ -173,12 +155,7 @@ export type NoticeEditItem = { range?: Array; }; export interface NoticeSchema extends SchemaBasicImplement { - editData: [ - NoticeEditItem<'text'>, - NoticeEditItem<'speed'>, - NoticeEditItem<'theme'>, - NoticeEditItem<'isClose'>, - ]; + editData: Array>; config: NoticeConfigType; } @@ -202,12 +179,7 @@ export type QRCodeEditItem = { }; export interface QRCodeSchema extends SchemaBasicImplement { - editData: [ - QRCodeEditItem<'qrcode'>, - QRCodeEditItem<'text'>, - QRCodeEditItem<'color'>, - QRCodeEditItem<'fontSize'>, - ]; + editData: Array>; config: QRCodeConfigType; } @@ -233,14 +205,7 @@ export type FooterEditItem = { }; export interface FooterSchema extends SchemaBasicImplement { - editData: [ - FooterEditItem<'bgColor'>, - FooterEditItem<'height'>, - FooterEditItem<'text'>, - FooterEditItem<'fontSize'>, - FooterEditItem<'color'>, - FooterEditItem<'align'>, - ]; + editData: Array>; config: FooterConfigType; } @@ -262,7 +227,7 @@ export type ImageEditItem = { }; export interface ImageSchema extends SchemaBasicImplement { - editData: [ImageEditItem<'imgUrl'>, ImageEditItem<'round'>]; + editData: Array>; config: ImageConfigType; } @@ -289,14 +254,7 @@ export type HeaderEditItem = { }; export interface HeaderSchema extends SchemaBasicImplement { - editData: [ - HeaderEditItem<'bgColor'>, - HeaderEditItem<'height'>, - HeaderEditItem<'logo'>, - HeaderEditItem<'logoText'>, - HeaderEditItem<'color'>, - HeaderEditItem<'fontSize'>, - ]; + editData: Array>; config: HeaderConfigType; } @@ -320,13 +278,7 @@ export type ListEditItem = { }; export interface ListSchema extends SchemaBasicImplement { - editData: [ - ListEditItem<'sourceData'>, - ListEditItem<'round'>, - ListEditItem<'imgSize'>, - ListEditItem<'fontSize'>, - ListEditItem<'color'>, - ]; + editData: Array>; config: ListConfigType; } //__________________________________________ @@ -392,12 +344,7 @@ export type IconEditItem = { }; export interface IconSchema extends SchemaBasicImplement { - editData: [ - IconEditItem<'color'>, - IconEditItem<'size'>, - IconEditItem<'spin'>, - IconEditItem<'type'>, - ]; + editData: Array>; config: IconConfigType; } @@ -418,7 +365,7 @@ export type VideoEditItem = { }; export interface VideoSchema extends SchemaBasicImplement { - editData: [VideoEditItem<'poster'>, VideoEditItem<'url'>]; + editData: Array>; config: VideoConfigType; } @@ -444,13 +391,7 @@ export type XProgressEditItem = { }; export interface XProgressSchema extends SchemaBasicImplement { - editData: [ - XProgressEditItem<'theme'>, - XProgressEditItem<'shape'>, - XProgressEditItem<'size'>, - XProgressEditItem<'percent'>, - XProgressEditItem<'strokeWidth'>, - ]; + editData: Array>; config: XProgressConfigType; } @@ -472,20 +413,6 @@ export interface SchemaType extends SchemaImplement { XProgress: XProgressSchema; } -export type UnionData = - | CarouselSchema[T] - | TextSchema[T] - | TabSchema[T] - | NoticeSchema[T] - | QRCodeSchema[T] - | FooterSchema[T] - | ImageSchema[T] - | HeaderSchema[T] - | ListSchema[T] - | IconSchema[T] - | VideoSchema[T] - | XProgressSchema[T]; - const schema: SchemaType = { Carousel: { editData: [ diff --git a/src/components/FormEditor/index.tsx b/src/components/FormEditor/index.tsx index 3bda828..2114922 100644 --- a/src/components/FormEditor/index.tsx +++ b/src/components/FormEditor/index.tsx @@ -6,7 +6,7 @@ import MutiText from '../MutiText'; import Color from '../Color'; import CardPicker from '../CardPicker'; import { Store } from 'antd/lib/form/interface'; -import { UnionData, BasicRangeType, IconSchema } from '../DynamicEngine/schema'; +import { BasicRangeType, IconSchema } from '../DynamicEngine/schema'; // import styles from './index.less'; const normFile = (e: any) => { console.log('Upload event:', e); @@ -34,7 +34,6 @@ interface FormEditorProps { const FormEditor = (props: FormEditorProps) => { const { config, defaultValue, onSave, onDel, uid } = props; - console.log(config, defaultValue, uid); const onFinish = (values: Store) => { onSave && onSave(values); };