Skip to content

Commit

Permalink
添加图形
Browse files Browse the repository at this point in the history
  • Loading branch information
lgf196 committed Apr 20, 2022
1 parent 1d0580c commit 10f2f51
Show file tree
Hide file tree
Showing 21 changed files with 187 additions and 7 deletions.
147 changes: 146 additions & 1 deletion src/assets/data/graphics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,152 @@ import { graphicsConfigItem } from '@/core/componentTemplate/graphics/Carrier/co
/**
* @description 通用图形
*/
export const universal = [graphicsConfigItem('universal_1', '长方形', { w: 150, h: 150 })];
export const universal = [
graphicsConfigItem(
'universal_square',
'正方形',
{
category: 'universal',
name: 'square',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_diamond',
'菱形',
{
category: 'universal',
name: 'diamond',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_quadrilateral',
'四边形',
{
category: 'universal',
name: 'quadrilateral',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_circle',
'圆形',
{
category: 'universal',
name: 'circle',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_rectangle',
'长方形',
{
category: 'universal',
name: 'rectangle',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_ellipse',
'椭圆形',
{
category: 'universal',
name: 'ellipse',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_hexagon',
'六边形',
{
category: 'universal',
name: 'hexagon',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_heptagon',
'七边形',
{
category: 'universal',
name: 'heptagon',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_octagon',
'八角形',
{
category: 'universal',
name: 'octagon',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_pentagon',
'五角形',
{
category: 'universal',
name: 'pentagon',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_trapezoid',
'梯形',
{
category: 'universal',
name: 'trapezoid',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_triangle',
'三角形',
{
category: 'universal',
name: 'triangle',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_cylinder',
'圆柱',
{
category: 'universal',
name: 'cylinder',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_prism',
'棱柱',
{
category: 'universal',
name: 'prism',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_cube',
'立方体',
{
category: 'universal',
name: 'cube',
},
{ w: 70, h: 70 },
),
graphicsConfigItem(
'universal_pyramid',
'锥形',
{
category: 'universal',
name: 'pyramid',
},
{ w: 70, h: 70 },
),
];

export default [
{
Expand Down
8 changes: 6 additions & 2 deletions src/core/componentTemplate/graphics/Carrier/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { commonAttr, defaultProps, commonStyle } from '@/core/config/common';
/**
*@param key 唯一值
*
@param key 唯一值
@param name 名称
* @param props 控件的属性
@param svg svg的一些相关的信息
@param props 控件的属性
*/
export const graphicsConfigItem = (
key: string,
name: string,
svg: svgInfoType,
props: Partial<mustExistProps & uncertainProps>,
): templateDataType => {
const { w, h } = props;
Expand All @@ -22,6 +25,7 @@ export const graphicsConfigItem = (
...props,
},
icon: 'https://cdn.gudsen.com/2021/09/30/af90bac80a9447f18156e251ecbc1dff.png',
svg,
style: {
...commonStyle,
width: w,
Expand Down
15 changes: 11 additions & 4 deletions src/core/componentTemplate/graphics/Carrier/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import React, { memo } from 'react';

const Index = memo((props) => {
return <div>Index</div>;
import React, { memo, useMemo, FC } from 'react';
const Index: FC<templateDataType> = memo(function Index(props) {
const { propValue, svg } = props;
const symbolId = useMemo(() => '#icon-graphics-' + `${svg?.category}-${svg?.name}`, [svg]);
return (
<>
<svg aria-hidden="true" width={propValue.w} height={propValue.h}>
<use xlinkHref={symbolId} />
</svg>
</>
);
});

export default Index;
1 change: 1 addition & 0 deletions src/icons/graphics/universal/circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/cube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/cylinder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/diamond.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/ellipse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/heptagon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/hexagon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/octagon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/pentagon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/prism.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/pyramid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/quadrilateral.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/rectangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/square.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/trapezoid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/icons/graphics/universal/triangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/types/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ interface getAllConfigListType {
title: string;
componentList: templateDataType[];
}
interface svgInfoType<T = string> {
category: T;
name: T;
}
4 changes: 4 additions & 0 deletions src/types/globalType.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ declare global {
* @description 是否锁定组件
*/
isLock?: boolean;
/**
* @description svg的相关信息
*/
svg?: null | svgInfoType;
[par: string]: any;
}
/**
Expand Down

0 comments on commit 10f2f51

Please sign in to comment.