diff --git a/src/components/map-control-group/official-layer-control/index.tsx b/src/components/map-control-group/official-layer-control/index.tsx index 221be3c..cc28cbc 100644 --- a/src/components/map-control-group/official-layer-control/index.tsx +++ b/src/components/map-control-group/official-layer-control/index.tsx @@ -20,6 +20,7 @@ import { OfficeLayerEnum, } from '../../../constants'; import { useGlobal } from '../../../recoil'; +import type { CustomTilesProps } from '../../../types/l7editor'; import useStyle from './styles'; const layout = { @@ -31,13 +32,6 @@ const enLayout = { wrapperCol: { span: 15 }, }; -type CustomTilesItemProps = { - id: string; - image?: string; - title?: string; - layers?: string[]; -}; - export function OfficialLayerControl() { const [form] = Form.useForm(); const styles = useStyle(); @@ -98,7 +92,7 @@ export function OfficialLayerControl() { return false; // 阻止antd组件自动上传 }; - const onItemClick = (item: CustomTilesItemProps) => { + const onItemClick = (item: CustomTilesProps) => { setRadioValue(item.id); setLayerType( item.id === OfficeLayerEnum.VectorMap ? [] : ([item.id] as string[]), @@ -144,7 +138,7 @@ export function OfficialLayerControl() { const onConfirm = ( e: React.MouseEvent | undefined, - item: CustomTilesItemProps, + item: CustomTilesProps, ) => { e?.stopPropagation(); const newCustomTiles = customTiles.filter((val) => { diff --git a/src/recoil/atomState.ts b/src/recoil/atomState.ts index a7da11d..b75ccef 100644 --- a/src/recoil/atomState.ts +++ b/src/recoil/atomState.ts @@ -173,7 +173,7 @@ const textLayerFieldsState = atom({ effects: [localStorageEffect(LocalStorageKey.textLayerFields)], }); -const customTilesState = atom({ +const customTilesState = atom({ key: 'customTiles', default: [], effects: [localStorageEffect(LocalStorageKey.customTiles)], diff --git a/src/types/l7editor.ts b/src/types/l7editor.ts index 8fa4493..a9574b7 100644 --- a/src/types/l7editor.ts +++ b/src/types/l7editor.ts @@ -2,13 +2,13 @@ import type { LarkMapProps } from '@antv/larkmap'; import type { Feature } from '@turf/turf'; import type { TabsProps } from 'antd'; -export type CustomTilesProps = { +export interface CustomTilesProps { [key: string]: any; id: string; image: string; title: string; layers: string[]; -}[]; +} export interface MapControlProps { logoControl?: boolean; @@ -158,5 +158,5 @@ export interface L7EditorProps { /** * 自定义瓦片底图图层 */ - customTiles?: CustomTilesProps; + customTiles?: CustomTilesProps[]; }