|
@@ -11,15 +11,27 @@ import Toolbar from "../../../components/novel/Toolbar";
|
|
|
import Settings from "../../../components/novel/Settings";
|
|
import Settings from "../../../components/novel/Settings";
|
|
|
|
|
|
|
|
import type { NextPageWithLayout } from "../../_app";
|
|
import type { NextPageWithLayout } from "../../_app";
|
|
|
-import type { ChapterData, ChapterListData } from "../../../types/http";
|
|
|
|
|
|
|
+import type { /* ChapterData, */ ChapterListData } from "../../../types/http";
|
|
|
|
|
|
|
|
import styles from "../../../styles/chapter.module.scss";
|
|
import styles from "../../../styles/chapter.module.scss";
|
|
|
|
|
+import useSWR from "swr";
|
|
|
|
|
+
|
|
|
|
|
+interface ChapterData {
|
|
|
|
|
+ chapter: "";
|
|
|
|
|
+ content: "";
|
|
|
|
|
+ errmsg: "ok";
|
|
|
|
|
+ errno: 10000;
|
|
|
|
|
+ next: "";
|
|
|
|
|
+ pre: "";
|
|
|
|
|
+ title: "";
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
const Chapter: NextPageWithLayout = () => {
|
|
const Chapter: NextPageWithLayout = () => {
|
|
|
const { query } = useRouter();
|
|
const { query } = useRouter();
|
|
|
|
|
|
|
|
- const { data: chapterData = null } = useGet<ChapterData>(
|
|
|
|
|
- `/api/novel/chapter/${query.slug}/${query.chapter}`
|
|
|
|
|
|
|
+ const { data: chapterData = null } = useSWR<ChapterData>(
|
|
|
|
|
+ `/api/novel/chapter/${query.slug}/${query.chapter}`,
|
|
|
|
|
+ (url) => fetch(url).then((res) => res.json())
|
|
|
);
|
|
);
|
|
|
// const { data: { data: chapterData } = { data: null } } = useGet<ChapterData>(
|
|
// const { data: { data: chapterData } = { data: null } } = useGet<ChapterData>(
|
|
|
// `/api/novel/chapter/${query.slug}/${query.chapter}`
|
|
// `/api/novel/chapter/${query.slug}/${query.chapter}`
|