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