Jelajahi Sumber

Update:更新readme

XieXing 3 bulan lalu
induk
melakukan
fe2e919bb9
1 mengubah file dengan 19 tambahan dan 6 penghapusan
  1. 19 6
      shudao-vue-frontend/src/utils/api.js

+ 19 - 6
shudao-vue-frontend/src/utils/api.js

@@ -4,6 +4,7 @@
  */
 import request from './authRequest'
 import { buildApiUrl, REPORT_API_PREFIX } from './apiConfig'
+import { getToken } from './auth'
 
 /**
  * 用户登录
@@ -80,11 +81,17 @@ export function getLoginLogs(params = {}) {
  */
 export async function stopSSEStream(userId, aiConversationId) {
   try {
+    const token = getToken()
+    const headers = {
+      'Content-Type': 'application/json'
+    }
+    if (token) {
+      headers['Authorization'] = `Bearer ${token}`
+    }
+    
     const response = await fetch(buildApiUrl('/sse/stop', REPORT_API_PREFIX), {
       method: 'POST',
-      headers: {
-        'Content-Type': 'application/json'
-      },
+      headers,
       body: JSON.stringify({
         // ===== 已删除:user_id - 后端从token解析 =====
         ai_conversation_id: aiConversationId
@@ -139,11 +146,17 @@ export async function stopSSEStream(userId, aiConversationId) {
  */
 export async function updateAIMessageContent(aiMessageId, content) {
   try {
+    const token = getToken()
+    const headers = {
+      'Content-Type': 'application/json'
+    }
+    if (token) {
+      headers['Authorization'] = `Bearer ${token}`
+    }
+    
     const response = await fetch(buildApiUrl('/report/update-ai-message', REPORT_API_PREFIX), {
       method: 'POST',
-      headers: {
-        'Content-Type': 'application/json'
-      },
+      headers,
       body: JSON.stringify({
         ai_message_id: aiMessageId,
         content: content