From 28b23efc5e747e170445246631ddc2dd76360fe3 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 5 Jul 2025 07:47:44 +0000 Subject: [PATCH] =?UTF-8?q?=E3=81=8A=E6=B0=97=E3=81=AB=E5=85=A5=E3=82=8A?= =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=88=E3=81=8B=E3=82=89=E3=81=AE=E3=82=B8?= =?UTF-8?q?=E3=83=A3=E3=83=B3=E3=83=97=E3=82=92=E5=85=A8=E3=81=A6=E3=81=AE?= =?UTF-8?q?=E9=A7=85=E3=81=A7=E5=88=A9=E7=94=A8=E5=8F=AF=E8=83=BD=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Apps/WebView.jsx | 44 +++++++++++++++++++++++++++---------- lib/getStationList.ts | 11 ++++++++++ 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/components/Apps/WebView.jsx b/components/Apps/WebView.jsx index 28e19dc..257d189 100644 --- a/components/Apps/WebView.jsx +++ b/components/Apps/WebView.jsx @@ -2,7 +2,13 @@ import React from "react"; import { Platform, LayoutAnimation } from "react-native"; import { WebView } from "react-native-webview"; -import { lineList, stationNamePair } from "../../lib/getStationList"; +import { + lineList, + lineList_LineWebID, + lineListPair, + stationIDPair, + stationNamePair, +} from "../../lib/getStationList"; import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData"; import { useFavoriteStation } from "../../stateBox/useFavoriteStation"; import { useCurrentTrain } from "../../stateBox/useCurrentTrain"; @@ -129,19 +135,35 @@ export const AppsWebView = ({ openStationACFromEachTrainInfo }) => { const onLoadEnd = () => { if (once) return () => {}; if (!stationData) return () => {}; + if (!originalStationList) return () => {}; if (favoriteStation.length < 1) return () => {}; - const getStationLine = (now) => { - const returnData = Object.keys(stationData).filter((d) => { - const cache = stationData[d].findIndex( - (data) => data.Station_JP == now.Station_JP - ); - return cache != -1; + const bootStationList = []; + Object.keys(originalStationList).forEach((d) => { + let findNearStations = false; + originalStationList[d].forEach((x) => { + let lineName = lineList_LineWebID[d]; + if (findNearStations) { + if (x.MyStation){ + bootStationList.push({ line: lineName, station: x }); + findNearStations = false; + } + return; + } + if (x.StationNumber == favoriteStation[0][0].StationNumber) { + console.log(originalStationList[d]); + if (!x.MyStation) findNearStations = true; + else bootStationList.push({ line: lineName, station: x }); + } }); - return returnData[0]; - }; - const lineName = getStationLine(favoriteStation[0][0]); + if (favoriteStation[0].StationNumber == "M12") { + bootStationList.push({ + line: "seto", + station: { Station_JP: "児島", MyStation: "0" }, + }); + } + }); webview.current?.injectJavaScript( - `MoveDisplayStation('${lineName}_${favoriteStation[0][0].MyStation}_${favoriteStation[0][0].Station_JP}')` + `MoveDisplayStation('${bootStationList[0].line}_${bootStationList[0].station.MyStation}_${bootStationList[0].station.Station_JP}')` ); once = true; }; diff --git a/lib/getStationList.ts b/lib/getStationList.ts index 1a851f3..796e893 100644 --- a/lib/getStationList.ts +++ b/lib/getStationList.ts @@ -40,6 +40,17 @@ export const lineListPair = { N: "鳴門線(池谷-鳴門間)[N]", M: "瀬戸大橋線(児島-宇多津間)[M]", }; +export const lineList_LineWebID = { + "予讃線(高松-松山間)[Y]" : "yosan", + "予讃線(松山-宇和島間)[U]" : "uwajima", + "予讃線/愛ある伊予灘線(向井原-伊予大洲間)[S]" : "uwajima2", + "土讃線(多度津-高知間)[D]" : "dosan", + "土讃線(高知-窪川間)[K]" : "dosan2", + "高徳線(高松-徳島間)[T]" : "koutoku", + "徳島線(徳島-阿波池田間)[B]" : "tokushima", + "鳴門線(池谷-鳴門間)[N]" : "naruto", + "瀬戸大橋線(児島-宇多津間)[M]" : "seto", +}; export const getStationList2 = async () => { return { yosan,