浏览代码

feat: optimize loading screen

Yifei Zhang 2 年之前
父节点
当前提交
9398b34b5c
共有 7 个文件被更改,包括 10 次插入6 次删除
  1. 1 4
      app/api/chat-stream/route.ts
  2. 1 0
      app/api/chat/route.ts
  3. 6 0
      app/components/home.module.scss
  4. 二进制
      app/favicon.ico
  5. 2 2
      app/layout.tsx
  6. 0 0
      app/styles/globals.scss
  7. 0 0
      app/styles/markdown.scss

+ 1 - 4
app/api/chat-stream/route.ts

@@ -8,8 +8,6 @@ async function createStream(payload: ReadableStream<Uint8Array>) {
   const encoder = new TextEncoder();
   const decoder = new TextDecoder();
 
-  console.log("[ChatStream]", payload);
-
   const res = await fetch("https://api.openai.com/v1/chat/completions", {
     headers: {
       "Content-Type": "application/json",
@@ -51,11 +49,10 @@ async function createStream(payload: ReadableStream<Uint8Array>) {
 
 export async function POST(req: NextRequest) {
   try {
-    console.log("Request", req);
     const stream = await createStream(req.body!);
     return new Response(stream);
   } catch (error) {
-    console.error(error);
+    console.error("[Chat Stream]", error);
   }
 }
 

+ 1 - 0
app/api/chat/route.ts

@@ -20,6 +20,7 @@ export async function POST(req: Request) {
 
     return new Response(JSON.stringify(completion.data));
   } catch (e) {
+    console.error("[Chat] ", e);
     return new Response(JSON.stringify(e));
   }
 }

+ 6 - 0
app/components/home.module.scss

@@ -338,4 +338,10 @@
 
 .export-content {
   white-space: break-spaces;
+}
+
+.loading-content {
+  display: flex;
+  justify-content: center;
+  align-items: center;
 }

二进制
app/favicon.ico


+ 2 - 2
app/layout.tsx

@@ -1,5 +1,5 @@
-import "./globals.scss";
-import "./markdown.scss";
+import "./styles/globals.scss";
+import "./styles/markdown.scss";
 
 export const metadata = {
   title: "ChatGPT Next Web",

+ 0 - 0
app/globals.scss → app/styles/globals.scss


+ 0 - 0
app/markdown.scss → app/styles/markdown.scss