diff --git a/src/manage/qd/Book.tsx b/src/manage/qd/Book.tsx index f6346b9..6a83a4e 100644 --- a/src/manage/qd/Book.tsx +++ b/src/manage/qd/Book.tsx @@ -4,12 +4,14 @@ import { useDb } from "../dbProvider"; import type { QdBookInfo } from "../../types"; import { useEffect, useState } from "react"; import { BookInfoContext } from "./BookInfoProvider"; +import { BookStatusContext, createBookStatus } from "./BookStatusProvider"; export default function Book() { const db = useDb(); const { id } = useParams(); const [book, setBook] = useState(null); const [err, setErr] = useState(null); + const [bookStatus, setBookStatus] = useState(createBookStatus()); async function load() { const data = await db.getQdBook(Number(id)); if (data) { @@ -46,7 +48,9 @@ export default function Book() { subTitle={err} extra={} />} {book && ( - + + + )} ); diff --git a/src/manage/qd/BookIndex.module.css b/src/manage/qd/BookIndex.module.css index f1150aa..8613e9a 100644 --- a/src/manage/qd/BookIndex.module.css +++ b/src/manage/qd/BookIndex.module.css @@ -1,10 +1,11 @@ .c .img { - width: 180px; - height: auto; + width: 140px; + height: fit-content; } .c .info { min-width: 300px; + max-width: min(calc(100% - 160px), 800px); } .c .name { @@ -20,3 +21,20 @@ .c .author > span { font-weight: bold; } + +.c .tags { + margin: 0 8px; +} + +.c .sign { + margin: 0 8px; +} + +.c .intro { + margin: 0 8px; + white-space: pre-wrap; +} + +.affix { + background-color: white; +} diff --git a/src/manage/qd/BookIndex.tsx b/src/manage/qd/BookIndex.tsx index 54a0f48..284adca 100644 --- a/src/manage/qd/BookIndex.tsx +++ b/src/manage/qd/BookIndex.tsx @@ -1,20 +1,47 @@ -import { Flex, Space, Typography } from "antd"; +import { Affix, Flex, Space, Tag, Typography, Switch } from "antd"; import { useBookInfo } from "./BookInfoProvider"; import styles from './BookIndex.module.css'; +import { useBookStatus } from "./BookStatusProvider"; +import VolumesList from "./VolumesList"; -const { Paragraph } = Typography; +const { Paragraph, Link } = Typography; + +const QD_BOOK_TAG_COLOR = ['blue', 'cyan', 'orange']; export default function BookIndex() { const bookInfo = useBookInfo(); + const [bookStatus, setBookStatus] = useBookStatus(); + function setShowSavedOnly(showSavedOnly: boolean) { + setBookStatus({ ...bookStatus, showSavedOnly }); + } return (
- +

{bookInfo.bookName}

{bookInfo.bookInfo.pageJson.authorInfo.authorName} + + {bookInfo.tags.map((tag) => ( + { + tag.url ? {tag.name} : tag.name + } + ))} + + + {bookInfo.bookInfo.pageJson.signStatus} + + {bookInfo.intro.split('\n').map((line, index) => ( + <>{line}
+ ))}
+ + + + + + {!bookStatus.showSavedOnly && }
); } diff --git a/src/manage/qd/BookStatusProvider.ts b/src/manage/qd/BookStatusProvider.ts new file mode 100644 index 0000000..c8c89a6 --- /dev/null +++ b/src/manage/qd/BookStatusProvider.ts @@ -0,0 +1,18 @@ +import { createContext, useContext, Dispatch } from "react"; + +export type BookStatus = { + showSavedOnly: boolean; +} + +export function createBookStatus(): BookStatus { + return { + showSavedOnly: false, + } +} + +export const BookStatusContext = createContext<[BookStatus, Dispatch]>(null as any); + +export function useBookStatus() { + return useContext(BookStatusContext); +} + diff --git a/src/manage/qd/Books.module.css b/src/manage/qd/Books.module.css index 7f68e93..3ea5432 100644 --- a/src/manage/qd/Books.module.css +++ b/src/manage/qd/Books.module.css @@ -18,3 +18,7 @@ .books-card .intro { margin-left: 8px; } + +.affix { + background-color: white; +} diff --git a/src/manage/qd/Books.tsx b/src/manage/qd/Books.tsx index 1b4aad4..63924f2 100644 --- a/src/manage/qd/Books.tsx +++ b/src/manage/qd/Books.tsx @@ -10,7 +10,6 @@ const { Paragraph } = Typography; export default function Books() { const db = useDb(); const [searchParams, setSearchParams] = useSearchParams(); - const [container, setContainer] = useState(null); const [page, setPage] = useState(Number(searchParams.get('page') || '1')); const [pageSize, setPageSize] = useState(Number(searchParams.get('pageSize') || '10')); const [totalCount, setTotalCount] = useState(null); @@ -43,9 +42,10 @@ export default function Books() { }] } /> -
- {totalCount !== null && ( container}> +
+ {totalCount !== null && ( { + return { + key: v.id, + label: v.name, + extra: v.isVip ? VIP卷 : null, + children: + {v.chapters.map(chapter => ( + {chapter.name} + ))} + + } + })} + />); +} diff --git a/src/settings/DbSettings.tsx b/src/settings/DbSettings.tsx index 77e7b38..f49d84c 100644 --- a/src/settings/DbSettings.tsx +++ b/src/settings/DbSettings.tsx @@ -85,7 +85,6 @@ function PocketBaseSettings({config}: { config: PocketBaseConfig }) { } export default function DbSettings() { - const [container, setContainer] = useState(null); const [config] = useState(new DbConfig()); const [alert, setAlert] = useState<{ title?: string; content: string } | null>(null); const [dbType, setDbType] = useState(DbType.IndexedDb); @@ -114,8 +113,8 @@ export default function DbSettings() { handleConfig(); } return ( -
- container}> +
+ diff --git a/src/settings/QdSettings.tsx b/src/settings/QdSettings.tsx index 3e5f2ec..3779eb8 100644 --- a/src/settings/QdSettings.tsx +++ b/src/settings/QdSettings.tsx @@ -6,7 +6,6 @@ import SwitchLabel from "../components/SwitchLabel"; import AlertWarn from "../components/AlertWarn"; export default function QdSettings() { - const [container, setContainer] = useState(null); const [config] = useState(new QdConfig()); const [autoSaveChapter, setAutoSaveChapter] = useState(false); const [alert, setAlert] = useState<{ title?: string; content: string } | null>(null); @@ -33,8 +32,8 @@ export default function QdSettings() { handleConfig(); } return ( -
- container}> +
+