diff --git a/app.vue b/app.vue index 988daa2..255c764 100644 --- a/app.vue +++ b/app.vue @@ -46,6 +46,20 @@ onMounted(async () => { console.warn(e); } + // 天気の各設定コードを取得 + const wideRegion = localStorage.getItem('weatherWideRegion'); + if (wideRegion != null) { + weatherWideRegionNumber().value = wideRegion; + } + const officeNumber = localStorage.getItem('weatherOfficeNumber'); + if (officeNumber != null) { + weatherOfficeNumber().value = officeNumber; + } + const areaNumber = localStorage.getItem('weatherAreaNumber'); + if (areaNumber != null) { + weatherAreaNumber().value = areaNumber; + } + // OPFSからチャイム音源とアラート音源を読み込む const opfsRoot = await navigator.storage.getDirectory(); diff --git a/components/settings.vue b/components/settings.vue index fd7543a..7c48b95 100644 --- a/components/settings.vue +++ b/components/settings.vue @@ -162,6 +162,8 @@ onMounted(() => { + +

diff --git a/components/status.vue b/components/status.vue index a342f4c..1d5d0e0 100644 --- a/components/status.vue +++ b/components/status.vue @@ -120,18 +120,37 @@ async function refleshStatus() { sensorInterval?.resume(); } -// 10分ごとに天気を更新 -async function refleshWeather() { - const djs = dayjs(); +// クライアントサイドのみで実行 +onMounted(async () => { + // 2秒ごとに温度を更新 (1秒だとシリアル通信が追いつかない? + await refleshStatus(); + sensorInterval = useIntervalFn(refleshStatus, 2000); + + // 10分ごとに天気を更新 + await refleshWeather(); + useIntervalFn(refleshWeather, 10000); +}); + + +