From f3a35884d626009d33e05adc76bbc8372498f317 Mon Sep 17 00:00:00 2001 From: ben_29 Date: Sat, 16 Sep 2023 21:35:23 +0800 Subject: [PATCH] add: sport type: Ski --- README-CN.md | 2 +- README.md | 2 +- scripts/config.py | 2 ++ src/utils/const.js | 2 ++ src/utils/utils.js | 9 ++++++--- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README-CN.md b/README-CN.md index 1954aa48836..55a6aa33606 100644 --- a/README-CN.md +++ b/README-CN.md @@ -25,8 +25,8 @@ - 修改 `scripts/config.py`, `TYPE_DICT` 增加类型映射关系, `MAPPING_TYPE` 里增加运动类型 - 修改 `src/utils/const.js`, 增加类型标题,并加入到 `RUN_TITLES` - 修改 `src/utils/util.js` 里的 `colorFromType`, 增加 case 指定颜色; `titleForRun` 增加 case 指定类型标题 - - 参考这个 [commit](https://github.com/ben-29/workouts_page/commit/bfb6e9da4f72bdbdec669c42bdd10062558039cd) +- 或 [留言](https://github.com/ben-29/workouts_page/issues/20) --- ### Codoon(咕咚) diff --git a/README.md b/README.md index 035257d50c4..e8efaf3cc28 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,8 @@ This project is based on [running_page](https://github.com/yihong0618/running_pa - Modify `TYPE_DICT` & `MAPPING_TYPE` in `scripts/config.py` - Add Type Name and add it into `RUN_TITLES` in `src/utils/const.js` - Modify `colorFromType` & `titleForRun` in `src/utils/util.js` - - see [commit](https://github.com/ben-29/workouts_page/commit/bfb6e9da4f72bdbdec669c42bdd10062558039cd) +- or comment [here](https://github.com/ben-29/workouts_page/issues/20) --- diff --git a/scripts/config.py b/scripts/config.py index 7c5f43921c2..c900de82ce6 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -69,6 +69,7 @@ def safeget(dct, *keys): "flight": "Flight", "kayaking": "Kayaking", "Snowboard": "Snowboard", + "Ski": "Ski", } MAPPING_TYPE = [ @@ -81,6 +82,7 @@ def safeget(dct, *keys): "RoadTrip", "Kayaking", "Snowboard", + "Ski", ] STRAVA_GARMIN_TYPE_DICT = { diff --git a/src/utils/const.js b/src/utils/const.js index 42a504ba029..008df29f557 100644 --- a/src/utils/const.js +++ b/src/utils/const.js @@ -60,6 +60,7 @@ const HIKE_TITLE = IS_CHINESE ? '徒步' : 'Hike'; const ROWING_TITLE = IS_CHINESE ? '划船' : 'Rowing'; const KAYAKING_TITLE = IS_CHINESE ? '皮划艇' : 'Kayaking'; const SNOWBOARD_TITLE = IS_CHINESE ? '单板滑雪' : 'Snowboard'; +const SKI_TITLE = IS_CHINESE ? '双板滑雪' : 'Ski'; const ROAD_TRIP_TITLE = IS_CHINESE ? '自驾' : 'RoadTrip'; const FLIGHT_TITLE = IS_CHINESE ? '飞行' : 'Flight'; @@ -78,6 +79,7 @@ const RUN_TITLES = { ROAD_TRIP_TITLE, FLIGHT_TITLE, SNOWBOARD_TITLE, + SKI_TITLE, }; export { diff --git a/src/utils/utils.js b/src/utils/utils.js index 7b8a54f954d..dd7d979fc5d 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -74,11 +74,11 @@ const pattern = /([\u4e00-\u9fa5]{2,}(市|自治州))/g; const extractLocations = (str) => { const locations = []; let match; - + while ((match = pattern.exec(str)) !== null) { locations.push(match[0]); } - + return locations; }; @@ -96,7 +96,7 @@ const locationForRun = (run) => { if (cityMatch) { [city] = cityMatch; city = cities.find(value => cityMatch.includes(value)); - + if (!city) { city = ''; } @@ -194,6 +194,8 @@ const titleForType = (type) => { return RUN_TITLES.KAYAKING_TITLE; case 'Snowboard': return RUN_TITLES.SNOWBOARD_TITLE; + case 'Ski': + return RUN_TITLES.SKI_TITLE; default: return RUN_TITLES.RUN_TITLE; } @@ -235,6 +237,7 @@ const colorFromType = (workoutType) => { case 'Kayaking': return KAYAKING_COLOR; case 'Snowboard': + case 'Ski': return SNOWBOARD_COLOR; default: return MAIN_COLOR;