Skip to content

Commit

Permalink
feat: character page
Browse files Browse the repository at this point in the history
  • Loading branch information
BIYUEHU committed Jun 13, 2024
1 parent efb3c94 commit 99c7339
Show file tree
Hide file tree
Showing 20 changed files with 447 additions and 101 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Your anime character collection gallery, easily build, freely share.

## Example

> [👉 There](https://hotaru.icu/moehub.html)
## Stacks

- Frontend: React, tailwind-css
Expand Down
4 changes: 2 additions & 2 deletions packages/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="" />
<link rel="icon" type="image/svg+xml" href="https://hotaru.icu/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Moehub</title>
<title>MoeHub</title>
</head>

<body>
Expand Down
5 changes: 3 additions & 2 deletions packages/client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useRoutes } from 'react-router-dom';
import layout from './components/layout';
import Layout from './components/Layout';
import router from './router';

function App() {
const outlet = useRoutes(router);
document.title = 'MoeHub';

return <div>{layout(outlet!)}</div>;
return <Layout outlet={outlet!} />;
}

export default App;
32 changes: 32 additions & 0 deletions packages/client/src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Flex, Layout as AntLayout } from 'antd';
import { Link } from 'react-router-dom';
import styles from './styles.module.css';

const { Header, Footer, Content } = AntLayout;

const Layout: React.FC<{ outlet: React.ReactElement }> = ({ outlet }) => (
<>
<div className={styles.background}></div>
<Flex gap="middle" wrap>
<AntLayout className={styles.layout}>
<Header className={styles.header}>
<h1>
<Link className={styles.headerTitle} to="/">
Moe Hub
</Link>
</h1>
</Header>
<Content className={styles.content}>{outlet}</Content>
<Footer className={styles.footer}>
Made with ❤ By{' '}
<a href="https://github.com/biyuehu" target="_blank">
Arimura Sena
</a>{' '}
In © 2024
</Footer>
</AntLayout>
</Flex>
</>
);

export default Layout;
42 changes: 42 additions & 0 deletions packages/client/src/components/Layout/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.background {
top: 0;
left: 0;
width: 100%;
height: 110vh;
position: fixed;
z-index: -1;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-image: url('https://himeno-sena.com/pic3.jpg');
}

.header {
color: #eee;
background-color: #227d51;
height: 64px;
padding-inline: 48px;
line-height: 64px;
}

.headerTitle {
color: #eee;
}

.content {
min-height: 120px;
line-height: 120px;
overflow: initial;
}

.footer {
color: #eee;
background-color: #333;
}

.layout {
text-align: center;
border-radius: 8px;
min-height: 100vh;
background-color: #ffffffc0;
}
38 changes: 0 additions & 38 deletions packages/client/src/components/layout.tsx

This file was deleted.

11 changes: 11 additions & 0 deletions packages/client/src/components/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Flex, Spin } from 'antd';

const Loading: React.FC = () => (
<Flex justify="center" align="center" style={{ width: '100%', height: '80vh' }}>
<Spin tip="Loading" size="large">
<div></div>
</Spin>
</Flex>
);

export default Loading;
7 changes: 7 additions & 0 deletions packages/client/src/components/result/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Result } from 'antd';

const ErrorResult: React.FC = () => (
<Result status="error" title="获取数据失败" subTitle="请检查网络连接或接口地址是否配置正确" />
);

export default ErrorResult;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { message } from 'antd';
import { notification } from 'antd';
import config from './config.js';

const http = axios.create({
Expand All @@ -19,7 +19,11 @@ http.interceptors.response.use(
} */
response.data,
(err) => {
if (err instanceof Error) message.useMessage()[0].error(`请求错误:${err.message}`);
notification.error({
message: 'Http request error',
description: err instanceof Error ? err.message : err || 'Unknown error',
placement: 'topRight'
});
return Promise.reject(err);
}
);
Expand Down
5 changes: 5 additions & 0 deletions packages/client/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import 'antd/dist/reset.css';
import 'tailwindcss/tailwind.css';
import 'antd/dist/antd.min.js.LICENSE.txt';
import './styles/index.css';
import { notification } from 'antd';
import App from './App.tsx';

notification.config({
duration: 3
});

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<BrowserRouter>
Expand Down
7 changes: 6 additions & 1 deletion packages/client/src/router/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { lazy } from 'react';
import Loading from '../components/loading';

/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
function lazyLoader(callback: () => Promise<any>) {
const Component = lazy(callback);
return (
<React.Suspense fallback={<div>Loading...</div>}>
<React.Suspense fallback={<Loading />}>
<Component />
</React.Suspense>
);
Expand All @@ -15,6 +16,10 @@ export default [
path: '/',
element: lazyLoader(() => import('../views/Home'))
},
{
path: '/character/:id',
element: lazyLoader(() => import('../views/Character'))
},
{
path: '/about',
element: lazyLoader(() => import('../views/About'))
Expand Down
22 changes: 22 additions & 0 deletions packages/client/src/styles/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
::selection {
background-color: #227d51bb;
}

a {
color: #227d51;
}

a:hover {
background-color: #096148;
}

a::selection {
color: #333;
background-color: #096148;
}

.card {
background: none;
border: 1px solid #00000040;
border-radius: 10px;
}
5 changes: 5 additions & 0 deletions packages/client/src/styles/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const MAIN_COLOR = '#227D51';

export const MAIN_COLOR_DEEP = '#096148';

export const PRIMARY_COLOR = '#0077B6';
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default () => (
const AboutView: React.FC = () => (
<div>
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Iste quod culpa dolores esse quis beatae cupiditate
commodi, id vitae tenetur, facilis dicta iusto atque, animi soluta consequatur! Officia, ab rerum!
</div>
);

export default AboutView;
Loading

0 comments on commit 99c7339

Please sign in to comment.