From 07cd0bb8ef327b320299f2a2d3a9f2b1282433d5 Mon Sep 17 00:00:00 2001 From: yanxiong Date: Thu, 19 Oct 2023 19:18:28 +0800 Subject: [PATCH 1/4] =?UTF-8?q?chore:=20=E8=A1=A5=E5=85=85=20Github=20?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index bb7dd386..7e3eda69 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "module": "es/index.js", "types": "es/index.d.ts", "license": "MIT", - "author": "oujinhui.ojh", "scripts": { "start": "dumi dev", "build": "father build", @@ -110,6 +109,11 @@ "prettier --parser=typescript --write" ] }, + "author": { + "name": "AntV", + "url": "https://antv.antgroup.com" + }, + "homepage": "https://l7editor.antv.antgroup.com", "repository": { "type": "git", "url": "https://github.com/antvis/L7Editor" @@ -117,5 +121,8 @@ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" + }, + "bugs": { + "url": "https://github.com/antvis/L7Editor/issues" } } \ No newline at end of file From 677041980fb62463cfec94c95caaccb1e4f13af8 Mon Sep 17 00:00:00 2001 From: yanxiong Date: Thu, 19 Oct 2023 19:23:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?build:=20=E4=BF=AE=E5=A4=8D=20sam=20?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/lint.yml | 1 + .github/workflows/preview.yml | 1 + .github/workflows/release.yml | 2 ++ 3 files changed, 4 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0b1bf030..4842ee2d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,6 +14,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} + - run: npm config set registry https://registry.npm.taobao.org/ - run: npm install - run: npm run ci # - name: coverall diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index ca7ad44e..eb34743a 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -20,5 +20,6 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist build: | + npm config set registry https://registry.npm.taobao.org/ npm install npm run docs:build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 62bbab7e..6e81999f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,7 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 + - run: npm config set registry https://registry.npm.taobao.org/ - run: npm install - run: npm run ci @@ -23,6 +24,7 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 + - run: npm config set registry https://registry.npm.taobao.org/ - run: npm install - run: npm run docs:build - run: | From 9125490e464257f68c8e16c0c9f12fe10b9c6dba Mon Sep 17 00:00:00 2001 From: yanxiong Date: Thu, 19 Oct 2023 19:26:55 +0800 Subject: [PATCH 3/4] =?UTF-8?q?build:=20=E5=B0=86=20CI=20=E4=B8=AD=20npm?= =?UTF-8?q?=20=E6=9B=BF=E6=8D=A2=E4=B8=BA=20yarn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/lint.yml | 5 ++--- .github/workflows/preview.yml | 5 ++--- .github/workflows/release.yml | 10 ++++------ package.json | 3 --- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4842ee2d..aff590cf 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,9 +14,8 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - - run: npm config set registry https://registry.npm.taobao.org/ - - run: npm install - - run: npm run ci + - run: yarn + - run: yarn ci # - name: coverall # if: success() # uses: coverallsapp/github-action@master diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index eb34743a..c05eea89 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -20,6 +20,5 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist build: | - npm config set registry https://registry.npm.taobao.org/ - npm install - npm run docs:build + yarn + yarn docs:build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e81999f..4fde9528 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,9 +12,8 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 - - run: npm config set registry https://registry.npm.taobao.org/ - - run: npm install - - run: npm run ci + - run: yarn + - run: yarn ci publish-site: needs: build @@ -24,9 +23,8 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 - - run: npm config set registry https://registry.npm.taobao.org/ - - run: npm install - - run: npm run docs:build + - run: yarn + - run: yarn docs:build - run: | cd docs-dist git init diff --git a/package.json b/package.json index 7e3eda69..257c465b 100644 --- a/package.json +++ b/package.json @@ -61,9 +61,6 @@ "wellknown": "^0.5.0", "xlsx": "^0.18.5" }, - "tnpm": { - "mode": "npm" - }, "yuyanId": "180020010001251474", "devDependencies": { "@antv/l7": "^2.11.0", From 0d87f7028465448fa87ca9bc5b8cfc37930fe71a Mon Sep 17 00:00:00 2001 From: yanxiong Date: Fri, 20 Oct 2023 10:19:37 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20eslint=20?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 11 +- .../app-header/btn/download-btn.tsx | 9 +- .../app-header/btn/import-btn/file-upload.tsx | 39 +-- .../app-header/btn/import-btn/index.tsx | 16 +- .../btn/import-btn/lnglat-import-btn.tsx | 8 +- .../app-header/btn/import-btn/url-upload.tsx | 2 +- src/components/app-header/index.tsx | 1 + src/components/app-header/styles.ts | 3 +- src/components/app-map/index.tsx | 5 +- src/components/app-table/index.tsx | 25 +- src/components/geojson-editor/index.tsx | 4 +- .../layer-contextmenu-popup/code-block.tsx | 2 + .../layer-contextmenu-popup/index.tsx | 7 +- src/components/layer-list/index.tsx | 10 +- src/components/layer-popup/index.tsx | 261 +++++++++--------- src/components/lnglat-editor/index.tsx | 7 +- src/components/map-content/index.tsx | 6 +- .../administrative-select-control/index.tsx | 44 +-- .../map-control-group/draw-control/index.tsx | 8 +- .../filter-form-list-control/index.tsx | 2 +- .../filter-form-list-control/numberFilter.tsx | 5 +- .../filter-form-list-control/stringFilter.tsx | 5 +- .../filter-form-list-control/styles.ts | 2 - src/components/map-control-group/index.tsx | 2 +- .../location-search-control/index.tsx | 2 +- .../official-layer-control/index.tsx | 5 +- .../official-layer-control/styles.ts | 5 - .../map-control-group/sam-control/index.tsx | 4 +- .../save-map-options-control/index.tsx | 2 +- src/components/resize-panel/index.tsx | 22 +- src/components/resize-panel/styles.ts | 2 - src/components/text-layer/index.tsx | 10 +- src/components/wkt-editor/index.tsx | 1 + src/hooks/use-filter-features.ts | 4 +- src/locales/index.ts | 1 + src/pages/components/editor.tsx | 2 + src/pages/index.tsx | 3 +- src/recoil/atomState.ts | 8 +- src/recoil/feature.ts | 34 ++- src/recoil/lnglat.ts | 13 +- src/types/filter.ts | 47 ++-- src/types/l7editor.ts | 6 +- src/utils/file-to-source.ts | 20 +- src/utils/gcoord.ts | 2 +- src/utils/index.ts | 5 +- src/utils/lnglat.ts | 19 +- src/utils/transform.ts | 3 +- 47 files changed, 366 insertions(+), 338 deletions(-) diff --git a/package.json b/package.json index 257c465b..25f6627e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@antv/l7-editor", - "version": "1.1.2", + "version": "1.1.3", "description": "Geographic data editing tool based on L7", "files": [ "lib", @@ -15,13 +15,13 @@ "build": "father build", "i18n:collect": "kiwi --extract src", "lint": "run-p lint:*", - "lint:ts": "eslint src __tests__ --ext .ts,.tsx --ignore-pattern 'src/**/demos/'", - "lint:style": "stylelint --fix src/**/*.less", - "prettier": "prettier --write 'src/*.{tsx,ts,md,json}'", - "lint-fix": "eslint src __tests__ --fix --ext .ts,.tsx --format=pretty && npm run lint:style", + "lint:ts": "eslint src --ext .ts,.tsx --ignore-pattern 'src/**/demos/'", + "lint-fix": "eslint src --fix --ext .ts,.tsx --format=pretty", + "prettier": "prettier --write 'src/**.{tsx,ts,md,json}'", "clean": "rimraf es lib dist umd", "format": "prettier --cache --write .", "prepare": "dumi setup", + "ci": "run-s lint doctor build", "setup": "dumi setup", "doctor": "father doctor", "docs:build": "dumi build", @@ -87,6 +87,7 @@ "gh-pages": "^4.0.0", "husky": "^8.0.1", "lint-staged": "^13.0.3", + "npm-run-all": "^4.1.5", "typescript": "^4.1.2", "webpack-bundle-analyzer": "^4.9.0" }, diff --git a/src/components/app-header/btn/download-btn.tsx b/src/components/app-header/btn/download-btn.tsx index 45d3a502..37b062a5 100644 --- a/src/components/app-header/btn/download-btn.tsx +++ b/src/components/app-header/btn/download-btn.tsx @@ -1,14 +1,15 @@ import { CloudDownloadOutlined } from '@ant-design/icons'; import { coordAll } from '@turf/turf'; -import { Button, Dropdown, MenuProps } from 'antd'; +import type { MenuProps } from 'antd'; +import { Button, Dropdown } from 'antd'; import React from 'react'; import { useTranslation } from 'react-i18next'; -import { downloadText } from '../../../utils'; -import { prettierText } from '../../../utils/prettier-text'; -import { useFeature } from './../../../recoil'; // @ts-ignore import tokml from 'tokml'; +import { downloadText } from '../../../utils'; +import { prettierText } from '../../../utils/prettier-text'; import { GeoJSON2Wkt } from '../../../utils/wkt'; +import { useFeature } from './../../../recoil'; const DownloadBtn: React.FC = () => { const { editorText, fc } = useFeature(); diff --git a/src/components/app-header/btn/import-btn/file-upload.tsx b/src/components/app-header/btn/import-btn/file-upload.tsx index 92455662..0a137bf6 100644 --- a/src/components/app-header/btn/import-btn/file-upload.tsx +++ b/src/components/app-header/btn/import-btn/file-upload.tsx @@ -1,6 +1,8 @@ import { FileTextOutlined, QuestionCircleOutlined } from '@ant-design/icons'; -import { Geometry, feature, featureCollection } from '@turf/turf'; -import { Form, Select, Tooltip, Upload, UploadFile, message } from 'antd'; +import type { Geometry } from '@turf/turf'; +import { feature, featureCollection } from '@turf/turf'; +import type { UploadFile } from 'antd'; +import { Form, Select, Tooltip, Upload, message } from 'antd'; import { cloneDeep } from 'lodash'; import React, { forwardRef, @@ -114,46 +116,47 @@ const FileUpload = forwardRef(function FileUpload({}, ref) { } }), }), - [fileList, uploadData], + [fileList, t, uploadData], ); const selectItem = useMemo(() => { if (selectList.length) { const data = selectList.map((item, index) => { - const options = item.columns.map((item: string | number) => { + const options = item.columns.map((option: string | number) => { return { - value: item, - label: item, + value: option, + label: option, }; }); return ( save(key, value)} + onBlur={() => save(key, value)} + /> + )} + + + ) : ( +
{ + setTableClick({ + isInput: !tableClick.isInput, + index: index, + }); + setAddOpen(false); + form.setFieldsValue({ input: value }); + }} + > + {value ? String(value) : '-'} +
+ )} + + + ); + } + return null; + })} + {addOpen && ( + { + setAddValue((prevState) => ({ + ...prevState, + label: e.target.value, + })); + }} + onBlur={addBlur} + /> + } + > +
+ { + setAddValue((prevState) => ({ + ...prevState, + value: e.target.value, + })); + }} + onBlur={addBlur} + /> +
+
+ )} + + + ) : ( + + )} +
+ {!addOpen && ( +
- - )} - - - ) : ( - + + {t('layer_popup.index.tianJiaZiDuan')} + )} -
- {!addOpen && ( - - )} -
- ); - }, [featureFields, popupProps.feature, addOpen]); + + ); return ( <> diff --git a/src/components/lnglat-editor/index.tsx b/src/components/lnglat-editor/index.tsx index f82fead9..af3bde5a 100644 --- a/src/components/lnglat-editor/index.tsx +++ b/src/components/lnglat-editor/index.tsx @@ -3,7 +3,7 @@ import { Input } from 'antd'; import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useFeature, useGlobal } from '../../recoil'; -import { IFeatures } from '../../types'; +import type { IFeatures } from '../../types'; import { GeoJSON2LngLat, LngLat2GeoJson } from '../../utils'; const { TextArea } = Input; @@ -23,11 +23,12 @@ export const LngLatEditor: React.FC = () => { if (result !== input) { setInput(result); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [fc, isFocus]); const { run: onInputChange } = useDebounceFn( - (input: string) => { - const features = LngLat2GeoJson(input); + (newInput: string) => { + const features = LngLat2GeoJson(newInput); if (features) { resetFeatures(features as IFeatures); if (autoFitBounds) { diff --git a/src/components/map-content/index.tsx b/src/components/map-content/index.tsx index 1ada13cd..ebd573bd 100644 --- a/src/components/map-content/index.tsx +++ b/src/components/map-content/index.tsx @@ -1,6 +1,7 @@ import { GlobalOutlined, TableOutlined } from '@ant-design/icons'; -import { Feature } from '@turf/turf'; -import { Select, Tabs, TabsProps } from 'antd'; +import type { Feature } from '@turf/turf'; +import type { TabsProps } from 'antd'; +import { Select, Tabs } from 'antd'; import React, { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { IconFont } from '../../constants'; @@ -31,6 +32,7 @@ export const MapContent: React.FC = ({ JSON.stringify({ type: 'FeatureCollection', features }, null, 2), ); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [features]); const tabItem = [ diff --git a/src/components/map-control-group/administrative-select-control/index.tsx b/src/components/map-control-group/administrative-select-control/index.tsx index 6abe091e..f614b9e4 100644 --- a/src/components/map-control-group/administrative-select-control/index.tsx +++ b/src/components/map-control-group/administrative-select-control/index.tsx @@ -1,12 +1,9 @@ -import { CustomControl, LineLayer, LineLayerProps } from '@antv/larkmap'; -import { - Feature, - MultiLineString, - featureCollection, - multiLineString, -} from '@turf/turf'; +import type { LineLayerProps } from '@antv/larkmap'; +import { CustomControl, LineLayer } from '@antv/larkmap'; +import type { Feature, MultiLineString } from '@turf/turf'; +import { featureCollection, multiLineString } from '@turf/turf'; import { Cascader, Dropdown, Empty, Tooltip, message } from 'antd'; -import { DefaultOptionType } from 'antd/es/select'; +import type { DefaultOptionType } from 'antd/es/select'; import classNames from 'classnames'; import { cloneDeep } from 'lodash-es'; import React, { useEffect, useMemo, useState } from 'react'; @@ -62,10 +59,11 @@ export const AdministrativeSelect = () => { .then((res) => { setData(getCascadeData(res.districts[0].districts)); }); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const onChange = (value: string[], option: any) => { - setValue(value); + const onChange = (items: string[], option: any) => { + setValue(items); if (option) { const code: string[] = []; const label: string[] = []; @@ -76,10 +74,10 @@ export const AdministrativeSelect = () => { const item = { value: JSON.stringify(code), label: label.join('/') }; const arr = [item, ...cityHistory]; const formatArr = () => { - let map = new Map(); - for (let item of arr) { - if (!map.has(item.value)) { - map.set(item.value, item); + const map = new Map(); + for (const o of arr) { + if (!map.has(o.value)) { + map.set(o.value, o); } } //@ts-ignore @@ -87,7 +85,7 @@ export const AdministrativeSelect = () => { }; setCityHistory(formatArr()); if (cityHistory.length >= 10) { - let arrHistory = cloneDeep(cityHistory); + const arrHistory = cloneDeep(cityHistory); arrHistory.pop(); setCityHistory(arrHistory); } @@ -106,21 +104,21 @@ export const AdministrativeSelect = () => { const historyItem = useMemo(() => { if (cityHistory.length) { - const data = cityHistory.map((item) => { + const item = cityHistory.map((city) => { return { - key: item.value, + key: city.value, label: (
{ - setValue(JSON.parse(item.value)); + setValue(JSON.parse(city.value)); }} > - {item.label} + {city.label}
), }; }); - return data; + return item; } else { return [{ key: 'undefined', label: }]; } @@ -128,8 +126,7 @@ export const AdministrativeSelect = () => { useEffect(() => { if (value) { - const data = value[value.length - 1]; - const name = data; + const name = value[value.length - 1]; fetch( `https://restapi.amap.com/v3/config/district?keywords=${name}&subdistrict=0&key=98d10f05a2da96697313a2ce35ebf1a2&extensions=all`, ) @@ -160,7 +157,9 @@ export const AdministrativeSelect = () => { ); }); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [value]); + return ( <> @@ -169,6 +168,7 @@ export const AdministrativeSelect = () => { { scene.removeControl(newDrawControl); } }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [scene, layerColor]); const onDrawAdd = useCallback( @@ -129,6 +130,7 @@ const DrawControl = () => { draw?.off(DrawEvent.Edit, onDrawAddMap[drawType].onEdit); }); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [drawControl, onDrawAdd]); useEffect(() => { diff --git a/src/components/map-control-group/filter-form-list-control/index.tsx b/src/components/map-control-group/filter-form-list-control/index.tsx index 4e4b616e..ac463962 100644 --- a/src/components/map-control-group/filter-form-list-control/index.tsx +++ b/src/components/map-control-group/filter-form-list-control/index.tsx @@ -97,7 +97,7 @@ const FilterControl: React.FC = () => { <> {fields.map(({ name }, index) => (
diff --git a/src/components/map-control-group/filter-form-list-control/numberFilter.tsx b/src/components/map-control-group/filter-form-list-control/numberFilter.tsx index e14b7510..9542df38 100644 --- a/src/components/map-control-group/filter-form-list-control/numberFilter.tsx +++ b/src/components/map-control-group/filter-form-list-control/numberFilter.tsx @@ -1,9 +1,10 @@ -import { Form, FormInstance, InputNumber, Select } from 'antd'; +import type { FormInstance } from 'antd'; +import { Form, InputNumber, Select } from 'antd'; import { cloneDeep } from 'lodash-es'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { useFeature, useFilter } from '../../../recoil'; -import { FilterNumberData } from '../../../types'; +import type { FilterNumberData } from '../../../types'; interface Props { name: number; diff --git a/src/components/map-control-group/filter-form-list-control/stringFilter.tsx b/src/components/map-control-group/filter-form-list-control/stringFilter.tsx index 60a5e624..65516e9e 100644 --- a/src/components/map-control-group/filter-form-list-control/stringFilter.tsx +++ b/src/components/map-control-group/filter-form-list-control/stringFilter.tsx @@ -1,10 +1,11 @@ -import { Form, FormInstance, Input, Select, Tooltip } from 'antd'; +import type { FormInstance } from 'antd'; +import { Form, Input, Select, Tooltip } from 'antd'; import { cloneDeep, uniq } from 'lodash-es'; import React from 'react'; import { useTranslation } from 'react-i18next'; import useFeature from '../../../recoil/feature'; import useFilter from '../../../recoil/filter'; -import { FilterStringData } from '../../../types/filter'; +import type { FilterStringData } from '../../../types/filter'; interface Props { name: number; diff --git a/src/components/map-control-group/filter-form-list-control/styles.ts b/src/components/map-control-group/filter-form-list-control/styles.ts index 6e3900da..fbca4326 100644 --- a/src/components/map-control-group/filter-form-list-control/styles.ts +++ b/src/components/map-control-group/filter-form-list-control/styles.ts @@ -7,8 +7,6 @@ const useStyle = () => { const { colorBgContainer, boxShadow, - colorIcon, - colorText, } = token; return { l7FilterPanel: css` diff --git a/src/components/map-control-group/index.tsx b/src/components/map-control-group/index.tsx index 2af76c64..f4abd5b9 100644 --- a/src/components/map-control-group/index.tsx +++ b/src/components/map-control-group/index.tsx @@ -9,7 +9,7 @@ import { import React, { useEffect, useState } from 'react'; import { OfficeLayerEnum } from '../../constants'; import { useGlobal } from '../../recoil'; -import { MapControlProps } from '../../types/l7editor'; +import type { MapControlProps } from '../../types/l7editor'; import { AdministrativeSelect } from './administrative-select-control'; import { AutoControl } from './auto-control'; import { ClearControl } from './clear-control'; diff --git a/src/components/map-control-group/location-search-control/index.tsx b/src/components/map-control-group/location-search-control/index.tsx index fa2f8d10..63022c1b 100644 --- a/src/components/map-control-group/location-search-control/index.tsx +++ b/src/components/map-control-group/location-search-control/index.tsx @@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next'; import { useFeature, useGlobal } from '../../../recoil'; import { getPointImage } from '../../../utils/change-image-color'; import { LocationSearch } from './location-search'; -import { LocationSearchOption } from './types'; +import type { LocationSearchOption } from './types'; const LocationSearchControl: React.FC = React.memo(() => { const scene = useScene(); 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 c5edbe9e..96b036ab 100644 --- a/src/components/map-control-group/official-layer-control/index.tsx +++ b/src/components/map-control-group/official-layer-control/index.tsx @@ -15,7 +15,7 @@ export function OfficialLayerControl() { const scene = useScene(); const styles = useStyle(); const style = useStyles(); - const { layerType, setLayerType, baseMap } = useGlobal(); + const { layerType, setLayerType } = useGlobal(); const { t } = useTranslation(); const officeLayerGroup = useMemo(() => { @@ -62,7 +62,7 @@ export function OfficialLayerControl() { ], }, ]; - }, [baseMap, t]); + }, [t]); const amapLayerInstanceRef = useRef( scene.getType() !== 'mapbox' @@ -106,6 +106,7 @@ export function OfficialLayerControl() { } } catch {} } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [layerType, scene]); const officialLayerList = useMemo(() => { diff --git a/src/components/map-control-group/official-layer-control/styles.ts b/src/components/map-control-group/official-layer-control/styles.ts index a0ffe3ab..c32fe81f 100644 --- a/src/components/map-control-group/official-layer-control/styles.ts +++ b/src/components/map-control-group/official-layer-control/styles.ts @@ -1,11 +1,6 @@ import { css } from '@emotion/css'; -import { theme } from 'antd'; const useStyle = () => { - const { useToken } = theme; - const { token } = useToken(); - - const { colorIcon, colorBgContainer, colorText, boxShadow } = token; return { amapInfo: css` margin-top: 10px; diff --git a/src/components/map-control-group/sam-control/index.tsx b/src/components/map-control-group/sam-control/index.tsx index 090a2da1..965ebde2 100644 --- a/src/components/map-control-group/sam-control/index.tsx +++ b/src/components/map-control-group/sam-control/index.tsx @@ -94,7 +94,7 @@ export const SamControl = () => { } } }, - [bound, samModel, revertCoord, features, t], + [bound, samModel, revertCoord, resetFeatures, features, t], ); // 生成 embedding 并初始化载入模型 @@ -216,12 +216,14 @@ export const SamControl = () => { return () => { polygonLayer?.off('unclick', onMapClick); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [samOpen, scene, onMapClick]); useEffect(() => { if (samOpen && samModel) { generateEmbedding(); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [samOpen, samModel]); return ( diff --git a/src/components/map-control-group/save-map-options-control/index.tsx b/src/components/map-control-group/save-map-options-control/index.tsx index 2c6595c5..f7724cd2 100644 --- a/src/components/map-control-group/save-map-options-control/index.tsx +++ b/src/components/map-control-group/save-map-options-control/index.tsx @@ -35,7 +35,7 @@ const SaveMapOptionsControl: React.FC = () => { onClick={onSave} type="button" > - + diff --git a/src/components/resize-panel/index.tsx b/src/components/resize-panel/index.tsx index 5e84204a..5d24dc51 100644 --- a/src/components/resize-panel/index.tsx +++ b/src/components/resize-panel/index.tsx @@ -1,9 +1,10 @@ import { CaretRightOutlined } from '@ant-design/icons'; -import { Feature } from '@turf/turf'; +import type { Feature } from '@turf/turf'; import { useSize } from 'ahooks'; import classNames from 'classnames'; import { Resizable } from 're-resizable'; -import React, { ReactNode, useEffect, useMemo, useState } from 'react'; +import type { ReactNode} from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; import { RightPanelWidthRange } from '../../constants'; import { useFeature, useGlobal } from '../../recoil'; import useStyle from './styles'; @@ -28,17 +29,17 @@ export const ResizePanel: React.FC = ({ const styles = useStyle(); const onResize = (event: Event) => { - const { left = 0 } = resizePanel?.getBoundingClientRect() ?? {}; + const { left: leftWidth = 0 } = resizePanel?.getBoundingClientRect() ?? {}; - let rightPanelWidth = - 100 * (1 - ((event as MouseEvent).clientX - left) / containerWidth); - if (rightPanelWidth < minRightWidth) { - rightPanelWidth = minRightWidth; + let newRightPanelWidth = + 100 * (1 - ((event as MouseEvent).clientX - leftWidth) / containerWidth); + if (newRightPanelWidth < minRightWidth) { + newRightPanelWidth = minRightWidth; } - if (rightPanelWidth > maxRightWidth) { - rightPanelWidth = maxRightWidth; + if (newRightPanelWidth > maxRightWidth) { + newRightPanelWidth = maxRightWidth; } - setRightWidth(rightPanelWidth); + setRightWidth(newRightPanelWidth); }; const calcRightWidth = useMemo(() => { @@ -47,6 +48,7 @@ export const ResizePanel: React.FC = ({ useEffect(() => { onFeatureChange(features); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [features]); return ( diff --git a/src/components/resize-panel/styles.ts b/src/components/resize-panel/styles.ts index 74ba5cd6..c0791078 100644 --- a/src/components/resize-panel/styles.ts +++ b/src/components/resize-panel/styles.ts @@ -9,8 +9,6 @@ const useStyle = () => { colorBgContainer, boxShadow, colorBorderSecondary, - colorFillContentHover, - boxShadowSecondary, colorInfoHover, colorIcon, } = token; diff --git a/src/components/text-layer/index.tsx b/src/components/text-layer/index.tsx index df7071d0..7d77fd64 100644 --- a/src/components/text-layer/index.tsx +++ b/src/components/text-layer/index.tsx @@ -1,4 +1,5 @@ -import { TextLayer, TextLayerProps } from '@antv/larkmap'; +import type { TextLayerProps } from '@antv/larkmap'; +import { TextLayer } from '@antv/larkmap'; import { center } from '@turf/turf'; import React, { useMemo } from 'react'; import { FeatureKey } from '../../constants'; @@ -8,7 +9,7 @@ import { useFeature, useGlobal } from '../../recoil'; export const EditorTextLayer = () => { const { transformCoord } = useFeature(); const { features: newFeatures } = useFilterFeatures(); - const { coordConvert, layerColor } = useGlobal(); + const { layerColor } = useGlobal(); const layerOptions: Omit = useMemo(() => { return { @@ -35,7 +36,7 @@ export const EditorTextLayer = () => { featureIndex: item.properties?.[FeatureKey.Index], }; }); - const data = transformData.map((item, index) => { + const data = transformData.map((item) => { return { //@ts-ignore x: item.data.geometry.coordinates[0], @@ -45,7 +46,8 @@ export const EditorTextLayer = () => { }; }); return data; - }, [newFeatures, coordConvert]); + }, [transformCoord, newFeatures]); + return ( { if (result !== input) { setInput(result); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [fc, isFocus]); const { run: onInputChange } = useDebounceFn( diff --git a/src/hooks/use-filter-features.ts b/src/hooks/use-filter-features.ts index c19692b0..79cc1d16 100644 --- a/src/hooks/use-filter-features.ts +++ b/src/hooks/use-filter-features.ts @@ -1,9 +1,9 @@ -import { Feature } from '@turf/turf'; +import type { Feature } from '@turf/turf'; import { isEmpty, isUndefined } from 'lodash-es'; import { useEffect } from 'react'; import { atom, useRecoilValue, useSetRecoilState } from 'recoil'; import { useFeature, useFilter } from '../recoil'; -import { FilterNode } from './../types/filter'; +import type { FilterNode } from './../types/filter'; export function isEmptyFilter(filter: FilterNode) { const { operator, value, type, field } = filter; diff --git a/src/locales/index.ts b/src/locales/index.ts index 647edb14..54b6c3e4 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -7,6 +7,7 @@ import { initReactI18next } from 'react-i18next'; import enUS from './langs/en-US'; import zhCN from './langs/zh-CN'; +// eslint-disable-next-line import/no-named-as-default-member i18n // 检测用户当前使用的语言 // 文档: https://github.com/i18next/i18next-browser-languageDetector diff --git a/src/pages/components/editor.tsx b/src/pages/components/editor.tsx index 6d72a1dd..843e10ae 100644 --- a/src/pages/components/editor.tsx +++ b/src/pages/components/editor.tsx @@ -32,10 +32,12 @@ export const Editor: React.FC = (props) => { } else { setMapOptions({ ...mapOptions, style: 'light' }); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [theme]); useEffect(() => { i18n.changeLanguage(locale); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const antdLocale = useMemo( diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 039130eb..415e3bda 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,7 +1,8 @@ import { Result } from 'antd'; import React, { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; -import { MutableSnapshot, RecoilEnv, RecoilRoot } from 'recoil'; +import type { MutableSnapshot } from 'recoil'; +import { RecoilEnv, RecoilRoot } from 'recoil'; import { PrimaryColor } from '../constants'; import '../locales/index'; import { diff --git a/src/recoil/atomState.ts b/src/recoil/atomState.ts index d06bf32f..7a1aa026 100644 --- a/src/recoil/atomState.ts +++ b/src/recoil/atomState.ts @@ -1,9 +1,9 @@ -import { Scene } from '@antv/l7'; -import { LarkMapProps } from '@antv/larkmap'; +import type { Scene } from '@antv/l7'; +import type { LarkMapProps } from '@antv/larkmap'; import { atom, DefaultValue } from 'recoil'; import { LocalStorageKey } from '../constants'; -import { IFeatures, LngLatImportType } from '../types'; -import { FilterNode } from '../types/filter'; +import type { IFeatures, LngLatImportType } from '../types'; +import type { FilterNode } from '../types/filter'; const localStorageEffect = (key: string) => diff --git a/src/recoil/feature.ts b/src/recoil/feature.ts index 79162a20..890dbd3f 100644 --- a/src/recoil/feature.ts +++ b/src/recoil/feature.ts @@ -1,11 +1,12 @@ -import { bbox, Feature, featureCollection, getType } from '@turf/turf'; +import type { Feature } from '@turf/turf'; +import { bbox, featureCollection, getType } from '@turf/turf'; import { message } from 'antd'; import { cloneDeep, flatMap, max, min } from 'lodash-es'; import { useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useRecoilState } from 'recoil'; import { FeatureKey } from '../constants'; -import { FilterField, IFeatures } from '../types'; +import type { FilterField, IFeatures } from '../types'; import { gcj02towgs84, transformFeatures, wgs84togcj02 } from '../utils'; import { prettierText } from '../utils/prettier-text'; import { @@ -123,19 +124,22 @@ export default function useFeature() { return featureKeyList; }, [features]); - const transformCoord = (newFeatures: Feature[]) => { - let data = [...newFeatures]; - if (coordConvert === 'WGS84' && baseMap === 'Gaode') { - data = data.map((item) => { - return wgs84togcj02(cloneDeep(item)); - }); - } else if (coordConvert === 'GCJ02' && baseMap === 'Mapbox') { - data = data.map((item) => { - return gcj02towgs84(cloneDeep(item)); - }); - } - return data; - }; + const transformCoord = useCallback( + (newFeatures: Feature[]) => { + let data = [...newFeatures]; + if (coordConvert === 'WGS84' && baseMap === 'Gaode') { + data = data.map((item) => { + return wgs84togcj02(cloneDeep(item)); + }); + } else if (coordConvert === 'GCJ02' && baseMap === 'Mapbox') { + data = data.map((item) => { + return gcj02towgs84(cloneDeep(item)); + }); + } + return data; + }, + [baseMap, coordConvert], + ); const revertCoord = useCallback( (newFeatures: Feature[]) => { diff --git a/src/recoil/lnglat.ts b/src/recoil/lnglat.ts index 2c295d64..5913c3e3 100644 --- a/src/recoil/lnglat.ts +++ b/src/recoil/lnglat.ts @@ -1,4 +1,5 @@ -import { Feature, lineString, point, polygon, Position } from '@turf/turf'; +import type { Feature, Position } from '@turf/turf'; +import { lineString, point, polygon } from '@turf/turf'; import { first, isEqual, last } from 'lodash-es'; import { useTranslation } from 'react-i18next'; import { useRecoilState } from 'recoil'; @@ -19,12 +20,12 @@ export default function useLnglat() { .map((item) => item .split(';') - .filter((item) => item) - .map((item) => - item + .filter((str) => str) + .map((str) => + str .split(',') - .filter((item) => item) - .map((item) => +item), + .filter((num) => num) + .map((num) => +num), ), ); diff --git a/src/types/filter.ts b/src/types/filter.ts index de1ac4cc..0e2ff772 100644 --- a/src/types/filter.ts +++ b/src/types/filter.ts @@ -1,5 +1,5 @@ -import { FeatureKey } from '../constants'; -import { Feature, Geometry, GeometryCollection } from '@turf/turf'; +import type { Feature, Geometry, GeometryCollection } from '@turf/turf'; +import type { FeatureKey } from '../constants'; /** 筛选器基础类型 */ type FilterBase = { @@ -14,15 +14,15 @@ type FilterString = FilterBase & { type: 'string'; } & ( | { - // 精准匹配 - operator: 'IN' | 'NOT_IN'; - value: string[]; - } + // 精准匹配 + operator: 'IN' | 'NOT_IN'; + value: string[]; + } | { - // 模糊匹配 - operator: 'LIKE' | 'NOT_LIKE'; - value: string; - } + // 模糊匹配 + operator: 'LIKE' | 'NOT_LIKE'; + value: string; + } ); /** 数值型筛选器 */ @@ -30,15 +30,15 @@ type FilterNumber = FilterBase & { type: 'number'; } & ( | { - // 大于 | 大于等于 | 等于 | 小于等于 | 小于 - operator: '>' | '>=' | '=' | '<=' | '<'; - value: number; - } + // 大于 | 大于等于 | 等于 | 小于等于 | 小于 + operator: '>' | '>=' | '=' | '<=' | '<'; + value: number; + } | { - // 在范围内 - operator: 'BETWEEN'; - value: [number, number]; - } + // 在范围内 + operator: 'BETWEEN'; + value: [number, number]; + } ); type BaseFilterField = { @@ -46,7 +46,6 @@ type BaseFilterField = { field: string; }; - type FilterNumberData = BaseFilterField & { min?: number; max?: number; @@ -61,7 +60,6 @@ type FilterField = FilterStringData | FilterNumberData; /** 筛选器子节点,单个筛选条件 */ type FilterNode = FilterString | FilterNumber; - type LngLatImportType = 'Point' | 'LingString' | 'Polygon'; type IFeatures = Feature< @@ -72,4 +70,11 @@ type IFeatures = Feature< } >[]; -export { FilterNumberData, FilterField, FilterNode, LngLatImportType, IFeatures, FilterStringData } \ No newline at end of file +export { + FilterField, + FilterNode, + FilterNumberData, + FilterStringData, + IFeatures, + LngLatImportType, +}; diff --git a/src/types/l7editor.ts b/src/types/l7editor.ts index 017a3d3f..9631cb99 100644 --- a/src/types/l7editor.ts +++ b/src/types/l7editor.ts @@ -1,6 +1,6 @@ -import { LarkMapProps } from '@antv/larkmap'; -import { Feature } from '@turf/turf'; -import { TabsProps } from 'antd'; +import type { LarkMapProps } from '@antv/larkmap'; +import type { Feature } from '@turf/turf'; +import type { TabsProps } from 'antd'; export interface MapControlProps { logoControl?: boolean; diff --git a/src/utils/file-to-source.ts b/src/utils/file-to-source.ts index 501f44f3..a8dcfb99 100644 --- a/src/utils/file-to-source.ts +++ b/src/utils/file-to-source.ts @@ -1,12 +1,12 @@ -import { FeatureCollectionVT } from '../constants'; // @ts-ignore import togeojson from '@mapbox/togeojson'; // @ts-ignore import { uniqueId } from 'lodash-es'; -import { Wkt2GeoJSON } from './wkt'; //@ts-ignore import papaparse from 'papaparse'; import { read as XLSX_read, utils as XLSX_utils } from 'xlsx'; +import { FeatureCollectionVT } from '../constants'; +import { Wkt2GeoJSON } from './wkt'; export const readFileAsText = (file: File) => { return new Promise((resolve, reject) => { @@ -27,9 +27,9 @@ export const readFileAsText = (file: File) => { /* 解析 geojson 文件数据至数据集格式 */ export const parserGeoJson = (content: string, name: string, id?: string) => { - let originData: GeoJSON.FeatureCollection; - - originData = JSON.parse(content) as GeoJSON.FeatureCollection; + const originData: GeoJSON.FeatureCollection = JSON.parse( + content, + ) as GeoJSON.FeatureCollection; return { id: id || uniqueId(id), @@ -47,9 +47,7 @@ export const parserJsonToGeoJson = ( name: string, id?: string, ) => { - let data: Record[]; - - data = JSON.parse(content); + const data: Record[] = JSON.parse(content); // 兼容 geojson 文件 if (FeatureCollectionVT.check(data)) { @@ -75,8 +73,7 @@ export const parserTextFileToSource = async ( const fileExtension = fileFullName.substring( fileFullName.lastIndexOf('.') + 1, ); - let content: string; - content = await readFileAsText(file); + const content = await readFileAsText(file); if (fileExtension === 'json') { return parserJsonToGeoJson(content, name, id); @@ -109,8 +106,7 @@ export const csv2json = async ( name: string, id?: string, ): Promise => { - let content: string; - content = await readFileAsText(file); + const content = await readFileAsText(file); const result = papaparse.parse(content, { header: true, diff --git a/src/utils/gcoord.ts b/src/utils/gcoord.ts index 72a17e62..e3698247 100644 --- a/src/utils/gcoord.ts +++ b/src/utils/gcoord.ts @@ -1,4 +1,4 @@ -import { Feature } from '@turf/turf'; +import type { Feature } from '@turf/turf'; import gcoord from 'gcoord'; export const wgs84togcj02 = (feature: Feature) => { diff --git a/src/utils/index.ts b/src/utils/index.ts index 157b824a..65ae27ce 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,12 +1,13 @@ import { getSingleColorStyle } from '@antv/l7-draw'; -import { FeatureCollectionVT, FeatureKey, LayerZIndex } from '../constants'; //@ts-ignore import togeojson from '@mapbox/togeojson'; -import { bearing, center, coordAll, distance, Feature } from '@turf/turf'; +import type { Feature } from '@turf/turf'; +import { bearing, center, coordAll, distance } from '@turf/turf'; import { message } from 'antd'; import Color from 'color'; import dayjs from 'dayjs'; import { isUndefined } from 'lodash-es'; +import { FeatureCollectionVT, FeatureKey, LayerZIndex } from '../constants'; // @ts-ignore import { Wkt2GeoJSON } from './wkt'; diff --git a/src/utils/lnglat.ts b/src/utils/lnglat.ts index c0281cbb..8afff164 100644 --- a/src/utils/lnglat.ts +++ b/src/utils/lnglat.ts @@ -1,10 +1,5 @@ -import { - Feature, - FeatureCollection, - Position, - coordAll, - point, -} from '@turf/turf'; +import type { Feature, FeatureCollection, Position } from '@turf/turf'; +import { coordAll, point } from '@turf/turf'; import { LngLatVT } from '../constants'; export function GeoJSON2LngLat(fc: FeatureCollection) { @@ -22,12 +17,12 @@ export function LngLat2GeoJson(lngLat: string) { .map((item) => item .split(';') - .filter((item) => item) - .map((item) => - item + .filter((str) => str) + .map((str) => + str .split(',') - .filter((item) => item) - .map((item) => +item), + .filter((num) => num) + .map((num) => +num), ), ); if (LngLatVT.check(featurePositionList)) { diff --git a/src/utils/transform.ts b/src/utils/transform.ts index 580a4d77..acf9c765 100644 --- a/src/utils/transform.ts +++ b/src/utils/transform.ts @@ -1,4 +1,5 @@ -import { Feature, feature } from '@turf/turf'; +import type { Feature } from '@turf/turf'; +import { feature } from '@turf/turf'; import { FeatureCollectionVT, FeatureListVT,