mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
Compare commits
No commits in common. "fc6c367f97daf59b555cc1e8eda35f5a6e214571" and "6a0367c1928354acaa1f7c0f99995a6dda01c540" have entirely different histories.
fc6c367f97
...
6a0367c192
@ -29,6 +29,7 @@ export default async function ServerGlobal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function Global({ countries = [] }: GlobalProps) {
|
export async function Global({ countries = [] }: GlobalProps) {
|
||||||
|
// const t = useTranslations("Global");
|
||||||
const map = new DottedMap({ map: JSON.parse(mapJsonString) });
|
const map = new DottedMap({ map: JSON.parse(mapJsonString) });
|
||||||
|
|
||||||
const countries_alpha3 = countries
|
const countries_alpha3 = countries
|
||||||
@ -43,42 +44,6 @@ export async function Global({ countries = [] }: GlobalProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (feature) {
|
if (feature) {
|
||||||
if (countryCode === "RUS") {
|
|
||||||
// 获取俄罗斯的多个边界
|
|
||||||
const bboxList = feature.geometry.coordinates.map((polygon: any) =>
|
|
||||||
turf.bbox({ type: "Polygon", coordinates: polygon }),
|
|
||||||
);
|
|
||||||
|
|
||||||
const spacing = 20; // 单位为千米
|
|
||||||
const options = { units: "kilometers" };
|
|
||||||
|
|
||||||
bboxList.forEach((bbox: any) => {
|
|
||||||
// @ts-expect-error ignore
|
|
||||||
const pointGrid = turf.pointGrid(bbox, spacing, options);
|
|
||||||
|
|
||||||
// 过滤出位于当前多边形内部的点
|
|
||||||
const pointsWithin = turf.pointsWithinPolygon(pointGrid, feature);
|
|
||||||
|
|
||||||
if (pointsWithin.features.length === 0) {
|
|
||||||
const centroid = turf.centroid(feature);
|
|
||||||
const [lng, lat] = centroid.geometry.coordinates;
|
|
||||||
map.addPin({
|
|
||||||
lat,
|
|
||||||
lng,
|
|
||||||
svgOptions: { color: "#FF4500", radius: 0.3 },
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
pointsWithin.features.forEach((point: any) => {
|
|
||||||
const [lng, lat] = point.geometry.coordinates;
|
|
||||||
map.addPin({
|
|
||||||
lat,
|
|
||||||
lng,
|
|
||||||
svgOptions: { color: "#FF4500", radius: 0.3 },
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// 获取国家的边界框
|
// 获取国家的边界框
|
||||||
const bbox = turf.bbox(feature);
|
const bbox = turf.bbox(feature);
|
||||||
|
|
||||||
|
183
lib/dev-geo.ts
183
lib/dev-geo.ts
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nezha-dash",
|
"name": "nezha-dash",
|
||||||
"version": "1.4.5",
|
"version": "1.4.4-fix",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 3040",
|
"dev": "next dev -p 3040",
|
||||||
@ -25,7 +25,7 @@
|
|||||||
"@turf/turf": "^7.1.0",
|
"@turf/turf": "^7.1.0",
|
||||||
"@types/luxon": "^3.4.2",
|
"@types/luxon": "^3.4.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
||||||
"caniuse-lite": "^1.0.30001683",
|
"caniuse-lite": "^1.0.30001680",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"country-flag-icons": "^1.5.13",
|
"country-flag-icons": "^1.5.13",
|
||||||
|
Loading…
Reference in New Issue
Block a user