2023-03-06 15:04:00 -05:00
|
|
|
import { ErrorContent } from 'components/ErrorContent';
|
|
|
|
|
import { Loading } from 'components/Loading';
|
2023-03-08 12:03:57 -05:00
|
|
|
import { RunPanel } from 'components/RunPanel';
|
2023-03-06 15:32:09 -05:00
|
|
|
import { STAT_INK } from 'constant';
|
2023-03-06 15:04:00 -05:00
|
|
|
import { usePromise } from 'hooks/usePromise';
|
2023-03-04 08:10:30 -05:00
|
|
|
import React from 'react'
|
2023-03-06 07:21:29 -05:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-03-06 09:01:18 -05:00
|
|
|
import { Link } from "react-router-dom";
|
2023-03-06 15:04:00 -05:00
|
|
|
import { getConfig, getProfile } from 'services/config';
|
|
|
|
|
import { composeLoadable } from 'utils/composeLoadable';
|
2023-03-04 08:10:30 -05:00
|
|
|
|
2023-03-06 07:21:29 -05:00
|
|
|
export const Home: React.FC = () => {
|
2023-03-06 15:32:09 -05:00
|
|
|
let { loading, error, retry } = composeLoadable({
|
2023-03-06 15:04:00 -05:00
|
|
|
config: usePromise(getConfig),
|
|
|
|
|
profile: usePromise(() => getProfile(0)),
|
|
|
|
|
});
|
2023-03-06 07:21:29 -05:00
|
|
|
const { t } = useTranslation();
|
2023-03-03 09:06:14 -05:00
|
|
|
|
2023-03-06 15:04:00 -05:00
|
|
|
if (loading) {
|
|
|
|
|
return <>
|
|
|
|
|
<div className='h-full flex items-center justify-center'><Loading /></div>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
return <>
|
|
|
|
|
<ErrorContent error={error} retry={retry} />
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 09:06:14 -05:00
|
|
|
return <>
|
2023-03-08 09:55:23 -05:00
|
|
|
<div className='full-card'>
|
2023-03-06 15:32:09 -05:00
|
|
|
<h1 className='mb-4'>{t('欢迎!')}</h1>
|
|
|
|
|
<div className='flex flex-col gap-2'>
|
2023-03-08 12:03:57 -05:00
|
|
|
<RunPanel />
|
|
|
|
|
<Link to='/settings' className='btn'>{t('配置')}</Link>
|
2023-03-06 15:32:09 -05:00
|
|
|
<a className='btn' href={STAT_INK} target='_blank' rel='noreferrer'>{t('前往 stat.ink')}</a>
|
|
|
|
|
</div>
|
2023-03-06 07:21:29 -05:00
|
|
|
</div>
|
2023-03-03 09:06:14 -05:00
|
|
|
</>
|
2023-03-04 06:19:24 -05:00
|
|
|
}
|