From 3f9584aef5e0afaa01855bcf3d0b7bb0844915e0 Mon Sep 17 00:00:00 2001 From: orionna319 <85230052+orionna319@users.noreply.github.com> Date: Mon, 27 Nov 2023 11:32:41 +0800 Subject: [PATCH 1/6] perf: split `activities.json` from index (#552) --- vite.config.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index d6cd323b83a..11908d05f30 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -11,5 +11,14 @@ export default defineConfig({ build: { manifest: true, outDir: './dist', // for user easy to use, vercel use default dir -> dist + rollupOptions: { + output: { + manualChunks: (id: string) => { + if (id.includes('activities')) { + return 'activities' + } + }, + } + }, }, }); From b63aa7d52c0823ba6a3c2fe963bc34e536c32341 Mon Sep 17 00:00:00 2001 From: conanyangqun Date: Sat, 2 Dec 2023 22:26:37 +0800 Subject: [PATCH 2/6] fix a bug in track.py. (#559) --- run_page/gpxtrackposter/track.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run_page/gpxtrackposter/track.py b/run_page/gpxtrackposter/track.py index 3eac70c52bd..3172db26a1c 100644 --- a/run_page/gpxtrackposter/track.py +++ b/run_page/gpxtrackposter/track.py @@ -109,8 +109,10 @@ def load_from_db(self, activity): self.start_time_local = start_time self.end_time = start_time + activity.elapsed_time self.length = float(activity.distance) - if not IGNORE_BEFORE_SAVING: + if IGNORE_BEFORE_SAVING: summary_polyline = filter_out(activity.summary_polyline) + else: + summary_polyline = activity.summary_polyline polyline_data = polyline.decode(summary_polyline) if summary_polyline else [] self.polylines = [[s2.LatLng.from_degrees(p[0], p[1]) for p in polyline_data]] self.run_id = activity.run_id From 71705f01849583ea6be89dae5213c697741acb6c Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Fri, 8 Dec 2023 19:00:21 +0800 Subject: [PATCH 3/6] fix: #566 --- Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 99024c32f25..fc1db81cb7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,8 +24,7 @@ RUN npm config set registry https://registry.npm.taobao.org \ FROM develop-py AS data ARG app ARG nike_refresh_token -ARG email -ARG password +ARG secret_string ARG client_id ARG client_secret ARG refresh_token @@ -39,9 +38,9 @@ RUN DUMMY=${DUMMY}; \ if [ "$app" = "NRC" ] ; then \ python3 run_page/nike_sync.py ${nike_refresh_token}; \ elif [ "$app" = "Garmin" ] ; then \ - python3 run_page/garmin_sync.py ${email} ${password}; \ + python3 run_page/garmin_sync.py ${secret_string} ; \ elif [ "$app" = "Garmin-CN" ] ; then \ - python3 run_page/garmin_sync.py ${email} ${password} --is-cn ; \ + python3 run_page/garmin_sync.py ${secret_string} --is-cn ; \ elif [ "$app" = "Strava" ] ; then \ python3 run_page/strava_sync.py ${client_id} ${client_secret} ${refresh_token};\ elif [ "$app" = "Nike_to_Strava" ] ; then \ From 1146208228a3392b30619d3d1a30dc90a988177c Mon Sep 17 00:00:00 2001 From: ben_29 Date: Sun, 10 Dec 2023 16:32:51 +0800 Subject: [PATCH 4/6] feat: Lights on and off --- src/components/RunMap/LightsControl.tsx | 21 ++++++++++++ src/components/RunMap/index.tsx | 45 ++++++++++++++++++------- src/components/RunMap/style.module.scss | 28 +++++++++++++++ 3 files changed, 81 insertions(+), 13 deletions(-) create mode 100644 src/components/RunMap/LightsControl.tsx diff --git a/src/components/RunMap/LightsControl.tsx b/src/components/RunMap/LightsControl.tsx new file mode 100644 index 00000000000..b37360664cb --- /dev/null +++ b/src/components/RunMap/LightsControl.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import styles from './style.module.scss'; + +interface ILightsProps { + setLights: (_lights: boolean) => void; + lights: boolean; +} + +const LightsControl = ({ setLights, lights }: ILightsProps) => { + + return ( +
+ +
+ ); +}; + +export default LightsControl; diff --git a/src/components/RunMap/index.tsx b/src/components/RunMap/index.tsx index 8164d1c0d77..3a5e199109a 100644 --- a/src/components/RunMap/index.tsx +++ b/src/components/RunMap/index.tsx @@ -1,6 +1,6 @@ import MapboxLanguage from '@mapbox/mapbox-gl-language'; -import React, { useRef, useCallback } from 'react'; -import Map, { Layer, Source, FullscreenControl, NavigationControl, MapRef } from 'react-map-gl'; +import React, {useRef, useCallback, useState} from 'react'; +import Map, {Layer, Source, FullscreenControl, NavigationControl, MapRef} from 'react-map-gl'; import useActivities from '@/hooks/useActivities'; import { MAP_LAYER_LIST, @@ -20,6 +20,7 @@ import styles from './style.module.scss'; import { FeatureCollection } from 'geojson'; import { RPGeometry } from '@/static/run_countries'; import './mapbox.css'; +import LightsControl from "@/components/RunMap/LightsControl"; interface IRunMapProps { title: string; @@ -40,25 +41,42 @@ const RunMap = ({ }: IRunMapProps) => { const { provinces } = useActivities(); const mapRef = useRef(); + const [lights, setLights] = useState(true); const mapRefCallback = useCallback( (ref: MapRef) => { if (ref !== null) { - mapRef.current = ref; const map = ref.getMap(); - if (map && IS_CHINESE) { - map.addControl(new MapboxLanguage({ defaultLanguage: 'zh-Hans' })); - if (!ROAD_LABEL_DISPLAY) { - // todo delete layers - map.on('load', () => { + if (map) { + map.addControl(new MapboxLanguage({defaultLanguage: 'zh-Hans'})); + } + map.on('load', () => { + if (!ROAD_LABEL_DISPLAY) { + // todo delete layers MAP_LAYER_LIST.forEach((layerId) => { map.removeLayer(layerId); }); - }); - } + } + mapRef.current = ref; + }); + } + if (mapRef.current) { + const map = mapRef.current.getMap(); + if (map) { + const styleJson = map.getStyle(); + const keepWhenLightsOff = ['runs2'] + styleJson.layers.forEach(it => { + if (!keepWhenLightsOff.includes(it.id)) { + if (lights) + map.setLayoutProperty(it.id, 'visibility', 'visible'); + else + map.setLayoutProperty(it.id, 'visibility', 'none'); + } + } + ) } } }, - [mapRef] + [mapRef, lights] ); const filterProvinces = provinces.slice(); // for geojson format @@ -140,8 +158,9 @@ const RunMap = ({ /> )} {title} - - + + + ); }; diff --git a/src/components/RunMap/style.module.scss b/src/components/RunMap/style.module.scss index c2cc83c7f82..f58c27bc9bd 100644 --- a/src/components/RunMap/style.module.scss +++ b/src/components/RunMap/style.module.scss @@ -41,3 +41,31 @@ font-family: $global-font-family; cursor: pointer; } + +.lights { + position: absolute; + margin-top: 62px; + right: 20px; + opacity: 0.3; + width: 29px; + height: 38px; +} + + +.lightsOn { + height: 38px !important; + background-image: url("data:image/svg+xml,