From 9f85a42168cc1ec55c40092747860cf637724532 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Thu, 19 Feb 2026 09:22:05 +0800 Subject: [PATCH] Add saved mark to Chapters List --- src/manage/qd/VolumesList.module.css | 5 +++++ src/manage/qd/VolumesList.tsx | 6 +++++- src/qdtypes.ts | 1 + src/utils/qd.ts | 13 +++++++++---- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/manage/qd/VolumesList.module.css b/src/manage/qd/VolumesList.module.css index 84b0a75..1c4dcf5 100644 --- a/src/manage/qd/VolumesList.module.css +++ b/src/manage/qd/VolumesList.module.css @@ -2,3 +2,8 @@ margin: 4px 8px; width: min(calc((100% - 40px) / 4), 300px); } + +.saved { + margin-left: auto; + color: green; +} diff --git a/src/manage/qd/VolumesList.tsx b/src/manage/qd/VolumesList.tsx index d412215..ba9267c 100644 --- a/src/manage/qd/VolumesList.tsx +++ b/src/manage/qd/VolumesList.tsx @@ -2,6 +2,7 @@ import { Collapse, Flex } from "antd"; import type { Volume } from "../../qdtypes"; import styles from './VolumesList.module.css'; import { Link } from "react-router"; +import { CheckCircleOutlined } from "@ant-design/icons"; export type VolumesListProps = { volumes: Volume[]; @@ -17,7 +18,10 @@ export default function VolumesList({ volumes, bookId }: VolumesListProps) { extra: v.isVip ? VIP卷 : null, children: {v.chapters.map(chapter => ( - {chapter.name} + + {chapter.name} + {chapter.isSaved && } + ))} } diff --git a/src/qdtypes.ts b/src/qdtypes.ts index 2146ca6..39e937b 100644 --- a/src/qdtypes.ts +++ b/src/qdtypes.ts @@ -195,6 +195,7 @@ export type BookGData = { export type Chapter = { name: string; id: number; + isSaved?: boolean; } export type Volume = { diff --git a/src/utils/qd.ts b/src/utils/qd.ts index e5dcddf..f31abe9 100644 --- a/src/utils/qd.ts +++ b/src/utils/qd.ts @@ -32,20 +32,25 @@ export function hash_qdchapter_info(info: QdChapterInfo): string { export function get_new_volumes(chapterLists: QdChapterSimpleInfo[], volumes: Volume[], keep=true): Volume[] { const vols: Volume[] = []; if (keep) { - const volMap: Map = new Map(); - for (const vol of volumes) { + const volMap: Map = new Map(); + for (const vo of volumes) { + const vol = structuredClone(vo); for (const ch of vol.chapters) { - volMap.set(ch.id, vol.name); + volMap.set(ch.id, ch); } vols.push(vol); } const volCh: Chapter[] = []; for (const ch of chapterLists) { - if (!volMap.has(ch.id)) { + const chInfo = volMap.get(ch.id); + if (!chInfo) { volCh.push({ id: ch.id, name: ch.name, + isSaved: true, }); + } else { + chInfo.isSaved = true; } } if (volCh.length > 0) {