Jelajahi Sumber

新增直接打开聊天页面

sunsheng 2 bulan lalu
induk
melakukan
01c2378260
4 mengubah file dengan 62 tambahan dan 40 penghapusan
  1. 2 2
      app/client/platforms/deepSeek.ts
  2. 0 1
      app/components/chat.tsx
  3. 59 37
      app/components/home.tsx
  4. 1 0
      next.config.mjs

+ 2 - 2
app/client/platforms/deepSeek.ts

@@ -22,8 +22,8 @@ export class DeepSeekApi implements LLMApi {
   constructor() {
     // this.baseURL = 'http://192.168.3.209:18078';
     this.baseURL = '/deepseek-api';
-    // this.apiPath = this.baseURL + '/vllm/ai/chat';//线上地址
-    this.apiPath = this.baseURL + '/vllm/chat'; // 测试地址 
+    this.apiPath = this.baseURL + '/vllm/ai/chat';//线上地址
+    // this.apiPath = this.baseURL + '/vllm/chat'; // 测试地址 
   }
 
   async chat(options: ChatOptions) {

+ 0 - 1
app/components/chat.tsx

@@ -2157,7 +2157,6 @@ function _Chat() {
                           </div>
                         }
                         <div className={styles["chat-message-item"]}>
-                          {JSON.stringify(message)}
                           <Markdown
                             key={message.streaming ? "loading" : "done"}
                             content={getMessageTextContent(message)}

+ 59 - 37
app/components/home.tsx

@@ -342,12 +342,14 @@ export function Home() {
     }
   }
 
-  const frameLogin = async (data: { clientId: string,
+  const frameLogin = async (data: {
+    clientId: string,
     workspaceId: string,
     workspaceName: string,
     userName: string,
     timestamp: string,
-    signature: string }, url: string,fullUrl:string) => {
+    signature: string
+  }, url: string, fullUrl: string) => {
     try {
       const res = await api.post('frame_login', data);
       localStorage.setItem('userInfo', JSON.stringify(res.data));
@@ -359,13 +361,13 @@ export function Home() {
       });
       //停留5秒
       setTimeout(() => {
-        toUninLogin(url,fullUrl);
+        toUninLogin(url, fullUrl);
       }, 5000);
 
     }
   }
 
-  const toUninLogin = async (originUrl:string, fullUrl:string) => {
+  const toUninLogin = async (originUrl: string, fullUrl: string) => {
     // return
     //测试环境
     //const loginUrl = 'https://esctest.sribs.com.cn/esc-sso/oauth2.0/authorize?client_id=e97f94cf93761f4d69e8&response_type=code';
@@ -393,6 +395,25 @@ export function Home() {
     // if (loginRes) {
     //   return localStorage.setItem('userInfo', JSON.stringify(loginRes));
     // }
+    // 如果有token就先去存数据
+    const hash = window.location.hash;
+    const queryString = hash.includes("?") ? hash.split("?")[1] : "";
+    const urlHachParams = new URLSearchParams(queryString);
+    const token = urlHachParams.get('token');
+    const nickName = urlHachParams.get('nickName');
+    const userId = urlHachParams.get('userId');
+    if(token) {
+      localStorage.setItem('userInfo', JSON.stringify({ token, nickName, userId }));
+      // 清除url中的token参数
+      if (window.history.replaceState) {
+        const cleanUrl = window.location.href.split("#")[0];
+        // http://localhost:4000/#/knowledgeChat?showMenu=true&chatMode=LOCAL&appId=2965620717148049408&userId=8&nickName=test&token=eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjQ3M2QzOWI0LTVhOGYtNGYxZS1iOGY
+        window.history.replaceState({}, document.title, `${cleanUrl}#/knowledgeChat?showMenu=true&chatMode=LOCAL&&appId=${urlHachParams.get('appId')}`);
+      }
+    }
+
+
+
     const originUrl = window.location.origin;
     const fullUrl = window.location.href;
     const urlParams = new URLSearchParams(new URL(fullUrl).search);
@@ -400,47 +421,48 @@ export function Home() {
     const state = urlParams.get('state');
     const userInfo = localStorage.getItem('userInfo');
 
+
     if (fullUrl.includes(originUrl + '/?code') && code && state) {// 通过code登陆
       if (!userInfo) {
         jkLogin({ code: code, redirectUrl: encodeURIComponent(originUrl) }, state);
       }
     } else {
 
-        //判断是否是frame方式联登/frame
-        if (fullUrl.includes(originUrl + '/?frame=Y')) {
-
-          const workspaceId = urlParams.get('workspace_id');
-          const workspaceName = urlParams.get('workspace_name');
-          const username = urlParams.get('username');
-          const clientId = urlParams.get('client_id');
-          const timestamp = urlParams.get('timestamp');
-          const signature = urlParams.get('signature');
-          if (!clientId || !workspaceId || !workspaceName || !username || !timestamp || !signature) {
-            // 处理缺失参数的情况
-            Modal.error({
-              title: '参数错误',
-              content: '缺少必要的参数',
-            });
-            //停留5秒
-            setTimeout(() => {
-              toUninLogin(originUrl,fullUrl);
-            }, 5000);
-            return;
-          }
-          frameLogin({
-            clientId: clientId,
-            workspaceId: workspaceId,
-            workspaceName: workspaceName,
-            userName: username,
-            timestamp: timestamp,
-            signature: signature
-          },originUrl,fullUrl);
-
-        } else {
-          if (!userInfo) {
+      //判断是否是frame方式联登/frame
+      if (fullUrl.includes(originUrl + '/?frame=Y')) {
+
+        const workspaceId = urlParams.get('workspace_id');
+        const workspaceName = urlParams.get('workspace_name');
+        const username = urlParams.get('username');
+        const clientId = urlParams.get('client_id');
+        const timestamp = urlParams.get('timestamp');
+        const signature = urlParams.get('signature');
+        if (!clientId || !workspaceId || !workspaceName || !username || !timestamp || !signature) {
+          // 处理缺失参数的情况
+          Modal.error({
+            title: '参数错误',
+            content: '缺少必要的参数',
+          });
+          //停留5秒
+          setTimeout(() => {
             toUninLogin(originUrl, fullUrl);
-          }
+          }, 5000);
+          return;
         }
+        frameLogin({
+          clientId: clientId,
+          workspaceId: workspaceId,
+          workspaceName: workspaceName,
+          userName: username,
+          timestamp: timestamp,
+          signature: signature
+        }, originUrl, fullUrl);
+
+      } else {
+        if (!userInfo) {
+          toUninLogin(originUrl, fullUrl);
+        }
+      }
     }
   }, []);
 

+ 1 - 0
next.config.mjs

@@ -93,6 +93,7 @@ if (mode !== "export") {
       {
         source: "/bigmodel-api/:path*",
         // destination: "http://192.168.3.3:8091/:path*",
+        // destination: "http://xia0miduo.gicp.net:8091/:path*",
         destination: "http://192.168.3.123:8091/:path*",
       },
       {