diff --git a/src/features/homepage/components/MessagePaper.tsx b/src/features/homepage/components/MessagePaper.tsx index 92514ed..1034fa3 100644 --- a/src/features/homepage/components/MessagePaper.tsx +++ b/src/features/homepage/components/MessagePaper.tsx @@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'; import { Paper, Typography, Stack, Button, Divider } from '@mui/material'; import { useAppStateStore } from '@/store/appStateStore'; -const isElectron = navigator.userAgent.indexOf('Electron') >= 0; +const isElectron = navigator.userAgent.includes('Electron'); export const MessagePaper = () => { const [currentVersion, setCurrentVersion] = useState(''); @@ -24,7 +24,7 @@ export const MessagePaper = () => { // 現在のアプリバージョンを取得 const fetchCurrentVersion = async () => { - // @ts-expect-error ElectronAPI + //@ts-expect-error Electron const version = await window.electron.getAppVersion(); setCurrentVersion(version); }; @@ -72,7 +72,7 @@ export const MessagePaper = () => { return ( - {isWeb && ( + {isWeb && !isElectron && ( <> @@ -96,7 +96,7 @@ export const MessagePaper = () => { )} {isElectron && ( - + ver{currentVersion} @@ -130,7 +130,11 @@ export const MessagePaper = () => { ©{new Date().getFullYear()} Jun Murakami {' '} |{' '} - + GitHub {' '} |{' '} diff --git a/src/features/homepage/hooks/useAuth.ts b/src/features/homepage/hooks/useAuth.ts index 35d5004..fda361e 100644 --- a/src/features/homepage/hooks/useAuth.ts +++ b/src/features/homepage/hooks/useAuth.ts @@ -61,7 +61,7 @@ type UserComact = { email: string | null; }; -const isElectron = navigator.userAgent.indexOf('Electron') >= 0; +const isElectron = navigator.userAgent.includes('Electron'); export const useAuth = () => { const isOffline = useAppStateStore((state) => state.isOffline); @@ -137,7 +137,7 @@ export const useAuth = () => { setSystemMessage(null); }) .catch((error) => { - setSystemMessage('ログインに失敗しました。Code:100\n\n' + error.code); + setSystemMessage('ログインに失敗しました。Code:99\n\n' + error); setIsLoading(false); }); } @@ -175,11 +175,16 @@ export const useAuth = () => { return; } } else if (isElectron) { - // @ts-expect-error ElectronAPI - await window.electron.openOAuthURL(`https://${import.meta.env.VITE_AUTH_DOMAIN}/auth/google`).then((credential) => { - handleCredentialLogin(credential); - }).catch((error: FirebaseError) => { - setSystemMessage('Googleログインに失敗しました。Code:102\n\n' + error.code); + //@ts-expect-error Electron + await window.electron.openOAuthURL(`https://${import.meta.env.VITE_AUTH_DOMAIN}/auth/google`).then((credential: OAuthCredential) => { + const googleCredential = GoogleAuthProvider.credential(credential.idToken, credential.accessToken); + handleCredentialLogin(googleCredential); + }).catch((error: Error) => { + if (error.message.includes('closed-by-user')) { + setSystemMessage('Googleログインがキャンセルされました。'); + } else { + setSystemMessage('Googleログインに失敗しました。Code:102\n\n' + (error instanceof Error ? error.message : 'Unknown error')); + } setIsLoading(false); }); } else { @@ -227,11 +232,16 @@ export const useAuth = () => { return; } } else if (isElectron) { - // @ts-expect-error ElectronAPI - await window.electron.openOAuthURL(`https://${import.meta.env.VITE_AUTH_DOMAIN}/auth/apple`).then((credential) => { - handleCredentialLogin(credential); - }).catch((error: FirebaseError) => { - setSystemMessage('Appleログインに失敗しました。Code:107\n\n' + error.code); + //@ts-expect-error Electron + await window.electron.openOAuthURL(`https://${import.meta.env.VITE_AUTH_DOMAIN}/auth/apple`).then((credential: OAuthCredential) => { + const appleCredential = OAuthProvider.credentialFromJSON(credential); + handleCredentialLogin(appleCredential); + }).catch((error: Error) => { + if (error.message.includes('closed-by-user')) { + setSystemMessage('Appleログインがキャンセルされました。'); + } else { + setSystemMessage('Appleログインに失敗しました。Code:107\n\n' + (error instanceof Error ? error.message : 'Unknown error')); + } setIsLoading(false); }); } else {