fix: 修复/analyze接口
This commit is contained in:
@@ -371,8 +371,8 @@ async function testConnection() {
|
|||||||
const response = await apiService.testApiConnection({
|
const response = await apiService.testApiConnection({
|
||||||
api_url: apiConfig.value.apiUrl,
|
api_url: apiConfig.value.apiUrl,
|
||||||
api_key: apiConfig.value.apiKey,
|
api_key: apiConfig.value.apiKey,
|
||||||
api_model: apiConfig.value.apiModel,
|
api_model: apiConfig.value.apiModel || undefined,
|
||||||
api_timeout: apiConfig.value.apiTimeout
|
api_timeout: parseInt(apiConfig.value.apiTimeout) || 60
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ async function analyzeStocks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 发送分析请求
|
// 发送分析请求
|
||||||
const response = await fetch('/analyze', {
|
const response = await fetch('/api/analyze', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers,
|
headers,
|
||||||
body: JSON.stringify(requestData)
|
body: JSON.stringify(requestData)
|
||||||
|
|||||||
@@ -65,14 +65,14 @@ export interface AnalyzeRequest {
|
|||||||
api_url?: string;
|
api_url?: string;
|
||||||
api_key?: string;
|
api_key?: string;
|
||||||
api_model?: string;
|
api_model?: string;
|
||||||
api_timeout?: string;
|
api_timeout?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TestApiRequest {
|
export interface TestApiRequest {
|
||||||
api_url: string;
|
api_url: string;
|
||||||
api_key: string;
|
api_key: string;
|
||||||
api_model: string;
|
api_model?: string;
|
||||||
api_timeout: string;
|
api_timeout: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TestApiResponse {
|
export interface TestApiResponse {
|
||||||
|
|||||||
@@ -17,52 +17,17 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
cors: true,
|
cors: true,
|
||||||
|
hmr: {
|
||||||
|
// 解决WebSocket连接问题
|
||||||
|
host: 'localhost',
|
||||||
|
port: 5173,
|
||||||
|
protocol: 'ws'
|
||||||
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://127.0.0.1:8888',
|
target: 'http://127.0.0.1:8888',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
}
|
||||||
},
|
|
||||||
'/analyze': {
|
|
||||||
target: 'http://127.0.0.1:8888',
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/test_api_connection': {
|
|
||||||
target: 'http://127.0.0.1:8888',
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/search_us_stocks': {
|
|
||||||
target: 'http://127.0.0.1:8888',
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/config': {
|
|
||||||
target: 'http://127.0.0.1:8888',
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/login': {
|
|
||||||
target: 'http://127.0.0.1:8888',
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/check_auth': {
|
|
||||||
target: 'http://127.0.0.1:8888',
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/need_login': {
|
|
||||||
target: 'http://127.0.0.1:8888',
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/us_stock_detail': {
|
|
||||||
target: 'http://127.0.0.1:8888',
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/fund_detail': {
|
|
||||||
target: 'http://127.0.0.1:8888',
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
'/search_funds': {
|
|
||||||
target: 'http://127.0.0.1:8888',
|
|
||||||
changeOrigin: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ else:
|
|||||||
logger.warning("前端构建目录不存在,仅API功能可用")
|
logger.warning("前端构建目录不存在,仅API功能可用")
|
||||||
|
|
||||||
# 初始化异步服务
|
# 初始化异步服务
|
||||||
# StockAnalyzerService 不需要全局初始化,在 /analyze 接口中按需创建
|
|
||||||
us_stock_service = USStockServiceAsync()
|
us_stock_service = USStockServiceAsync()
|
||||||
fund_service = FundServiceAsync()
|
fund_service = FundServiceAsync()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user