diff --git a/zbook_backend/gapi/admin_get_daily_visitors.go b/zbook_backend/gapi/admin_get_daily_visitors.go index 52f1f41..f34e802 100644 --- a/zbook_backend/gapi/admin_get_daily_visitors.go +++ b/zbook_backend/gapi/admin_get_daily_visitors.go @@ -2,6 +2,9 @@ package gapi import ( "context" + + "math/rand" + "net/netip" "sort" @@ -71,13 +74,17 @@ func ConvertVisitor(server *Server, visitors map[string]int, lang string) []*rpc city = record.CityNameEn.String } } + // 在这里添加随机扰动 + latWithNoise := record.Latitude.Float64 + (rand.Float64()*2 - 1) + longWithNoise := record.Longitude.Float64 + (rand.Float64()*2 - 1) + ret_reports = append(ret_reports, &rpcs.Visitor{ Ip: ipStr, City: city, Count: int32(count), - Lat: record.Latitude.Float64, - Long: record.Longitude.Float64, + Lat: latWithNoise, + Long: longWithNoise, }, ) } diff --git a/zbook_frontend/src/components/charts/EarthChart.tsx b/zbook_frontend/src/components/charts/EarthChart.tsx index e18e17f..b3d6c9d 100644 --- a/zbook_frontend/src/components/charts/EarthChart.tsx +++ b/zbook_frontend/src/components/charts/EarthChart.tsx @@ -27,8 +27,8 @@ export default function EarthChart({ }) { markers = markers || []; markers = [ - { ip: "66.249.66.165", lat: 37.751, long: -97.822, count: 13 }, - { ip: "66.249.66.165", lat: 37.751, long: -97.822, count: 13 }, + { ip: "66.249.66.165", lat: 37.751, long: -98.822, count: 13 }, + { ip: "66.249.66.165", lat: 38.751, long: -97.822, count: 13 }, ]; const svgRef = useRef(null); console.log("markers:", markers); @@ -174,7 +174,6 @@ export default function EarthChart({ }); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - return (