diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 586824e..c3a9a2c 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -7,6 +7,15 @@ datasource db { url = env("DB_URL") } +model User { + id String @id @default(cuid()) + name String @unique + email String @unique + password String + created_at DateTime @default(now()) + updated_at DateTime? +} + model ACGM { id Int @id @default(autoincrement()) title String? diff --git a/prisma/seed.ts b/prisma/seed.ts index e15a241..b5e113f 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -24,6 +24,13 @@ const songs: Prisma.ACGMCreateInput[] = [ bangumi: "这个美术部有问题", music_id: 435288259 }, + { + title: "みずきのテーマ", + artist: "吟", + album: "この美術部には問題がある! オリジナルサウンドトラックCD vol.1", + bangumi: "这个美术部有问题", + music_id: 435288260 + }, { title: "伝える勇気があったなら", artist: "吟", @@ -85,6 +92,14 @@ async function main() { }); } + await prisma.user.create({ + data: { + name: "Paul", + email: "dreamer_paul@126.com", + password: "123456", + } + }); + console.log(`Seeding finished.`); } diff --git a/src/components/Admin/AddACGM.tsx b/src/components/Admin/AddACGM.tsx new file mode 100644 index 0000000..2cfec40 --- /dev/null +++ b/src/components/Admin/AddACGM.tsx @@ -0,0 +1,66 @@ +// React +import React from "react"; +import { useRequest } from "ahooks"; +import useStat from "@/hooks/useStat"; + + +// UI +import Button from "@/components/Base/Button"; + + +// Tool +import addMusicRequest from "@/server/api/admin/acgm/add"; + + +// Interface +import { MouseEvent, ChangeEvent } from "react"; + + +// Components +function AddACGM() { + const { loading, run } = useRequest( + (params) => addMusicRequest({ + query: params + }), + { + manual: true, + onSuccess: (data) => { + console.log(data); + } + } + ); + + const [input, setInput] = useStat({ + id: "", + bangumi: "" + }); + + const onSubmit = (ev: MouseEvent) => { + ev.preventDefault(); + + run(input); + } + + const onInputChange = (ev: ChangeEvent) => { + setInput({ [ev.target.name]: ev.target.value }); + } + + return ( +
+ +
+ ) +} + +export default AddACGM; diff --git a/src/components/Admin/RemoveMusicCache.tsx b/src/components/Admin/RemoveMusicCache.tsx new file mode 100644 index 0000000..82e29b2 --- /dev/null +++ b/src/components/Admin/RemoveMusicCache.tsx @@ -0,0 +1,62 @@ +// React +import React from "react"; +import { useRequest } from "ahooks"; +import useStat from "@/hooks/useStat"; + + +// UI +import Button from "@/components/Base/Button"; + + +// Tool +import cleanCacheRequest from "@/server/api/admin/netease/clean"; + + +// Interface +import { MouseEvent, ChangeEvent } from "react"; + + +// Components +function RemoveMusicCache() { + const { loading, run } = useRequest( + (params) => cleanCacheRequest({ + query: params + }), + { + manual: true, + onSuccess: (data) => { + console.log(data); + } + } + ); + + const [input, setInput] = useStat({ + id: "" + }); + + const onSubmit = (ev: MouseEvent) => { + ev.preventDefault(); + + run(input); + } + + const onInputChange = (ev: ChangeEvent) => { + setInput({ [ev.target.name]: ev.target.value }); + } + + return ( +
+ +
+ ) +} + +export default RemoveMusicCache; diff --git a/src/components/Base/Button.tsx b/src/components/Base/Button.tsx new file mode 100644 index 0000000..c8a59e4 --- /dev/null +++ b/src/components/Base/Button.tsx @@ -0,0 +1,23 @@ +// React +import React from "react"; + + +// Interface +interface ButtonProps { + loading?: boolean + children: React.ReactNode + + onClick?: React.MouseEventHandler +} + + +// Component +function Button({ loading = false, children, onClick }: ButtonProps) { + return ( + + ) +} + +export default Button; diff --git a/src/components/Layout/Aside.tsx b/src/components/Layout/Aside.tsx index 0de4d45..f133abf 100644 --- a/src/components/Layout/Aside.tsx +++ b/src/components/Layout/Aside.tsx @@ -47,6 +47,7 @@ function Aside() { 随机动漫音乐 哔哩哔哩小窗 必应每日壁纸 + {profile.name && 轻管理} diff --git a/src/components/Layout/FrontWrapper.tsx b/src/components/Layout/FrontWrapper.tsx index 09547e0..66b6c6c 100644 --- a/src/components/Layout/FrontWrapper.tsx +++ b/src/components/Layout/FrontWrapper.tsx @@ -1,11 +1,9 @@ // React import React, { useEffect, useLayoutEffect } from "react"; -import useGlobalData from "@/hooks/useGlobalData"; import { useLocation } from "react-router-dom"; // Components -import GlobalContext from "@/components/GlobalContext"; import Aside from "@/components/Layout/Aside"; import Footer from "@/components/Layout/Footer"; @@ -20,7 +18,6 @@ interface FrontWrapperProps { // Components function FrontWrapper(props: FrontWrapperProps) { const location = useLocation(); - let [globalData, setGlobalData] = useGlobalData(); useEffect(() => { const name = import.meta.env.PAUL_SITENAME; @@ -38,11 +35,11 @@ function FrontWrapper(props: FrontWrapperProps) { }, [location.pathname]); return ( - + <>