mirror of
https://github.com/lifegpc/bookdownload.git
synced 2026-07-08 01:31:31 +08:00
add download options page
This commit is contained in:
@@ -35,6 +35,11 @@
|
|||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
max-width: min(calc(100% - 20px), 940px);
|
||||||
|
margin: 4px auto;
|
||||||
|
}
|
||||||
|
|
||||||
.affix {
|
.affix {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Affix, Flex, Space, Tag, Typography, Skeleton, Result, Button } from "antd";
|
import { Affix, Flex, Space, Tag, Typography, Skeleton, Result, Button, Modal } from "antd";
|
||||||
import { useBookInfo } from "./BookInfoProvider";
|
import { useBookInfo } from "./BookInfoProvider";
|
||||||
import styles from './BookIndex.module.css';
|
import styles from './BookIndex.module.css';
|
||||||
import { loadChapterListsIfNeeded, useBookContext, useBookStatus } from "./BookStatusProvider";
|
import { loadChapterListsIfNeeded, useBookContext, useBookStatus } from "./BookStatusProvider";
|
||||||
@@ -9,6 +9,8 @@ import type { Volume } from "../../qdtypes";
|
|||||||
import { ChapterShowMode, get_new_volumes } from "../../utils/qd";
|
import { ChapterShowMode, get_new_volumes } from "../../utils/qd";
|
||||||
import ShowMode from "./ShowMode";
|
import ShowMode from "./ShowMode";
|
||||||
import { sendMessageToTab, waitTabLoaded } from "../../utils";
|
import { sendMessageToTab, waitTabLoaded } from "../../utils";
|
||||||
|
import { QdBookDownloadOptions } from "../../types";
|
||||||
|
import SwitchLabel from "../../components/SwitchLabel";
|
||||||
|
|
||||||
const { Paragraph, Link } = Typography;
|
const { Paragraph, Link } = Typography;
|
||||||
|
|
||||||
@@ -20,6 +22,8 @@ export default function BookIndex() {
|
|||||||
const [bookStatus, setBookStatus] = useBookStatus();
|
const [bookStatus, setBookStatus] = useBookStatus();
|
||||||
const setItems = useBookContext();
|
const setItems = useBookContext();
|
||||||
const [err, setErr] = useState<string | null>(null);
|
const [err, setErr] = useState<string | null>(null);
|
||||||
|
const [saveChapterOpenAsEpub, setSaveChapterOpenAsEpub] = useState(false);
|
||||||
|
const [downloadOptions, setDownloadOptions] = useState<QdBookDownloadOptions>({});
|
||||||
function setChapterShowMode(chapterShowMode: ChapterShowMode) {
|
function setChapterShowMode(chapterShowMode: ChapterShowMode) {
|
||||||
setBookStatus({ ...bookStatus, chapterShowMode });
|
setBookStatus({ ...bookStatus, chapterShowMode });
|
||||||
}
|
}
|
||||||
@@ -41,6 +45,7 @@ export default function BookIndex() {
|
|||||||
await sendMessageToTab(tab.id!, {
|
await sendMessageToTab(tab.id!, {
|
||||||
type: 'DownloadQdBookAsEpub',
|
type: 'DownloadQdBookAsEpub',
|
||||||
info: bookInfo,
|
info: bookInfo,
|
||||||
|
options: downloadOptions,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -75,8 +80,30 @@ export default function BookIndex() {
|
|||||||
))}</Paragraph>
|
))}</Paragraph>
|
||||||
</Space>
|
</Space>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex align="cenrer">
|
<Flex align="center" className={styles.actions}>
|
||||||
<Button type="primary" onClick={handleSaveAsEpub}>保存为EPUB</Button>
|
<Button type="primary" onClick={() => setSaveChapterOpenAsEpub(true)}>保存为EPUB</Button>
|
||||||
|
<Modal
|
||||||
|
open={saveChapterOpenAsEpub}
|
||||||
|
onCancel={() => setSaveChapterOpenAsEpub(false)}
|
||||||
|
onOk={() => {
|
||||||
|
setSaveChapterOpenAsEpub(false);
|
||||||
|
handleSaveAsEpub();
|
||||||
|
}}
|
||||||
|
title="保存为EPUB"
|
||||||
|
okText="保存"
|
||||||
|
cancelText="取消"
|
||||||
|
>
|
||||||
|
<SwitchLabel
|
||||||
|
checked={downloadOptions.skipNotBoughtChapters ?? false}
|
||||||
|
onChange={(checked) => setDownloadOptions({ ...downloadOptions, skipNotBoughtChapters: checked })}
|
||||||
|
label="跳过未购买章节"
|
||||||
|
/>
|
||||||
|
<SwitchLabel
|
||||||
|
checked={downloadOptions.skipUnsavedChapters ?? false}
|
||||||
|
onChange={(checked) => setDownloadOptions({ ...downloadOptions, skipUnsavedChapters: checked })}
|
||||||
|
label="跳过未保存章节"
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Affix offsetTop={10}>
|
<Affix offsetTop={10}>
|
||||||
<Flex justify="flex-end" className={styles.affix}>
|
<Flex justify="flex-end" className={styles.affix}>
|
||||||
|
|||||||
Reference in New Issue
Block a user