Leo 3 年之前
父节点
当前提交
91130d4537
共有 2 个文件被更改,包括 16 次插入4 次删除
  1. 1 1
      ecosystem.config.js
  2. 15 3
      pages/novel/[slug]/[chapter].tsx

+ 1 - 1
ecosystem.config.js

@@ -2,7 +2,7 @@ module.exports = {
   apps: [
     {
       name: "novel",
-      script: "next dev",
+      script: "next start",
       instances: "max",
       env: {
         NODE_ENV: "production",

+ 15 - 3
pages/novel/[slug]/[chapter].tsx

@@ -11,15 +11,27 @@ import Toolbar from "../../../components/novel/Toolbar";
 import Settings from "../../../components/novel/Settings";
 
 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 useSWR from "swr";
+
+interface ChapterData {
+  chapter: "";
+  content: "";
+  errmsg: "ok";
+  errno: 10000;
+  next: "";
+  pre: "";
+  title: "";
+}
 
 const Chapter: NextPageWithLayout = () => {
   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>(
   //   `/api/novel/chapter/${query.slug}/${query.chapter}`