Skip to content

Commit

Permalink
Improve: デフォルトでOSを選んでおく
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Oct 27, 2024
1 parent 0363691 commit d643182
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/downloadModal.tsx
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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で選択できないモードの場合、最初のモードを選択する
Expand Down

0 comments on commit d643182

Please sign in to comment.