feat: 实现发送消息前余额检测
- creditsService.ts: 新增余额缓存和检测服务 - apiClient.ts: 新增 getCreditBalance() API 调用 - dialogService.ts: SSE credit_update 事件更新余额缓存 - messageHandler.ts: 发送消息前检测余额,低于5点阻止发送
This commit is contained in:
@ -224,3 +224,22 @@ export async function getUserInfo(): Promise<UserInfoResponse> {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
/** 余额查询响应 */
|
||||
export interface CreditBalanceResponse {
|
||||
success: boolean;
|
||||
balance?: number;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户资源点余额
|
||||
* GET /api/dialog/balance?userId=xxx
|
||||
*/
|
||||
export async function getCreditBalance(userId: string): Promise<CreditBalanceResponse> {
|
||||
console.log('[API] 查询余额: userId=', userId);
|
||||
return request<CreditBalanceResponse>(`/api/dialog/balance?userId=${userId}`, {
|
||||
method: 'GET',
|
||||
timeout: 5000
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user