Przeglądaj źródła

处理部署页面路由问题

masoft 2 miesięcy temu
rodzic
commit
ecf2c3662a

+ 5 - 4
web/package.json

@@ -3,12 +3,13 @@
   "version": "0.1.0",
   "private": true,
   "scripts": {
-    "export": "next export",
-    "dev": "next dev",
+    "dev": "next dev -p 6688",
     "build": "next build",
     "start": "next start",
-    "lint": "next lint",
-    "format": "prettier --write ."
+    "lint": "eslint src --fix --ext .ts,.tsx,.js,.jsx --max-warnings 0",
+    "pre-commit": "lint-staged",
+    "commitlint": "commitlint --config commitlint.config.cjs -e -V",
+    "release": "release-it"
   },
   "dependencies": {
     "@ant-design/pro-chat": "^1.15.3",

Plik diff jest za duży
+ 0 - 0
web/public/sw.js


+ 11 - 26
web/src/app/dialogue/page.tsx

@@ -3,7 +3,7 @@ import { getApiUrl, isMobile } from "@/utils/common";
 import { getUserSession } from "@/utils/user";
 import { useState, useEffect } from "react";
 import type { PopconfirmProps } from "antd";
-import { theme, Popconfirm, Button, Card, Result } from "antd";
+import { message, theme, Popconfirm, Button, Card, Result } from "antd";
 import { ThemeProvider, css, cx } from "antd-style";
 import { useTheme } from "next-themes";
 import { ProChat, ProChatInstance } from "@ant-design/pro-chat";
@@ -243,17 +243,18 @@ export default function Dialogue() {
   };
   //重命名聊天会话
   const renameChatSessionUi = (id: string, name: string) => {
+    setChatSessionRenameId("");
+    setRename("");
+    setChatSessionList(
+      chatSessionList.map((v) => (v.id === id ? { ...v, name: name } : v))
+    );
     renameChatSession({
       conversationId: id,
       agentId: Storage_getAgentId(),
       name: name,
     }).then((res) => {
       if (res.code == 0) {
-        setChatSessionList(
-          chatSessionList.map((v) => (v.id === id ? { ...v, name: name } : v))
-        );
-        setChatSessionRenameId("");
-        setRename("");
+        //message.success("会话重命名成功!");
       }
     });
   };
@@ -419,15 +420,6 @@ export default function Dialogue() {
     setShowVip(false);
   };
 
-  const NeedBuyVip = () => {
-    return (
-      <>
-        当前智能体需要会员才能使用,去开通:
-        <a onClick={() => setShowVip(true)}>会员套餐</a>
-      </>
-    );
-  };
-
   return (
     <>
       <div className="flex justify-between items-center bg-[slate-200] dark:bg-[#000] h-full">
@@ -523,7 +515,7 @@ export default function Dialogue() {
                                 }
                               />
 
-                              {chatSessionRenameId && (
+                              {chatSessionRenameId === item.id && (
                                 <p>
                                   <input
                                     value={rename}
@@ -541,7 +533,7 @@ export default function Dialogue() {
                                   />
                                 </p>
                               )}
-                              {!chatSessionRenameId && (
+                              {chatSessionRenameId !== item.id && (
                                 <h2
                                   className="pb-2"
                                   onClick={() => changeChatSession(item.id)}
@@ -716,13 +708,6 @@ export default function Dialogue() {
                     justify: "space-start",
                   },
                 }}
-                chatItemRenderConfig={{
-                  contentRender: (item) => {
-                    if (item?.originData?.role === "need_pay") {
-                      return <NeedBuyVip />;
-                    }
-                  },
-                }}
                 request={async (messages) => {
                   const response = await fetch(
                     getApiUrl() + "/gpts/chat/submit",
@@ -791,7 +776,7 @@ export default function Dialogue() {
                                   } else if (parsed.need_pay) {
                                     controller.enqueue(
                                       encoder.encode(
-                                        "当前智能体需要会员才能使用"
+                                        "当前智能体需要会员才能使用,去开通:[会员套餐](/vip.html)"
                                       )
                                     );
                                     setTimeout(() => {setShowVip(true);}, 200);
@@ -897,7 +882,7 @@ export default function Dialogue() {
         )}
       </div>
 
-      {showLeftBox && (
+      {showLeftBox && isMobile() && (
         <div className="pay-box">
           <div className="pay-mask"></div>
           <div className="pay-div md:p-7 bg-white dark:bg-gray-900 text-base rounded w-full md:container h-screen">

+ 8 - 5
web/src/app/layout.tsx

@@ -1,3 +1,4 @@
+import { NextUIProvider } from "@nextui-org/react";
 import { Inter } from "next/font/google";
 import type { Metadata, Viewport } from "next";
 import "./globals.scss";
@@ -16,7 +17,7 @@ export const metadata: Metadata = {
     icon: "/favicon.ico",
     shortcut: "/favicon-16x16.png",
     apple: "/apple-touch-icon.png",
-  }
+  },
 };
 
 export const viewport: Viewport = {
@@ -32,11 +33,13 @@ export default function RootLayout({
   children: React.ReactNode;
 }>) {
   return (
-    <html suppressHydrationWarning={true}>
+    <html suppressHydrationWarning>
       <body className={inter.className}>
-        <GlobalProvider>
-          <ThemeProvider>{children}</ThemeProvider>
-        </GlobalProvider>
+        <NextUIProvider>
+          <GlobalProvider>
+            <ThemeProvider>{children}</ThemeProvider>
+          </GlobalProvider>
+        </NextUIProvider>
       </body>
     </html>
   );

+ 1 - 1
web/src/app/page.tsx

@@ -80,7 +80,7 @@ export default function Home() {
     Storage_setListType(1);
     Storage_setAgentId(id);
     Storage_setConversationId("");
-    router.push("/dialogue");
+    router.push("/dialogue.html");
   };
 
   const [isFocused, setIsFocused] = useState(false);

+ 6 - 1
web/src/app/user-center/page.tsx

@@ -1,5 +1,6 @@
 "use client";
 import { useRef, useState, useEffect } from "react";
+import { useRouter } from "next/navigation";
 import { message, Tabs } from "antd";
 import { css, cx } from "antd-style";
 import { getUserInfo,updateUserInfo, userPassword, getUserBalance } from "@/api/client";
@@ -13,6 +14,7 @@ import {
 } from "react-icons/ri";
 
 const UserCenter = () => {
+  const router = useRouter();
   const themeBig = useTheme();
   const { changeMenuIndex,uploadUserInfoState, changeUploadUserInfoState } = useGlobalContext();
   const [userName, setUserName] = useState<string>("");
@@ -95,6 +97,9 @@ const UserCenter = () => {
         setPhone(data.data.mobile);
         setEmail(data.data.email);
       }
+      else{
+        router.push("/")
+      }
     });
     getUserBalance().then((data) => {
       if (data.code == 0) {
@@ -224,7 +229,7 @@ const UserCenter = () => {
                               会员套餐购买
                             </h2>
                             <p className="text-gray-500 mt-3">
-                              <a href="/vip">去购买</a>
+                              <a href="/vip.html">去购买</a>
                             </p>
                           </div>
                         </div>

+ 1 - 1
web/src/components/Header/index.tsx

@@ -39,7 +39,7 @@ export default function Header({ name }: { name: string }) {
       <div className="flex justify-between items-center grow-0 shrink-0">
         {isLogin && (
           <a
-            onClick={() => router.push("/user-center")}
+            onClick={() => router.push("/user-center.html")}
             className="cursor-pointer ease-in-out p-2 rounded-md text-gray-700 dark:text-gray-200 hover:text-gray-900 dark:hover:text-white hover:bg-gray-50 dark:hover:bg-gray-800"
           >
             {nickName}

+ 3 - 3
web/src/components/Menu/index.tsx

@@ -17,7 +17,7 @@ export default function Header() {
                 ? "bg-blue-50 dark:bg-blue-950 text-[#0061ff]"
                 : "text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-50 dark:hover:bg-gray-800"
             } cursor-pointer`}
-            onClick={() => router.push("/dialogue")}
+            onClick={() => router.push("/dialogue.html")}
           >
             <Image
               src="/icons/icon-talk.svg"
@@ -49,7 +49,7 @@ export default function Header() {
                 ? "bg-blue-50 dark:bg-blue-950 text-[#0061ff]"
                 : "text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-50 dark:hover:bg-gray-800"
             } cursor-pointer`}
-            onClick={() => router.push("/vip")}
+            onClick={() => router.push("/vip.html")}
           >
             <Image
               src="/icons/icon-vip.svg"
@@ -65,7 +65,7 @@ export default function Header() {
                 ? "bg-blue-50 dark:bg-blue-950 text-[#0061ff]"
                 : "text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-50 dark:hover:bg-gray-800"
             } cursor-pointer`}
-            onClick={() => router.push("/help")}
+            onClick={() => router.push("/help.html")}
           >
             <Image
               src="/icons/icon-question.svg"

+ 3 - 3
web/src/components/Menu_H5/index.tsx

@@ -11,7 +11,7 @@ export default function Header() {
     <>
       <div className="fixed bottom-0 left-0 right-0 py-1 bg-[#ffffff] dark:bg-[#202123] shadow-2xl shadow-black z-50">
         <div className="flex justify-around items-center py-1 text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-50 dark:hover:bg-gray-800 text-center text-sm">
-          <a className={menuIndex == 1 ? "bg-blue-50 dark:bg-blue-950 text-[#0061ff] rounded px-3":"px-3"} onClick={() => router.push("/dialogue")}>
+          <a className={menuIndex == 1 ? "bg-blue-50 dark:bg-blue-950 text-[#0061ff] rounded px-3":"px-3"} onClick={() => router.push("/dialogue.html")}>
             <Image
               src="/icons/icon-talk.svg"
               alt="聊天"
@@ -29,7 +29,7 @@ export default function Header() {
             />
             <p className="text-sm text-center py-1">应用</p>
           </a>
-          <a className={menuIndex == 3 ? "bg-blue-50 dark:bg-blue-950 text-[#0061ff] rounded px-3":"px-3"} onClick={() => router.push("/vip")}>
+          <a className={menuIndex == 3 ? "bg-blue-50 dark:bg-blue-950 text-[#0061ff] rounded px-3":"px-3"} onClick={() => router.push("/vip.html")}>
             <Image
               src="/icons/icon-vip.svg"
               alt="会员"
@@ -38,7 +38,7 @@ export default function Header() {
             />
             <p className="text-sm text-center py-1">会员</p>
           </a>
-          <a className={menuIndex == 4 ? "bg-blue-50 dark:bg-blue-950 text-[#0061ff] rounded px-3":"px-3"} onClick={() => router.push("/help")}>
+          <a className={menuIndex == 4 ? "bg-blue-50 dark:bg-blue-950 text-[#0061ff] rounded px-3":"px-3"} onClick={() => router.push("/help.html")}>
             <Image
               src="/icons/icon-question.svg"
               alt="帮助"

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików