Kaynağa Gözat

修复websocket连接的bug

zhupei 1 yıl önce
ebeveyn
işleme
db7426e213
4 değiştirilmiş dosya ile 13 ekleme ve 5 silme
  1. 2 0
      public/config.js
  2. 2 2
      src/ajax/api/agent.js
  3. 5 2
      src/ajax/api/message.js
  4. 4 1
      src/ajax/api/user.js

+ 2 - 0
public/config.js

@@ -3,6 +3,8 @@
  */
 window.__IFRAME_URL_CHUJUAN = 'http://192.168.20.119:8501'
 
+window.WEBSOCKET_BASE_URL = location.host;
+
 /**
  * 小数绘图 -> ComfyUI -> iframe弹窗地址
  */

+ 2 - 2
src/ajax/api/agent.js

@@ -5,8 +5,8 @@ import request from "../request";
  * @returns {Promise<Object>}
  */
 const getAgents = () => {
-    return request.get("/api/agent/list");
-    // return request.get("/api/user/menus");
+    // return request.get("/api/agent/list");
+    return request.get("/api/user/menus");
 };
 
 /**

+ 5 - 2
src/ajax/api/message.js

@@ -1,10 +1,13 @@
 import request from "../request";
 const create = (token, agentId, dialogId, type) => {
+    const socket_url = window.WEBSOCKET_BASE_URL;
+
   const wsParam = type === "report" ? "report" : "chat";
   const wsUrl =
     type === "excel"
-      ? `ws://${location.host}/api/document/ws/excel`
-      : `ws://${location.host}/api/${wsParam}/ws/${agentId}/${dialogId}?token=${token}`;
+      ? `ws://${socket_url}/api/document/ws/excel`
+      : `ws://${socket_url}/api/${wsParam}/ws/${agentId}/${dialogId}?token=${token}`;
+
   const ws = new WebSocket(wsUrl);
   // 当 WebSocket 打开时...
   ws.onopen = function (event) {

+ 4 - 1
src/ajax/api/user.js

@@ -15,7 +15,10 @@ const getInfo = () => {
  * @returns {Promise<Object>}
  */
 const login = (username, password) => {
-    return request.post("/api/auth/login", {
+    // const url = "/api/auth/login";
+    const url = "/api/auth/v2/login";
+
+    return request.post(url, {
         username,
         password
     });