fix(frontend): 添加 regionCode 参数到算力来源 API 调用

This commit is contained in:
hailin 2026-01-21 02:13:41 -08:00
parent 495a1445fd
commit 97e974b6da
3 changed files with 25 additions and 10 deletions

View File

@ -78,15 +78,18 @@ export default function SystemAccountDetailPage() {
error: transactionsError,
} = useSystemAccountTransactions(accountType, transactionPage, pageSize);
// 获取当前账户的 regionCode
const regionCode = currentAccount?.regionCode ?? null;
// 获取算力来源明细
const {
data: contributionRecords,
isLoading: contributionLoading,
error: contributionError,
} = useSystemAccountContributionRecords(accountType, contributionPage, pageSize);
} = useSystemAccountContributionRecords(accountType, regionCode, contributionPage, pageSize);
// 获取算力明细统计
const { data: contributionStats } = useSystemAccountContributionStats(accountType);
const { data: contributionStats } = useSystemAccountContributionStats(accountType, regionCode);
const displayInfo = getAccountDisplayInfo(accountType);

View File

@ -133,12 +133,17 @@ export const systemAccountsApi = {
*/
getContributionRecords: async (
accountType: string,
regionCode: string | null,
page: number = 1,
pageSize: number = 20
): Promise<SystemContributionRecordsResponse> => {
const params: Record<string, any> = { page, pageSize };
if (regionCode) {
params.regionCode = regionCode;
}
const response = await apiClient.get(
`/system-accounts/${accountType}/contributions`,
{ params: { page, pageSize } }
{ params }
);
return response.data.data;
},
@ -147,10 +152,16 @@ export const systemAccountsApi = {
* Get system account contribution stats ()
*/
getContributionStats: async (
accountType: string
accountType: string,
regionCode: string | null
): Promise<SystemContributionStats> => {
const params: Record<string, any> = {};
if (regionCode) {
params.regionCode = regionCode;
}
const response = await apiClient.get(
`/system-accounts/${accountType}/contribution-stats`
`/system-accounts/${accountType}/contribution-stats`,
{ params }
);
return response.data.data;
},

View File

@ -82,12 +82,13 @@ export function useSystemAccountTransactions(
*/
export function useSystemAccountContributionRecords(
accountType: string,
regionCode: string | null,
page: number = 1,
pageSize: number = 20
) {
return useQuery({
queryKey: ['system-accounts', accountType, 'contributions', page, pageSize],
queryFn: () => systemAccountsApi.getContributionRecords(accountType, page, pageSize),
queryKey: ['system-accounts', accountType, regionCode, 'contributions', page, pageSize],
queryFn: () => systemAccountsApi.getContributionRecords(accountType, regionCode, page, pageSize),
enabled: !!accountType,
});
}
@ -95,10 +96,10 @@ export function useSystemAccountContributionRecords(
/**
* Hook to fetch system account contribution stats ()
*/
export function useSystemAccountContributionStats(accountType: string) {
export function useSystemAccountContributionStats(accountType: string, regionCode: string | null) {
return useQuery({
queryKey: ['system-accounts', accountType, 'contribution-stats'],
queryFn: () => systemAccountsApi.getContributionStats(accountType),
queryKey: ['system-accounts', accountType, regionCode, 'contribution-stats'],
queryFn: () => systemAccountsApi.getContributionStats(accountType, regionCode),
enabled: !!accountType,
});
}