a
This commit is contained in:
parent
7847d3100b
commit
aca1cf26b7
|
|
@ -88,8 +88,6 @@ const withAccountHeaders = (headers = {}, accountIdOverride = null) => {
|
||||||
currentAccountIdFromStore = aid;
|
currentAccountIdFromStore = aid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 调试日志:记录使用的 accountId
|
|
||||||
console.log(`[API] withAccountHeaders: accountIdOverride=${accountIdOverride}, currentAccountIdFromStore=${currentAccountIdFromStore}, final accountId=${aid}`);
|
|
||||||
return withAuthHeaders({ ...headers, 'X-Account-Id': String(aid) });
|
return withAuthHeaders({ ...headers, 'X-Account-Id': String(aid) });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -137,7 +135,7 @@ export const api = {
|
||||||
|
|
||||||
// 账号管理
|
// 账号管理
|
||||||
getAccounts: async () => {
|
getAccounts: async () => {
|
||||||
const response = await fetch(buildUrl('/api/account'), { headers: withAccountHeaders() });
|
const response = await fetch(buildUrl('/api/accounts'), { headers: withAccountHeaders() });
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const error = await response.json().catch(() => ({ detail: '获取账号列表失败' }));
|
const error = await response.json().catch(() => ({ detail: '获取账号列表失败' }));
|
||||||
throw new Error(error.detail || '获取账号列表失败');
|
throw new Error(error.detail || '获取账号列表失败');
|
||||||
|
|
@ -145,7 +143,7 @@ export const api = {
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
createAccount: async (data) => {
|
createAccount: async (data) => {
|
||||||
const response = await fetch(buildUrl('/api/account'), {
|
const response = await fetch(buildUrl('/api/accounts'), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
body: JSON.stringify(data || {}),
|
body: JSON.stringify(data || {}),
|
||||||
|
|
@ -157,7 +155,7 @@ export const api = {
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
updateAccount: async (accountId, data) => {
|
updateAccount: async (accountId, data) => {
|
||||||
const response = await fetch(buildUrl(`/api/account/${accountId}`), {
|
const response = await fetch(buildUrl(`/api/accounts/${accountId}`), {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
body: JSON.stringify(data || {}),
|
body: JSON.stringify(data || {}),
|
||||||
|
|
@ -169,7 +167,7 @@ export const api = {
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
updateAccountCredentials: async (accountId, data) => {
|
updateAccountCredentials: async (accountId, data) => {
|
||||||
const response = await fetch(buildUrl(`/api/account/${accountId}/credentials`), {
|
const response = await fetch(buildUrl(`/api/accounts/${accountId}/credentials`), {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
body: JSON.stringify(data || {}),
|
body: JSON.stringify(data || {}),
|
||||||
|
|
@ -183,7 +181,7 @@ export const api = {
|
||||||
|
|
||||||
// 交易进程(按账号;需要 owner 或 admin)
|
// 交易进程(按账号;需要 owner 或 admin)
|
||||||
getAccountTradingStatus: async (accountId) => {
|
getAccountTradingStatus: async (accountId) => {
|
||||||
const response = await fetch(buildUrl(`/api/account/${accountId}/trading/status`), { headers: withAccountHeaders() })
|
const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/status`), { headers: withAccountHeaders() })
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const error = await response.json().catch(() => ({ detail: '获取交易进程状态失败' }))
|
const error = await response.json().catch(() => ({ detail: '获取交易进程状态失败' }))
|
||||||
throw new Error(error.detail || '获取交易进程状态失败')
|
throw new Error(error.detail || '获取交易进程状态失败')
|
||||||
|
|
@ -191,7 +189,7 @@ export const api = {
|
||||||
return response.json()
|
return response.json()
|
||||||
},
|
},
|
||||||
startAccountTrading: async (accountId) => {
|
startAccountTrading: async (accountId) => {
|
||||||
const response = await fetch(buildUrl(`/api/account/${accountId}/trading/start`), {
|
const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/start`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
})
|
})
|
||||||
|
|
@ -202,7 +200,7 @@ export const api = {
|
||||||
return response.json()
|
return response.json()
|
||||||
},
|
},
|
||||||
stopAccountTrading: async (accountId) => {
|
stopAccountTrading: async (accountId) => {
|
||||||
const response = await fetch(buildUrl(`/api/account/${accountId}/trading/stop`), {
|
const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/stop`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
})
|
})
|
||||||
|
|
@ -213,7 +211,7 @@ export const api = {
|
||||||
return response.json()
|
return response.json()
|
||||||
},
|
},
|
||||||
restartAccountTrading: async (accountId) => {
|
restartAccountTrading: async (accountId) => {
|
||||||
const response = await fetch(buildUrl(`/api/account/${accountId}/trading/restart`), {
|
const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/restart`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
})
|
})
|
||||||
|
|
@ -224,7 +222,7 @@ export const api = {
|
||||||
return response.json()
|
return response.json()
|
||||||
},
|
},
|
||||||
ensureAccountTradingProgram: async (accountId) => {
|
ensureAccountTradingProgram: async (accountId) => {
|
||||||
const response = await fetch(buildUrl(`/api/account/${accountId}/trading/ensure-program`), {
|
const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/ensure-program`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user