Add saved mark to Chapters List

This commit is contained in:
2026-02-19 09:22:05 +08:00
parent f56a9e3b2a
commit 9f85a42168
4 changed files with 20 additions and 5 deletions

View File

@@ -2,3 +2,8 @@
margin: 4px 8px;
width: min(calc((100% - 40px) / 4), 300px);
}
.saved {
margin-left: auto;
color: green;
}

View File

@@ -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 ? <span style={{ color: 'red' }}>VIP卷</span> : null,
children: <Flex wrap>
{v.chapters.map(chapter => (
<Link to={`/qd/book/${bookId}/chapter/${chapter.id}`} className={styles.ch} key={chapter.id}>{chapter.name}</Link>
<Flex className={styles.ch} key={chapter.id}>
<Link to={`/qd/book/${bookId}/chapter/${chapter.id}`}>{chapter.name}</Link>
{chapter.isSaved && <CheckCircleOutlined className={styles.saved} />}
</Flex>
))}
</Flex>
}

View File

@@ -195,6 +195,7 @@ export type BookGData = {
export type Chapter = {
name: string;
id: number;
isSaved?: boolean;
}
export type Volume = {

View File

@@ -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<number, string> = new Map();
for (const vol of volumes) {
const volMap: Map<number, Chapter> = 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) {