mirror of
https://github.com/lifegpc/bookdownload.git
synced 2026-07-08 01:31:31 +08:00
Add saved mark to Chapters List
This commit is contained in:
@@ -2,3 +2,8 @@
|
||||
margin: 4px 8px;
|
||||
width: min(calc((100% - 40px) / 4), 300px);
|
||||
}
|
||||
|
||||
.saved {
|
||||
margin-left: auto;
|
||||
color: green;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
@@ -195,6 +195,7 @@ export type BookGData = {
|
||||
export type Chapter = {
|
||||
name: string;
|
||||
id: number;
|
||||
isSaved?: boolean;
|
||||
}
|
||||
|
||||
export type Volume = {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user