1
0
mirror of https://github.com/h3poteto/whalebird-desktop synced 2024-12-25 16:23:19 +01:00
Whalebird-desktop-client-ma.../renderer/pages/index.tsx
2024-01-12 22:14:33 +09:00

34 lines
876 B
TypeScript

import { useRouter } from 'next/router'
import { useEffect } from 'react'
import { db } from '@/db'
import { Spinner } from '@material-tailwind/react'
export default function Index() {
const router = useRouter()
useEffect(() => {
const f = async () => {
const accounts = await db.accounts.toArray()
if (accounts.length > 0) {
if (typeof localStorage !== 'undefined') {
const lastAccount = localStorage.getItem(`lastAccount`)
if (parseInt(lastAccount) >= 0) {
router.push(`/accounts/${lastAccount}`)
} else {
router.push(`/accounts/${accounts[0].id}`)
}
} else {
router.push(`/accounts/${accounts[0].id}`)
}
}
}
f()
}, [])
return (
<div className="h-screen w-full flex justify-center items-center">
<Spinner />
</div>
)
}