From 026c422ff184c3edba445f2a034b838a6b8d0b4a Mon Sep 17 00:00:00 2001 From: Cmen <1176967590@qq.com> Date: Tue, 1 Mar 2022 20:55:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=8F=9C=E5=8D=95=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E7=BB=91=E5=AE=9A=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor/Menu/File.tsx | 9 +++++---- src/editor/Menu/MenuGroup.tsx | 4 +++- src/editor/Plot/Tools/index.tsx | 7 +++---- src/store/GlobalController.ts | 10 +++++----- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/editor/Menu/File.tsx b/src/editor/Menu/File.tsx index 2e0b34e..a68d982 100644 --- a/src/editor/Menu/File.tsx +++ b/src/editor/Menu/File.tsx @@ -1,15 +1,16 @@ +import { globalController } from "@store"; import MenuGroup from "./MenuGroup"; const FileMenu = () => { - const openGeoJSON = () => {}; return ( diff --git a/src/editor/Menu/MenuGroup.tsx b/src/editor/Menu/MenuGroup.tsx index 1fd9570..a2968f0 100644 --- a/src/editor/Menu/MenuGroup.tsx +++ b/src/editor/Menu/MenuGroup.tsx @@ -14,7 +14,9 @@ const MenuGroup = (props: MenuConfig) => { const menu = ( {props.items.map((item, index) => ( - {item.name} + + {item.name} + ))} ); diff --git a/src/editor/Plot/Tools/index.tsx b/src/editor/Plot/Tools/index.tsx index 06ba310..d758df6 100644 --- a/src/editor/Plot/Tools/index.tsx +++ b/src/editor/Plot/Tools/index.tsx @@ -1,7 +1,7 @@ import { Tooltip } from "antd"; -import { useDispatch, useSelector } from "react-redux"; +import { useSelector } from "react-redux"; import classnames from "classnames"; -import { EditorAction, OverlayNamePrefixs, mapStateSelector } from "@store"; +import { globalController, OverlayNamePrefixs, mapStateSelector } from "@store"; import { OverlayTypes } from "@types"; type IconWithTipProps = { @@ -36,14 +36,13 @@ type OverlayToolProps = { }; const OverlayTool = (props: OverlayToolProps) => { - const dispatch = useDispatch(); const { type } = props; const text = OverlayNamePrefixs[type]; const { overlayType } = useSelector(mapStateSelector); const selected = type === overlayType; - const onClick = () => dispatch(EditorAction.createOverlay(type)); + const onClick = () => globalController.createOverlay(type); return ; }; diff --git a/src/store/GlobalController.ts b/src/store/GlobalController.ts index 134ea70..9f3f551 100644 --- a/src/store/GlobalController.ts +++ b/src/store/GlobalController.ts @@ -55,19 +55,19 @@ export class GlobelController implements IGlobalController { // } createRectangle() { - this._createOverlay(OverlayTypes.Rectangle); + this.createOverlay(OverlayTypes.Rectangle); } createPolygon() { - this._createOverlay(OverlayTypes.Polygon); + this.createOverlay(OverlayTypes.Polygon); } createPolyline() { - this._createOverlay(OverlayTypes.Polyline); + this.createOverlay(OverlayTypes.Polyline); } createCircle() { - this._createOverlay(OverlayTypes.Circle); + this.createOverlay(OverlayTypes.Circle); } - private _createOverlay(type: OverlayTypes) { + createOverlay(type: OverlayTypes) { this._store.dispatch(EditorAction.createOverlay(type)); }