fix: use relative API paths instead of hardcoded localhost
This commit is contained in:
parent
d5d1343d01
commit
90a55d8d5d
|
|
@ -169,7 +169,7 @@ const parsedNodes = computed(() => {
|
|||
|
||||
const fetchNodes = async () => {
|
||||
try {
|
||||
const res = await axios.get('http://127.0.0.1:8000/context_nodes/')
|
||||
const res = await axios.get('/context_nodes/')
|
||||
nodes.value = res.data
|
||||
} catch (error) {
|
||||
message.error('获取认知节点失败')
|
||||
|
|
@ -178,7 +178,7 @@ const fetchNodes = async () => {
|
|||
|
||||
const createNode = async () => {
|
||||
try {
|
||||
const res = await axios.post('http://127.0.0.1:8000/context_nodes/', formValue.value)
|
||||
const res = await axios.post('/context_nodes/', formValue.value)
|
||||
message.success('认知已提交!')
|
||||
nodes.value.push(res.data)
|
||||
showModal.value = false
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ const getStatusLabel = (status: string) => {
|
|||
|
||||
const fetchExperiments = async () => {
|
||||
try {
|
||||
const res = await axios.get('http://127.0.0.1:8000/experiments/')
|
||||
const res = await axios.get('/experiments/')
|
||||
experiments.value = res.data
|
||||
} catch (error) {
|
||||
message.error('获取实验列表失败')
|
||||
|
|
@ -106,7 +106,7 @@ const fetchExperiments = async () => {
|
|||
|
||||
const fetchContextNodes = async () => {
|
||||
try {
|
||||
const res = await axios.get('http://127.0.0.1:8000/context_nodes/')
|
||||
const res = await axios.get('/context_nodes/')
|
||||
contextNodes.value = res.data
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch context nodes')
|
||||
|
|
@ -120,7 +120,7 @@ const openModal = () => {
|
|||
|
||||
const createExperiment = async () => {
|
||||
try {
|
||||
const res = await axios.post('http://127.0.0.1:8000/experiments/', formValue.value)
|
||||
const res = await axios.post('/experiments/', formValue.value)
|
||||
message.success('实验已启动!')
|
||||
experiments.value.push(res.data)
|
||||
showModal.value = false
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ const selectProvider = (value: string) => {
|
|||
const testConnection = async () => {
|
||||
testing.value = true
|
||||
try {
|
||||
const response = await axios.get(`${config.ollama_host.replace(':11434', ':8000')}/ai/status`, { timeout: 5000 })
|
||||
const response = await axios.get(`/ai/status`, { timeout: 5000 })
|
||||
if (response.data.status === 'ready') {
|
||||
isConnected.value = true
|
||||
statusText.value = `${response.data.model_count} 个模型`
|
||||
|
|
@ -251,7 +251,7 @@ const testConnection = async () => {
|
|||
|
||||
const loadConfig = async () => {
|
||||
try {
|
||||
const response = await axios.get('http://127.0.0.1:8000/ai/config')
|
||||
const response = await axios.get('/ai/config')
|
||||
config.provider = response.data.provider
|
||||
config.ollama_host = response.data.ollama_host
|
||||
} catch {}
|
||||
|
|
@ -260,7 +260,7 @@ const loadConfig = async () => {
|
|||
const saveConfig = async () => {
|
||||
saving.value = true
|
||||
try {
|
||||
await axios.post('http://127.0.0.1:8000/ai/config', {
|
||||
await axios.post('/ai/config', {
|
||||
provider: config.provider,
|
||||
deepseek_api_key: config.deepseek_api_key || undefined,
|
||||
openai_api_key: config.openai_api_key || undefined,
|
||||
|
|
@ -284,7 +284,7 @@ const resetConfig = () => {
|
|||
|
||||
const restartBackend = async () => {
|
||||
try {
|
||||
await axios.post('http://127.0.0.1:8000/ai/stop')
|
||||
await axios.post('/ai/stop')
|
||||
saveStatus.value = '后端已停止,请手动启动'
|
||||
showRestartModal.value = false
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -1186,7 +1186,7 @@ const submitFeedback = async (agreed: boolean) => {
|
|||
const aiPrediction = currentStrategicInfo.value.is_strategic
|
||||
const userFeedback = agreed ? aiPrediction : !aiPrediction
|
||||
|
||||
const response = await axios.post(`http://127.0.0.1:8000/signals/${selectedSignal.value.id}/feedback`, {
|
||||
const response = await axios.post(`/signals/${selectedSignal.value.id}/feedback`, {
|
||||
signal_id: selectedSignal.value.id,
|
||||
was_strategic: userFeedback,
|
||||
reason: agreed ? 'AI判断准确' : 'AI判断不准确'
|
||||
|
|
@ -1447,7 +1447,7 @@ watch(selectedSignal, (newVal, oldVal) => {
|
|||
// Load existing feedback for a signal
|
||||
const loadSignalFeedback = async (signalId: string) => {
|
||||
try {
|
||||
const response = await axios.get(`http://127.0.0.1:8000/signals/${signalId}/feedbacks`)
|
||||
const response = await axios.get(`/signals/${signalId}/feedbacks`)
|
||||
if (response.data && response.data.length > 0) {
|
||||
const latestFeedback = response.data[0]
|
||||
signalFeedback.value = latestFeedback
|
||||
|
|
@ -1505,7 +1505,7 @@ const isNewSignal = (signal: any) => {
|
|||
const fetchSignals = async (isPoll = false) => {
|
||||
if (!isPoll) loading.value = true
|
||||
try {
|
||||
const res = await axios.get('http://127.0.0.1:8000/signals/')
|
||||
const res = await axios.get('/signals/')
|
||||
const newSignals = res.data
|
||||
|
||||
// Check for task status updates if polling
|
||||
|
|
@ -1579,7 +1579,7 @@ const submitSignal = async () => {
|
|||
if (!formValue.value.content) return
|
||||
submitting.value = true
|
||||
try {
|
||||
const res = await axios.post('http://127.0.0.1:8000/signals/ingest', formValue.value)
|
||||
const res = await axios.post('/signals/ingest', formValue.value)
|
||||
message.success('信号已注入,战略评估完成!')
|
||||
showModal.value = false
|
||||
await fetchSignals()
|
||||
|
|
@ -1590,7 +1590,7 @@ const submitSignal = async () => {
|
|||
}
|
||||
|
||||
// 停止 Ollama 节省资源
|
||||
await axios.post('http://127.0.0.1:8000/ai/stop')
|
||||
await axios.post('/ai/stop')
|
||||
ollamaReady.value = false
|
||||
message.info('🌱 Ollama 已停止,节省资源')
|
||||
} catch (error) {
|
||||
|
|
@ -1603,7 +1603,7 @@ const submitSignal = async () => {
|
|||
// 检查 AI 服务状态
|
||||
const checkOllamaStatus = async () => {
|
||||
try {
|
||||
const response = await axios.get('http://127.0.0.1:8000/ai/status', { timeout: 3000 })
|
||||
const response = await axios.get('/ai/status', { timeout: 3000 })
|
||||
|
||||
const data = response.data
|
||||
providerType.value = data.provider_type || 'cloud'
|
||||
|
|
@ -1634,7 +1634,7 @@ const checkOllamaStatus = async () => {
|
|||
const startOllama = async () => {
|
||||
startingOllama.value = true
|
||||
try {
|
||||
const response = await axios.post('http://127.0.0.1:8000/ai/start')
|
||||
const response = await axios.post('/ai/start')
|
||||
|
||||
if (response.data.status === 'already_running') {
|
||||
message.info('Ollama 已在运行')
|
||||
|
|
@ -1660,7 +1660,7 @@ const startOllama = async () => {
|
|||
// 停止本地 Ollama
|
||||
const stopOllama = async () => {
|
||||
try {
|
||||
await axios.post('http://127.0.0.1:8000/ai/stop')
|
||||
await axios.post('/ai/stop')
|
||||
ollamaReady.value = false
|
||||
message.success('✅ Ollama 已停止,内存已释放')
|
||||
} catch (error) {
|
||||
|
|
@ -1691,7 +1691,7 @@ const startAnalysis = async () => {
|
|||
|
||||
// 调用后端获取并分析信号
|
||||
analysisStatus.value = '正在获取 HackerNews 信号...'
|
||||
const response = await axios.post('http://127.0.0.1:8000/signals/fetch')
|
||||
const response = await axios.post('/signals/fetch')
|
||||
|
||||
clearInterval(progressInterval)
|
||||
analysisProgress.value = 100
|
||||
|
|
@ -1708,7 +1708,7 @@ const startAnalysis = async () => {
|
|||
// 仅本地 Ollama 需要停止节省资源
|
||||
if (providerType.value === 'local') {
|
||||
analysisStatus.value = '正在停止 Ollama...'
|
||||
await axios.post('http://127.0.0.1:8000/ai/stop')
|
||||
await axios.post('/ai/stop')
|
||||
ollamaReady.value = false
|
||||
analysisStatus.value = `完成!Ollama 已停止`
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue