From 923ff5e3223153bdb85c42949b1add7c77d3c1c7 Mon Sep 17 00:00:00 2001 From: RoXoM Date: Sat, 28 Oct 2023 13:45:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=A3=B0=E6=98=8E=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/@types/AMap.d.ts | 4 +++- src/components/AMapPolygonEditor/AMapPolygonEditor.tsx | 6 +----- src/components/AMapPolylineEditor/AMapPolylineEditor.tsx | 7 +------ 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/@types/AMap.d.ts b/src/@types/AMap.d.ts index 0e3d948..1c3cd3e 100644 --- a/src/@types/AMap.d.ts +++ b/src/@types/AMap.d.ts @@ -1,7 +1,7 @@ /* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable max-classes-per-file */ +import { _PolylineEditor } from '@amap/amap-jsapi-types/plugins/PolylineEditor'; import '@amap/amap-jsapi-types'; - // 对 amap type 做扩展 declare global { namespace AMap { @@ -114,6 +114,8 @@ declare global { remove: () => void; } + + export class PolylineEditor2 extends _PolylineEditor {} } namespace AMapUI { diff --git a/src/components/AMapPolygonEditor/AMapPolygonEditor.tsx b/src/components/AMapPolygonEditor/AMapPolygonEditor.tsx index 317fe2e..618cf18 100644 --- a/src/components/AMapPolygonEditor/AMapPolygonEditor.tsx +++ b/src/components/AMapPolygonEditor/AMapPolygonEditor.tsx @@ -4,10 +4,6 @@ import { useEffect, useRef, } from 'react'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { - _PolygonEditor as PolygonEditor, -} from '@amap/amap-jsapi-types/plugins/PolygonEditor'; import useAMap from '../../hooks/useAMap'; import useAMapPluginInstance from '../../hooks/useAMapPluginInstance'; @@ -26,7 +22,7 @@ const AMapPolygonEditor: FC = ({ $lastOnChange.current = onChange; const initInstance = useCallback((AMap, map) => new AMap!.PolygonEditor(map), []); - const curInstance = useAMapPluginInstance('PolygonEditor', initInstance); + const curInstance = useAMapPluginInstance('PolygonEditor', initInstance); const { map } = useAMap(); const reSetTarget = useCallback(() => { diff --git a/src/components/AMapPolylineEditor/AMapPolylineEditor.tsx b/src/components/AMapPolylineEditor/AMapPolylineEditor.tsx index b9be5dd..73ea825 100644 --- a/src/components/AMapPolylineEditor/AMapPolylineEditor.tsx +++ b/src/components/AMapPolylineEditor/AMapPolylineEditor.tsx @@ -5,11 +5,6 @@ import { useRef, } from 'react'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { - _PolylineEditor as PolylineEditor, -} from '@amap/amap-jsapi-types/plugins/PolylineEditor'; - import useAMap from '../../hooks/useAMap'; import useAMapPluginInstance from '../../hooks/useAMapPluginInstance'; import { isPolyline } from '../../helpers/amapHelper'; @@ -26,7 +21,7 @@ const AMapPolylineEditor: FC = ({ $lastOnChange.current = onChange; const initInstance = useCallback((AMap, map) => new AMap!.PolylineEditor(map), []); - const curInstance = useAMapPluginInstance('PolylineEditor', initInstance); + const curInstance = useAMapPluginInstance('PolylineEditor', initInstance); const { map } = useAMap(); const reSetTarget = useCallback(() => {