|
@@ -5,37 +5,22 @@ import { GetServerSideProps } from "next";
|
|
|
import { ReactElement, useEffect, useState } from "react";
|
|
import { ReactElement, useEffect, useState } from "react";
|
|
|
|
|
|
|
|
import { get } from "../../../utils/http";
|
|
import { get } from "../../../utils/http";
|
|
|
-// import useGet from "../../../utils/hooks/useGet";
|
|
|
|
|
|
|
+import useGet from "../../../utils/hooks/useGet";
|
|
|
import Toc from "../../../components/novel/Toc";
|
|
import Toc from "../../../components/novel/Toc";
|
|
|
import Toolbar from "../../../components/novel/Toolbar";
|
|
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 } from "../../../types/http";
|
|
|
|
|
|
|
+import type { ChapterData } from "../../../types/http";
|
|
|
|
|
|
|
|
import styles from "../../../styles/chapter.module.scss";
|
|
import styles from "../../../styles/chapter.module.scss";
|
|
|
-import useSWR from "swr";
|
|
|
|
|
-
|
|
|
|
|
-interface ChapterData {
|
|
|
|
|
- chapter: string;
|
|
|
|
|
- content: string;
|
|
|
|
|
- errmsg: string;
|
|
|
|
|
- errno: number;
|
|
|
|
|
- next: string;
|
|
|
|
|
- pre: string;
|
|
|
|
|
- title: string;
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
const Chapter: NextPageWithLayout = () => {
|
|
const Chapter: NextPageWithLayout = () => {
|
|
|
const { query } = useRouter();
|
|
const { query } = useRouter();
|
|
|
|
|
|
|
|
- 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>(
|
|
|
|
|
+ `/api/novel/chapter/${query.slug}/${query.chapter}`
|
|
|
);
|
|
);
|
|
|
- // const { data: { data: chapterData } = { data: null } } = useGet<ChapterData>(
|
|
|
|
|
- // `/api/novel/chapter/${query.slug}/${query.chapter}`
|
|
|
|
|
- // );
|
|
|
|
|
|
|
|
|
|
const [open, setOpen] = useState(false);
|
|
const [open, setOpen] = useState(false);
|
|
|
const [menu, setMenu] = useState("");
|
|
const [menu, setMenu] = useState("");
|
|
@@ -221,9 +206,7 @@ export const getServerSideProps: GetServerSideProps<
|
|
|
}
|
|
}
|
|
|
const { slug, chapter } = context.params;
|
|
const { slug, chapter } = context.params;
|
|
|
const [chapterData] = await Promise.all([
|
|
const [chapterData] = await Promise.all([
|
|
|
- get<ChapterData>(
|
|
|
|
|
- `https://novels.yergoo.com/api/novel/chapter/${slug}/${chapter}`
|
|
|
|
|
- ),
|
|
|
|
|
|
|
+ get<ChapterData>(`/api/novel/chapter/${slug}/${chapter}`),
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
return {
|
|
return {
|