diff --git a/frontend/src/services/api.js b/frontend/src/services/api.js index 9d1383e..de3f677 100644 --- a/frontend/src/services/api.js +++ b/frontend/src/services/api.js @@ -137,7 +137,7 @@ export const api = { // 账号管理 getAccounts: async () => { - const response = await fetch(buildUrl('/api/accounts'), { headers: withAccountHeaders() }); + const response = await fetch(buildUrl('/api/account'), { headers: withAccountHeaders() }); if (!response.ok) { const error = await response.json().catch(() => ({ detail: '获取账号列表失败' })); throw new Error(error.detail || '获取账号列表失败'); @@ -145,7 +145,7 @@ export const api = { return response.json(); }, createAccount: async (data) => { - const response = await fetch(buildUrl('/api/accounts'), { + const response = await fetch(buildUrl('/api/account'), { method: 'POST', headers: withAccountHeaders({ 'Content-Type': 'application/json' }), body: JSON.stringify(data || {}), @@ -157,7 +157,7 @@ export const api = { return response.json(); }, updateAccount: async (accountId, data) => { - const response = await fetch(buildUrl(`/api/accounts/${accountId}`), { + const response = await fetch(buildUrl(`/api/account/${accountId}`), { method: 'PUT', headers: withAccountHeaders({ 'Content-Type': 'application/json' }), body: JSON.stringify(data || {}), @@ -169,7 +169,7 @@ export const api = { return response.json(); }, updateAccountCredentials: async (accountId, data) => { - const response = await fetch(buildUrl(`/api/accounts/${accountId}/credentials`), { + const response = await fetch(buildUrl(`/api/account/${accountId}/credentials`), { method: 'PUT', headers: withAccountHeaders({ 'Content-Type': 'application/json' }), body: JSON.stringify(data || {}), @@ -183,7 +183,7 @@ export const api = { // 交易进程(按账号;需要 owner 或 admin) getAccountTradingStatus: async (accountId) => { - const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/status`), { headers: withAccountHeaders() }) + const response = await fetch(buildUrl(`/api/account/${accountId}/trading/status`), { headers: withAccountHeaders() }) if (!response.ok) { const error = await response.json().catch(() => ({ detail: '获取交易进程状态失败' })) throw new Error(error.detail || '获取交易进程状态失败') @@ -191,7 +191,7 @@ export const api = { return response.json() }, startAccountTrading: async (accountId) => { - const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/start`), { + const response = await fetch(buildUrl(`/api/account/${accountId}/trading/start`), { method: 'POST', headers: withAccountHeaders({ 'Content-Type': 'application/json' }), }) @@ -202,7 +202,7 @@ export const api = { return response.json() }, stopAccountTrading: async (accountId) => { - const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/stop`), { + const response = await fetch(buildUrl(`/api/account/${accountId}/trading/stop`), { method: 'POST', headers: withAccountHeaders({ 'Content-Type': 'application/json' }), }) @@ -213,7 +213,7 @@ export const api = { return response.json() }, restartAccountTrading: async (accountId) => { - const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/restart`), { + const response = await fetch(buildUrl(`/api/account/${accountId}/trading/restart`), { method: 'POST', headers: withAccountHeaders({ 'Content-Type': 'application/json' }), }) @@ -224,7 +224,7 @@ export const api = { return response.json() }, ensureAccountTradingProgram: async (accountId) => { - const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/ensure-program`), { + const response = await fetch(buildUrl(`/api/account/${accountId}/trading/ensure-program`), { method: 'POST', headers: withAccountHeaders({ 'Content-Type': 'application/json' }), }) @@ -410,7 +410,7 @@ export const api = { // 补挂止盈止损(交易所保护单) ensurePositionSLTP: async (symbol) => { - const response = await fetch(buildUrl(`/api/accounts/positions/${symbol}/sltp/ensure`), { + const response = await fetch(buildUrl(`/api/account/positions/${symbol}/sltp/ensure`), { method: 'POST', headers: withAccountHeaders({ 'Content-Type': 'application/json' }), }); @@ -422,7 +422,7 @@ export const api = { }, ensureAllPositionsSLTP: async (limit = 50) => { - const response = await fetch(buildUrl(`/api/accounts/positions/sltp/ensure-all?limit=${encodeURIComponent(limit)}`), { + const response = await fetch(buildUrl(`/api/account/positions/sltp/ensure-all?limit=${encodeURIComponent(limit)}`), { method: 'POST', headers: withAccountHeaders({ 'Content-Type': 'application/json' }), }); @@ -435,7 +435,7 @@ export const api = { // 同步持仓状态 syncPositions: async () => { - const response = await fetch(buildUrl('/api/accounts/positions/sync'), { + const response = await fetch(buildUrl('/api/account/positions/sync'), { method: 'POST', headers: { ...withAccountHeaders({ 'Content-Type': 'application/json' }),