diff --git a/src/manage.tsx b/src/manage.tsx index a15c334..4606e0c 100644 --- a/src/manage.tsx +++ b/src/manage.tsx @@ -8,6 +8,7 @@ import QdBooks from "./manage/qd/Books"; import { Result } from 'antd'; import { DbContext } from "./manage/dbProvider"; import QdBook from "./manage/qd/Book"; +import QdBookIndex from "./manage/qd/BookIndex"; const router = createHashRouter([ { @@ -21,6 +22,12 @@ const router = createHashRouter([ { path: "/qd/book/:id", element: , + children: [ + { + index: true, + element: + } + ], } ]); diff --git a/src/manage/qd/Book.tsx b/src/manage/qd/Book.tsx index 0230377..f6346b9 100644 --- a/src/manage/qd/Book.tsx +++ b/src/manage/qd/Book.tsx @@ -1,8 +1,9 @@ import { Breadcrumb, Result, Button, Skeleton } from "antd"; -import { NavLink, useParams } from "react-router"; +import { NavLink, Outlet, useParams } from "react-router"; import { useDb } from "../dbProvider"; import type { QdBookInfo } from "../../types"; import { useEffect, useState } from "react"; +import { BookInfoContext } from "./BookInfoProvider"; export default function Book() { const db = useDb(); @@ -44,6 +45,9 @@ export default function Book() { title="数据加载失败" subTitle={err} extra={} />} + {book && ( + + )} ); } diff --git a/src/manage/qd/BookIndex.module.css b/src/manage/qd/BookIndex.module.css new file mode 100644 index 0000000..f1150aa --- /dev/null +++ b/src/manage/qd/BookIndex.module.css @@ -0,0 +1,22 @@ +.c .img { + width: 180px; + height: auto; +} + +.c .info { + min-width: 300px; +} + +.c .name { + margin: 0 8px; + text-align: center; +} + +.c .author { + margin: 0 8px; + text-align: right; +} + +.c .author > span { + font-weight: bold; +} diff --git a/src/manage/qd/BookIndex.tsx b/src/manage/qd/BookIndex.tsx new file mode 100644 index 0000000..54a0f48 --- /dev/null +++ b/src/manage/qd/BookIndex.tsx @@ -0,0 +1,20 @@ +import { Flex, Space, Typography } from "antd"; +import { useBookInfo } from "./BookInfoProvider"; +import styles from './BookIndex.module.css'; + +const { Paragraph } = Typography; + +export default function BookIndex() { + const bookInfo = useBookInfo(); + return ( +
+ + + +

{bookInfo.bookName}

+ {bookInfo.bookInfo.pageJson.authorInfo.authorName} +
+
+
+ ); +} diff --git a/src/manage/qd/BookInfoProvider.ts b/src/manage/qd/BookInfoProvider.ts new file mode 100644 index 0000000..4cefe89 --- /dev/null +++ b/src/manage/qd/BookInfoProvider.ts @@ -0,0 +1,8 @@ +import { createContext, useContext } from "react"; +import type { QdBookInfo } from "../../types"; + +export const BookInfoContext = createContext(null as any); + +export function useBookInfo() { + return useContext(BookInfoContext); +}