diff --git a/.DS_Store b/.DS_Store
index b020d8e..e99f789 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/src/components/BasicPcShop/BasicComponents/Button/index.tsx b/src/components/BasicPcShop/BasicComponents/Button/index.tsx
new file mode 100644
index 0000000..addc599
--- /dev/null
+++ b/src/components/BasicPcShop/BasicComponents/Button/index.tsx
@@ -0,0 +1,9 @@
+import React, { memo } from 'react';
+import { IButtonConfig } from './schema';
+import { Button } from 'antd';
+const button = memo((props: IButtonConfig) => {
+ const { text, type } = props;
+ return ;
+});
+
+export default button;
diff --git a/src/components/BasicPcShop/BasicComponents/Button/schema.ts b/src/components/BasicPcShop/BasicComponents/Button/schema.ts
new file mode 100644
index 0000000..224e083
--- /dev/null
+++ b/src/components/BasicPcShop/BasicComponents/Button/schema.ts
@@ -0,0 +1,89 @@
+import {
+ IColorConfigType,
+ INumberConfigType,
+ ISelectConfigType,
+ ITextConfigType,
+ TColorDefaultType,
+ TNumberDefaultType,
+ TSelectDefaultType,
+ TTextDefaultType,
+} from '@/components/PanelComponents/FormEditor/types';
+
+export type TButtonSelectKeyType = 'left' | 'center' | 'right';
+
+export type TButtonEditData = Array<
+ IColorConfigType | INumberConfigType | ITextConfigType | ISelectConfigType
+>;
+export interface IButtonConfig {
+ bgColor: TColorDefaultType;
+ text: TTextDefaultType;
+ color: TColorDefaultType;
+ align: TSelectDefaultType;
+ fontSize: TNumberDefaultType;
+ height: TNumberDefaultType;
+ type: any;
+}
+
+export interface IButtonSchema {
+ editData: TButtonEditData;
+ config: IButtonConfig;
+}
+
+const Button: IButtonSchema = {
+ editData: [
+ {
+ key: 'bgColor',
+ name: '背景色',
+ type: 'Color',
+ },
+ {
+ key: 'height',
+ name: '高度',
+ type: 'Number',
+ },
+ {
+ key: 'text',
+ name: '文字',
+ type: 'Text',
+ },
+ {
+ key: 'fontSize',
+ name: '字体大小',
+ type: 'Number',
+ },
+ {
+ key: 'color',
+ name: '文字颜色',
+ type: 'Color',
+ },
+ {
+ key: 'align',
+ name: '对齐方式',
+ type: 'Select',
+ range: [
+ {
+ key: 'left',
+ text: '左对齐',
+ },
+ {
+ key: 'center',
+ text: '居中对齐',
+ },
+ {
+ key: 'right',
+ text: '右对齐',
+ },
+ ],
+ },
+ ],
+ config: {
+ bgColor: 'rgba(0,0,0,1)',
+ text: '按钮 button 按钮 button 按钮 button',
+ color: 'rgba(255,255,255,1)',
+ align: 'center',
+ fontSize: 16,
+ height: 48,
+ type: 'primary',
+ },
+};
+export default Button;
diff --git a/src/components/BasicPcShop/BasicComponents/Button/template.ts b/src/components/BasicPcShop/BasicComponents/Button/template.ts
new file mode 100644
index 0000000..07338da
--- /dev/null
+++ b/src/components/BasicPcShop/BasicComponents/Button/template.ts
@@ -0,0 +1,6 @@
+const template = {
+ type: 'Button',
+ h: 24,
+ x: 12,
+};
+export default template;
diff --git a/src/components/BasicPcShop/BasicComponents/schema.ts b/src/components/BasicPcShop/BasicComponents/schema.ts
index 3ceeed4..0f0f630 100644
--- a/src/components/BasicPcShop/BasicComponents/schema.ts
+++ b/src/components/BasicPcShop/BasicComponents/schema.ts
@@ -6,6 +6,7 @@ import List from './List/schema';
import LongText from './LongText/schema';
import Qrcode from './Qrcode/schema';
import Text from './Text/schema';
+import Button from './Button/schema';
const basicSchema = {
Footer,
@@ -15,6 +16,7 @@ const basicSchema = {
List,
LongText,
Qrcode,
- Text
+ Text,
+ Button,
};
export default basicSchema;
diff --git a/src/components/BasicPcShop/BasicComponents/template.ts b/src/components/BasicPcShop/BasicComponents/template.ts
index 55b8780..39e1ce3 100644
--- a/src/components/BasicPcShop/BasicComponents/template.ts
+++ b/src/components/BasicPcShop/BasicComponents/template.ts
@@ -6,17 +6,9 @@ import List from './List/template';
import LongText from './LongText/template';
import Qrcode from './Qrcode/template';
import Text from './Text/template';
+import Button from './Button/template';
-const basicTemplate = [
- Footer,
- Header,
- Icon,
- Image,
- List,
- LongText,
- Qrcode,
- Text,
-];
+const basicTemplate = [Footer, Header, Icon, Image, List, LongText, Qrcode, Text, Button];
const BasicTemplate = basicTemplate.map(v => {
return { ...v, category: 'base' };
});
diff --git a/src/components/PanelComponents/FormEditor/types.ts b/src/components/PanelComponents/FormEditor/types.ts
index 8e630bf..569c7e4 100644
--- a/src/components/PanelComponents/FormEditor/types.ts
+++ b/src/components/PanelComponents/FormEditor/types.ts
@@ -1,3 +1,5 @@
+import { type } from 'os';
+
////////////////////
export interface IUploadConfigType {
key: string;
@@ -199,6 +201,13 @@ export type baseFormDateTpl = {
placeholder: string;
};
+export type baseFormButtonTpl = {
+ key: string;
+ name: string;
+ type: 'Button';
+ icons: Array;
+};
+
export type baseFormUnion =
| baseFormTextTpl
| baseFormNumberTpl
@@ -206,7 +215,8 @@ export type baseFormUnion =
| baseFormMyRadioTpl
| baseFormMyCheckboxTpl
| baseFormMySelectTpl
- | baseFormDateTpl;
+ | baseFormDateTpl
+ | baseFormButtonTpl;
export type baseFormUnionType =
| baseFormTextTpl['type']
| baseFormNumberTpl['type']
@@ -214,6 +224,7 @@ export type baseFormUnionType =
| baseFormMyRadioTpl['type']
| baseFormMyCheckboxTpl['type']
| baseFormMySelectTpl['type']
- | baseFormDateTpl['type'];
+ | baseFormDateTpl['type']
+ | baseFormButtonTpl['type'];
export type TFormItemsDefaultType = Array;
diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx
index ee5fc20..3e35216 100644
--- a/src/layouts/index.tsx
+++ b/src/layouts/index.tsx
@@ -84,7 +84,7 @@ export default function Layout({ children }: IRouteComponentProps) {
);
const [state, setState] = useState('h5');
-
+ debugger;
return (
{
const { item } = props;
+ const context = useContext(dooringContext);
+ const schema = useMemo(() => {
+ if (context.theme === 'h5') {
+ return schemaH5;
+ } else {
+ return schemaPc;
+ }
+ }, [context.theme]);
const [{ isDragging }, drag] = useDrag({
item: {
type: item.type,