Skip to content

Commit

Permalink
fix: character submit problems
Browse files Browse the repository at this point in the history
  • Loading branch information
BIYUEHU committed Aug 15, 2024
1 parent bd9d8f1 commit c745f01
Show file tree
Hide file tree
Showing 57 changed files with 346 additions and 711 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ migrations

packages/core/public/imgs/**/*.png
packages/core/public/imgs/**/*.jpg
packages/core/public/imgs/**/*.jpeg
packages/core/public/imgs/**/*.jpeg

packages/core/public/assets/*
packages/core/public/*.html
82 changes: 81 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,96 @@

# MoeHub

⚡ A modern and universal Meta-Framework to construct other frameworks. ⚡
⚡ A open source personal favorite character collection website system ⚡

⚡ 壹個開源的個人向喜愛角色收藏網站系統 ⚡

</div>

## Details

### Supports types

- [x] Anime characters
- [x] Manga/Comic characters
- [x] Game characters
- [x] Galgame/Visual Novel characters
- [x] Light novel characters
- [x] Other characters

Only supports **Japanese** characters, moehub doesn't support and welcome characters of other languages,especially
Z(C)hinese characters.

### International

- [x] Japan - Japanese (Default language)
- [x] American - English
- [x] Taiwan/Hongkong - Traditional Chinese
- [x] Zhina - Simplified Chinese (Will be deleted in the future)

### Cli commands

![](https://pic.imgdb.cn/item/66bd8160d9c307b7e9eb0016.png)

- `help [...command]` Get command help information
- `pwd` Reset password in force when you forget your password
- `data` Get statistics data
- `character [name]` Get all or some characters's information

### Characters birthdays reminder

![](https://pic.imgdb.cn/item/66bd8160d9c307b7e9eaff64.png)

Supports custom email template, receiver and any email accounts.

> Need you to set configurations (refer to the next content)
## Example

> [👉 There](https://m.hotaru.icu)
## Usage

1. Download release version from [Github Release](https://github.com/biyuehu/moehub/releases)

2. Extract the downloaded file

3. Install dependencies (Choose one)

```bash
npm install
yarn
pnpm install
```

4. Set your `.env` config and database


```ini
DATABASE_URL="mysql://username:password@host:port/database"

# MoeHub server port

PORT=5000

# MoeHub logger level

LOG_LEVEL=30
```

5. Import `data.sql` into your database

6. Start the server (Choose one)

```bash
npm run serve
yarn serve
pnpm serve
```

7. Login and set your website at `http://your-domain:5000/#/admin/settings` (Such as website title, name, address,
email key and more...)

## Stacks

- Frontend: React, tailwind-css, @kotori-bot/i18n
Expand Down
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

- [ ] Static webpage version
- [ ] Supports character collections
- [ ] Support next.js version
8 changes: 7 additions & 1 deletion packages/client/src/components/CharacterForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ export function handleMoehubDataCharacter(values: MoehubDataCharacterHandle): Mo
// console.log(values.color)
return {
...values,
color: values.color ? (values.color.cleared === false ? values.color.toHex() : '') : undefined,
color: values.color
? typeof values.color === 'string'
? values.color
: values.color.cleared === false
? values.color.toHex()
: ''
: undefined,
birthday: values.birthday ? new Date(values.birthday.toString()).getTime() : undefined
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Flex, Layout as AntLayout, Avatar, Button } from 'antd'
import { Flex, Layout as AntLayout, Avatar } from 'antd'
import { PictureOutlined, PoweroffOutlined, TranslationOutlined } from '@ant-design/icons'
import { Link, useNavigate } from 'react-router-dom'
import styles from './styles.module.css'
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default {
url: '/api'
url: 'http://localhost:5000/api'
}
2 changes: 1 addition & 1 deletion packages/client/src/i18n/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ export default {
'com.characterForm.seriesGenre.comic': 'Comic',
'com.characterForm.seriesGenre.galgame': 'Galgame/Visual Novel',
'com.characterForm.seriesGenre.game': 'Game',
'com.characterForm.images.button': 'Add Image',
'com.characterForm.seriesGenre.novel': 'Light Novel',
'com.characterForm.seriesGenre.other': 'Other',
'com.characterForm.label.2': 'Detailed Information',
'com.characterForm.alias': 'Alias',
'com.characterForm.images': 'Images',
'com.characterForm.images.button': 'Add Image',
'com.characterForm.description': 'Description',
'com.characterForm.hitokoto': 'Hitokoto',
'com.characterForm.birthday': 'Birthday',
Expand Down
4 changes: 3 additions & 1 deletion packages/client/src/views/Admin/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ const LoginView: React.FC = () => {
const isLogged = !!useSelector(getToken)

useEffect(() => {
if (isLogged) navigate('/admin')
if (!isLogged) return
navigate(0)
navigate('/admin')
}, [navigate, isLogged])

const [form] = Form.useForm<LoginData>()
Expand Down
9 changes: 6 additions & 3 deletions packages/client/src/views/Character/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ const CharacterView: React.FC = () => {
<h1>{t`view.character.title`}</h1>
<Flex justify="center" align="center" vertical>
<Card hoverable className="card cardFixed">
{data.hitokoto ? <div className={styles.hitokoto}>{data.hitokoto}</div> : null}
{data.hitokoto ? (
<div {...(data.color ? { style: { color: `#${data.color}` } } : {})} className={styles.hitokoto}>
{data.hitokoto}
</div>
) : null}
{data.songId ? (
<>
<br />
<iframe
title={t`view.character.themeSong`}
width="330"
height="86"
style={{ maxWidth: '80%', width: 330, height: 86 }}
src={`https://music.163.com/outchain/player?auto=1&type=2&id=${data.songId}&height=66`}
/>
<br />
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/views/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ const HomeView: React.FC = () => {
<h1>{t`view.home.characterList`}</h1>
<Flex justify="center" wrap className={styles.characterList}>
{data
.filter((item) => Array.isArray(item.images) && item.images.length > 0)
.filter((item) => Array.isArray(item.images) && item.images.length > 0 && !item.hide)
.reverse()
.sort((a, b) => a.order - b.order)
.sort((a, b) => (a.order ?? 50) - (b.order ?? 50))
.map((item) => (
<Card
key={item.id}
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/views/Photos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const PhotosView: React.FC = () => {
const [displayedImages, setDisplayedImages] = useState<string[]>([])

const loadMoreImages = useCallback(() => {
if (!data) return
if (!data || data.length === 0) return
const nextPage = page + 1
const startIndex = page * IMAGES_PER_PAGE
const endIndex = startIndex + IMAGES_PER_PAGE
Expand All @@ -28,7 +28,7 @@ const PhotosView: React.FC = () => {
}, [data, page])

useEffect(() => {
if (!data) return
if (!data || data.length === 0) return
if (displayedImages.length === 0) {
setDisplayedImages(data.slice(0, IMAGES_PER_PAGE))
}
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export const characterSchema = Tsu.Object({
bust: intPositive.optional(),
waist: intPositive.optional(),
hip: intPositive.optional(),
order: Tsu.Number().int().min(0).default(50),
hide: Tsu.Boolean().default(false)
order: Tsu.Number().int().min(0).optional(),
hide: Tsu.Boolean().optional()
}).strict()

export const settingsSchema = Tsu.Object({
Expand Down
Loading

0 comments on commit c745f01

Please sign in to comment.