From 0831097bc1615cca4f6ed3d4616960364347a5a2 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 27 Oct 2024 17:04:53 +0900 Subject: [PATCH 1/5] =?UTF-8?q?Fix:=20=E3=83=80=E3=82=A6=E3=83=B3=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=83=80=E3=82=A4=E3=82=A2=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=81=AEOS=E5=A4=89=E6=9B=B4=E6=99=82=E3=81=AE=E6=8C=99?= =?UTF-8?q?=E5=8B=95=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/downloadModal.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/downloadModal.tsx b/src/components/downloadModal.tsx index eca64bbd..9dd516b8 100644 --- a/src/components/downloadModal.tsx +++ b/src/components/downloadModal.tsx @@ -13,10 +13,7 @@ const modeAvailables: Record = { Linux: ["GPU / CPU", "CPU"], } -const packageAvailables: Record< - OsType, - Partial> -> = { +const packageAvailables = { Windows: { "GPU / CPU": ["インストーラー", "Zip"], CPU: ["インストーラー", "Zip"], @@ -26,7 +23,7 @@ const packageAvailables: Record< "CPU (Apple)": ["インストーラー", "Zip"], }, Linux: { "GPU / CPU": ["インストーラー"], CPU: ["インストーラー", "tar.gz"] }, -} +} as const satisfies Record>> export const DownloadModal: React.FC<{ isActive: boolean @@ -136,6 +133,12 @@ export const DownloadModal: React.FC<{ ? selectedPackage : packageAvailables[selectedOs][selectedOrDefaultMode]![0] + const onSelectedOsChange = (os: OsType) => { + setSelectedOs(os) + setSelectedMode(modeAvailables[os][0]) + setSelectedPackage(packageAvailables[os][modeAvailables[os][0]][0]) + } + return (
From 036369198c7fe4ff7fa78be45af2a23ed784d177 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 27 Oct 2024 17:59:51 +0900 Subject: [PATCH 2/5] =?UTF-8?q?Improve:=20=E6=8C=99=E5=8B=95=E3=81=AE?= =?UTF-8?q?=E5=B7=AE=E5=88=86=E3=82=92=E6=9C=80=E5=B0=8F=E9=99=90=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/downloadModal.tsx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/components/downloadModal.tsx b/src/components/downloadModal.tsx index 9dd516b8..76e66296 100644 --- a/src/components/downloadModal.tsx +++ b/src/components/downloadModal.tsx @@ -133,10 +133,21 @@ export const DownloadModal: React.FC<{ ? selectedPackage : packageAvailables[selectedOs][selectedOrDefaultMode]![0] - const onSelectedOsChange = (os: OsType) => { + const selectOs = (os: OsType) => { setSelectedOs(os) - setSelectedMode(modeAvailables[os][0]) - setSelectedPackage(packageAvailables[os][modeAvailables[os][0]][0]) + // 変更先のOSで選択できないモードの場合、最初のモードを選択する + selectMode( + modeAvailables[os].includes(selectedMode) + ? selectedMode + : modeAvailables[os][0], + os + ) + } + const selectMode = (mode: ModeType, os?: OsType) => { + setSelectedMode(mode) + if (!packageAvailables[os ?? selectedOs][mode]!.includes(selectedPackage)) { + setSelectedPackage(packageAvailables[os ?? selectedOs][mode]![0]) + } } return ( @@ -163,7 +174,7 @@ export const DownloadModal: React.FC<{ @@ -172,7 +183,7 @@ export const DownloadModal: React.FC<{

From d6431827ecad985d21bc5a7d4f7cc61133d356f1 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 27 Oct 2024 18:02:20 +0900 Subject: [PATCH 3/5] =?UTF-8?q?Improve:=20=E3=83=87=E3=83=95=E3=82=A9?= =?UTF-8?q?=E3=83=AB=E3=83=88=E3=81=A7OS=E3=82=92=E9=81=B8=E3=82=93?= =?UTF-8?q?=E3=81=A7=E3=81=8A=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/downloadModal.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/downloadModal.tsx b/src/components/downloadModal.tsx index 76e66296..9d3b2c92 100644 --- a/src/components/downloadModal.tsx +++ b/src/components/downloadModal.tsx @@ -1,5 +1,5 @@ import { Link, graphql, useStaticQuery } from "gatsby" -import React, { useState } from "react" +import React, { useEffect, useState } from "react" import { APP_VERSION } from "../constants" import DownloadModalSelecter from "./downloadModalSelecter" @@ -133,6 +133,17 @@ export const DownloadModal: React.FC<{ ? selectedPackage : packageAvailables[selectedOs][selectedOrDefaultMode]![0] + useEffect(() => { + const userAgent = window.navigator.userAgent + if (userAgent.includes("Windows")) { + setSelectedOs("Windows") + } else if (userAgent.includes("Mac")) { + setSelectedOs("Mac") + } else if (userAgent.includes("Linux")) { + setSelectedOs("Linux") + } + }, []) + const selectOs = (os: OsType) => { setSelectedOs(os) // 変更先のOSで選択できないモードの場合、最初のモードを選択する From c552f9a37e0d33855106b4ded2d466a0f98f3f22 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 27 Oct 2024 18:03:40 +0900 Subject: [PATCH 4/5] =?UTF-8?q?Fix:=20selectOs=E3=82=92=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/downloadModal.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/downloadModal.tsx b/src/components/downloadModal.tsx index 9d3b2c92..4890e43b 100644 --- a/src/components/downloadModal.tsx +++ b/src/components/downloadModal.tsx @@ -136,11 +136,11 @@ export const DownloadModal: React.FC<{ useEffect(() => { const userAgent = window.navigator.userAgent if (userAgent.includes("Windows")) { - setSelectedOs("Windows") + selectOs("Windows") } else if (userAgent.includes("Mac")) { - setSelectedOs("Mac") + selectOs("Mac") } else if (userAgent.includes("Linux")) { - setSelectedOs("Linux") + selectOs("Linux") } }, []) From 697507be1001825e924de5c0c326c9aeb60b6199 Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Tue, 29 Oct 2024 00:48:18 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=82=92=E5=BF=85?= =?UTF-8?q?=E9=A0=88=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/downloadModal.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/downloadModal.tsx b/src/components/downloadModal.tsx index 4890e43b..4d203898 100644 --- a/src/components/downloadModal.tsx +++ b/src/components/downloadModal.tsx @@ -148,16 +148,16 @@ export const DownloadModal: React.FC<{ setSelectedOs(os) // 変更先のOSで選択できないモードの場合、最初のモードを選択する selectMode( + os, modeAvailables[os].includes(selectedMode) ? selectedMode - : modeAvailables[os][0], - os + : modeAvailables[os][0] ) } - const selectMode = (mode: ModeType, os?: OsType) => { + const selectMode = (os: OsType, mode: ModeType) => { setSelectedMode(mode) - if (!packageAvailables[os ?? selectedOs][mode]!.includes(selectedPackage)) { - setSelectedPackage(packageAvailables[os ?? selectedOs][mode]![0]) + if (!packageAvailables[os][mode]!.includes(selectedPackage)) { + setSelectedPackage(packageAvailables[os][mode]![0]) } } @@ -194,7 +194,7 @@ export const DownloadModal: React.FC<{ selectMode(selectedOs, mode)} candidates={modeAvailables[selectedOs]} />