fix(frontend): 添加 regionCode 参数到算力来源 API 调用
This commit is contained in:
parent
495a1445fd
commit
97e974b6da
|
|
@ -78,15 +78,18 @@ export default function SystemAccountDetailPage() {
|
||||||
error: transactionsError,
|
error: transactionsError,
|
||||||
} = useSystemAccountTransactions(accountType, transactionPage, pageSize);
|
} = useSystemAccountTransactions(accountType, transactionPage, pageSize);
|
||||||
|
|
||||||
|
// 获取当前账户的 regionCode
|
||||||
|
const regionCode = currentAccount?.regionCode ?? null;
|
||||||
|
|
||||||
// 获取算力来源明细
|
// 获取算力来源明细
|
||||||
const {
|
const {
|
||||||
data: contributionRecords,
|
data: contributionRecords,
|
||||||
isLoading: contributionLoading,
|
isLoading: contributionLoading,
|
||||||
error: contributionError,
|
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);
|
const displayInfo = getAccountDisplayInfo(accountType);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,12 +133,17 @@ export const systemAccountsApi = {
|
||||||
*/
|
*/
|
||||||
getContributionRecords: async (
|
getContributionRecords: async (
|
||||||
accountType: string,
|
accountType: string,
|
||||||
|
regionCode: string | null,
|
||||||
page: number = 1,
|
page: number = 1,
|
||||||
pageSize: number = 20
|
pageSize: number = 20
|
||||||
): Promise<SystemContributionRecordsResponse> => {
|
): Promise<SystemContributionRecordsResponse> => {
|
||||||
|
const params: Record<string, any> = { page, pageSize };
|
||||||
|
if (regionCode) {
|
||||||
|
params.regionCode = regionCode;
|
||||||
|
}
|
||||||
const response = await apiClient.get(
|
const response = await apiClient.get(
|
||||||
`/system-accounts/${accountType}/contributions`,
|
`/system-accounts/${accountType}/contributions`,
|
||||||
{ params: { page, pageSize } }
|
{ params }
|
||||||
);
|
);
|
||||||
return response.data.data;
|
return response.data.data;
|
||||||
},
|
},
|
||||||
|
|
@ -147,10 +152,16 @@ export const systemAccountsApi = {
|
||||||
* Get system account contribution stats (算力明细统计)
|
* Get system account contribution stats (算力明细统计)
|
||||||
*/
|
*/
|
||||||
getContributionStats: async (
|
getContributionStats: async (
|
||||||
accountType: string
|
accountType: string,
|
||||||
|
regionCode: string | null
|
||||||
): Promise<SystemContributionStats> => {
|
): Promise<SystemContributionStats> => {
|
||||||
|
const params: Record<string, any> = {};
|
||||||
|
if (regionCode) {
|
||||||
|
params.regionCode = regionCode;
|
||||||
|
}
|
||||||
const response = await apiClient.get(
|
const response = await apiClient.get(
|
||||||
`/system-accounts/${accountType}/contribution-stats`
|
`/system-accounts/${accountType}/contribution-stats`,
|
||||||
|
{ params }
|
||||||
);
|
);
|
||||||
return response.data.data;
|
return response.data.data;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -82,12 +82,13 @@ export function useSystemAccountTransactions(
|
||||||
*/
|
*/
|
||||||
export function useSystemAccountContributionRecords(
|
export function useSystemAccountContributionRecords(
|
||||||
accountType: string,
|
accountType: string,
|
||||||
|
regionCode: string | null,
|
||||||
page: number = 1,
|
page: number = 1,
|
||||||
pageSize: number = 20
|
pageSize: number = 20
|
||||||
) {
|
) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ['system-accounts', accountType, 'contributions', page, pageSize],
|
queryKey: ['system-accounts', accountType, regionCode, 'contributions', page, pageSize],
|
||||||
queryFn: () => systemAccountsApi.getContributionRecords(accountType, page, pageSize),
|
queryFn: () => systemAccountsApi.getContributionRecords(accountType, regionCode, page, pageSize),
|
||||||
enabled: !!accountType,
|
enabled: !!accountType,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -95,10 +96,10 @@ export function useSystemAccountContributionRecords(
|
||||||
/**
|
/**
|
||||||
* Hook to fetch system account contribution stats (算力明细统计)
|
* Hook to fetch system account contribution stats (算力明细统计)
|
||||||
*/
|
*/
|
||||||
export function useSystemAccountContributionStats(accountType: string) {
|
export function useSystemAccountContributionStats(accountType: string, regionCode: string | null) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ['system-accounts', accountType, 'contribution-stats'],
|
queryKey: ['system-accounts', accountType, regionCode, 'contribution-stats'],
|
||||||
queryFn: () => systemAccountsApi.getContributionStats(accountType),
|
queryFn: () => systemAccountsApi.getContributionStats(accountType, regionCode),
|
||||||
enabled: !!accountType,
|
enabled: !!accountType,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue