Compare commits
5 Commits
cc4aff80af
...
ee4937b56b
| Author | SHA1 | Date | |
|---|---|---|---|
| ee4937b56b | |||
| 9558e84409 | |||
| e634d68b53 | |||
| 1192e5c518 | |||
| d9c7da8ef9 |
2
.env
2
.env
@ -1,2 +1,2 @@
|
||||
# API配置
|
||||
VUE_APP_API_BASE_URL=http://localhost:8000
|
||||
VUE_APP_API_BASE_URL=/api/
|
||||
@ -96,6 +96,7 @@ async def search_instances_v2(
|
||||
for row in results:
|
||||
hourly_price = float(row['price'])
|
||||
gp3_price = float(row['gp3'])
|
||||
gp2_price = float(row['gp2'])
|
||||
monthly_price = hourly_price * 730 # 730小时/月
|
||||
|
||||
# 计算存储价格
|
||||
@ -109,7 +110,7 @@ async def search_instances_v2(
|
||||
break
|
||||
|
||||
# disk_monthly_price = await calculate_ebs_price(region_code, disk_gb) if region_code else 0
|
||||
disk_monthly_price = gp3_price * disk_gb
|
||||
disk_monthly_price = gp3_price * disk_gb if gp3_price > 0 else gp2_price * disk_gb
|
||||
|
||||
# 计算总价格
|
||||
total_monthly_price = monthly_price + disk_monthly_price
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
# 生产环境API配置
|
||||
VUE_APP_API_BASE_URL=http://calc.buddyscloud.com:8000
|
||||
VUE_APP_API_BASE_URL=/api
|
||||
@ -41,7 +41,7 @@ const apiService = {
|
||||
// 获取区域列表
|
||||
getRegions: async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/api/regions')
|
||||
const response = await apiClient.get('/regions')
|
||||
return response.data
|
||||
} catch (error) {
|
||||
console.error('获取区域列表失败:', error)
|
||||
@ -52,7 +52,7 @@ const apiService = {
|
||||
// 获取实例类型列表
|
||||
getInstanceTypes: async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/api/instance-types')
|
||||
const response = await apiClient.get('/instance-types')
|
||||
return response.data
|
||||
} catch (error) {
|
||||
console.error('获取实例类型列表失败:', error)
|
||||
@ -63,7 +63,7 @@ const apiService = {
|
||||
// 搜索实例
|
||||
searchInstances: async (params) => {
|
||||
try {
|
||||
const response = await apiClient.post('/api/search-instances-v2', params)
|
||||
const response = await apiClient.post('/search-instances-v2', params)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
console.error('搜索实例失败:', error)
|
||||
@ -74,7 +74,7 @@ const apiService = {
|
||||
// 计算价格
|
||||
calculatePrice: async (params) => {
|
||||
try {
|
||||
const response = await apiClient.post('/api/calculate-price', params)
|
||||
const response = await apiClient.post('/calculate-price', params)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
console.error('计算价格失败:', error)
|
||||
@ -85,7 +85,7 @@ const apiService = {
|
||||
// 比较价格
|
||||
comparePrices: async (params) => {
|
||||
try {
|
||||
const response = await apiClient.post('/api/compare-prices', params)
|
||||
const response = await apiClient.post('/compare-prices', params)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
console.error('比较价格失败:', error)
|
||||
@ -96,7 +96,7 @@ const apiService = {
|
||||
// 获取预算估算
|
||||
getBudgetEstimate: async (params) => {
|
||||
try {
|
||||
const response = await apiClient.post('/api/budget', params)
|
||||
const response = await apiClient.post('/budget', params)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
console.error('获取预算估算失败:', error)
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
// API 配置文件
|
||||
const config = {
|
||||
// 后端API基础URL - 从环境变量中读取,如果不存在则使用默认值
|
||||
apiBaseUrl: process.env.VUE_APP_API_BASE_URL || 'http://localhost:8000',
|
||||
// 后端API基础URL 使用相对路径,通过 devServer 代理到后端
|
||||
// apiBaseUrl: process.env.VUE_APP_API_BASE_URL ,
|
||||
apiBaseUrl: '/api',
|
||||
|
||||
|
||||
// 其他全局配置
|
||||
defaultRegion: 'us-east-1',
|
||||
|
||||
16
frontend/vue.config.js
Normal file
16
frontend/vue.config.js
Normal file
@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
devServer: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://127.0.0.1:8000',
|
||||
changeOrigin: true,
|
||||
ws: false,
|
||||
secure: false,
|
||||
// 保留 /api 前缀并转发到后端 FastAPI(后端已以 /api 为前缀)
|
||||
pathRewrite: { '^/api': '/api' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user