diff --git a/frontend/src/composables/useChat.js b/frontend/src/composables/useChat.js index 4f0e1ce..a0de07e 100644 --- a/frontend/src/composables/useChat.js +++ b/frontend/src/composables/useChat.js @@ -92,8 +92,9 @@ export function useChat() { data_url: a.data_url, })) messages.value.push({ role: 'user', text: trimmed, attachments: localAttachments, created_at: now }) - const assistant = { role: 'assistant', text: '', references: [], created_at: now } - messages.value.push(assistant) + messages.value.push({ role: 'assistant', text: '', references: [], created_at: now }) + // 拿数组里的响应式代理,直接改原始对象绕过代理不会触发更新,SSE delta 会一直不动 + const assistant = messages.value[messages.value.length - 1] streaming.value = true try { diff --git a/frontend/src/stores/app.js b/frontend/src/stores/app.js index d8fdf60..61dab0d 100644 --- a/frontend/src/stores/app.js +++ b/frontend/src/stores/app.js @@ -3,8 +3,13 @@ import { computed, ref } from 'vue' import { notify } from '@/utils/notify' export const useAppStore = defineStore('app', () => { - const defaultApiBase = import.meta.env.DEV ? 'http://127.0.0.1:8775' : window.location.origin - const apiBase = ref(localStorage.getItem('financeAiApiBase') || defaultApiBase) + const defaultApiBase = import.meta.env.DEV ? '' : window.location.origin + const storedApiBase = localStorage.getItem('financeAiApiBase') + const legacyDevBases = new Set(['http://127.0.0.1:8775', 'https://127.0.0.1:8775']) + const initialApiBase = import.meta.env.DEV && legacyDevBases.has(storedApiBase) + ? defaultApiBase + : (storedApiBase ?? defaultApiBase) + const apiBase = ref(initialApiBase) const token = ref(localStorage.getItem('financeAiToken') || '') const currentUser = ref(null) const healthy = ref(false) diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 8fedb6b..2ceea40 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -14,9 +14,14 @@ export default defineConfig({ port: 5173, proxy: { '/api': { - target: 'http://127.0.0.1:8775', + target: 'https://127.0.0.1:8775', changeOrigin: true, - rewrite: (path) => path.replace(/^\/api/, ''), + secure: false, + }, + '/health': { + target: 'https://127.0.0.1:8775', + changeOrigin: true, + secure: false, }, }, },