feat:回答流式输出

This commit is contained in:
shijing 2026-07-15 13:17:22 +08:00
parent 2c9da6bf6d
commit b128b3c2ac
3 changed files with 17 additions and 6 deletions

View File

@ -92,8 +92,9 @@ export function useChat() {
data_url: a.data_url, data_url: a.data_url,
})) }))
messages.value.push({ role: 'user', text: trimmed, attachments: localAttachments, created_at: now }) messages.value.push({ role: 'user', text: trimmed, attachments: localAttachments, created_at: now })
const assistant = { role: 'assistant', text: '', references: [], created_at: now } messages.value.push({ role: 'assistant', text: '', references: [], created_at: now })
messages.value.push(assistant) // 拿数组里的响应式代理直接改原始对象绕过代理不会触发更新SSE delta 会一直不动
const assistant = messages.value[messages.value.length - 1]
streaming.value = true streaming.value = true
try { try {

View File

@ -3,8 +3,13 @@ import { computed, ref } from 'vue'
import { notify } from '@/utils/notify' import { notify } from '@/utils/notify'
export const useAppStore = defineStore('app', () => { export const useAppStore = defineStore('app', () => {
const defaultApiBase = import.meta.env.DEV ? 'http://127.0.0.1:8775' : window.location.origin const defaultApiBase = import.meta.env.DEV ? '' : window.location.origin
const apiBase = ref(localStorage.getItem('financeAiApiBase') || defaultApiBase) 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 token = ref(localStorage.getItem('financeAiToken') || '')
const currentUser = ref(null) const currentUser = ref(null)
const healthy = ref(false) const healthy = ref(false)

View File

@ -14,9 +14,14 @@ export default defineConfig({
port: 5173, port: 5173,
proxy: { proxy: {
'/api': { '/api': {
target: 'http://127.0.0.1:8775', target: 'https://127.0.0.1:8775',
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''), secure: false,
},
'/health': {
target: 'https://127.0.0.1:8775',
changeOrigin: true,
secure: false,
}, },
}, },
}, },