mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-02 08:19:59 +00:00
feat(ui): add pause/resume API hooks
- add api.cliproxy.accounts.pause/resume methods - add usePauseAccount, useResumeAccount hooks Refs #282
This commit is contained in:
@@ -118,6 +118,40 @@ export function useRemoveAccount() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function usePauseAccount() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({ provider, accountId }: { provider: string; accountId: string }) =>
|
||||||
|
api.cliproxy.accounts.pause(provider, accountId),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['cliproxy-accounts'] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['cliproxy-auth'] });
|
||||||
|
toast.success('Account paused');
|
||||||
|
},
|
||||||
|
onError: (error: Error) => {
|
||||||
|
toast.error(error.message);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useResumeAccount() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({ provider, accountId }: { provider: string; accountId: string }) =>
|
||||||
|
api.cliproxy.accounts.resume(provider, accountId),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['cliproxy-accounts'] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['cliproxy-auth'] });
|
||||||
|
toast.success('Account resumed');
|
||||||
|
},
|
||||||
|
onError: (error: Error) => {
|
||||||
|
toast.error(error.message);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// OAuth flow hook
|
// OAuth flow hook
|
||||||
export function useStartAuth() {
|
export function useStartAuth() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|||||||
@@ -71,11 +71,18 @@ export interface UpdateVariant {
|
|||||||
export interface OAuthAccount {
|
export interface OAuthAccount {
|
||||||
id: string;
|
id: string;
|
||||||
email?: string;
|
email?: string;
|
||||||
|
nickname?: string;
|
||||||
provider: 'gemini' | 'codex' | 'agy' | 'qwen' | 'iflow' | 'kiro' | 'ghcp';
|
provider: 'gemini' | 'codex' | 'agy' | 'qwen' | 'iflow' | 'kiro' | 'ghcp';
|
||||||
isDefault: boolean;
|
isDefault: boolean;
|
||||||
tokenFile: string;
|
tokenFile: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
lastUsedAt?: string;
|
lastUsedAt?: string;
|
||||||
|
/** Whether account is paused (skipped in quota rotation) */
|
||||||
|
paused?: boolean;
|
||||||
|
/** ISO timestamp when account was paused */
|
||||||
|
pausedAt?: string;
|
||||||
|
/** Account tier: free, pro, ultra */
|
||||||
|
tier?: 'free' | 'pro' | 'ultra' | 'unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthStatus {
|
export interface AuthStatus {
|
||||||
@@ -392,6 +399,16 @@ export const api = {
|
|||||||
}),
|
}),
|
||||||
remove: (provider: string, accountId: string) =>
|
remove: (provider: string, accountId: string) =>
|
||||||
request(`/cliproxy/auth/accounts/${provider}/${accountId}`, { method: 'DELETE' }),
|
request(`/cliproxy/auth/accounts/${provider}/${accountId}`, { method: 'DELETE' }),
|
||||||
|
pause: (provider: string, accountId: string) =>
|
||||||
|
request<{ provider: string; accountId: string; paused: boolean }>(
|
||||||
|
`/cliproxy/auth/accounts/${provider}/${accountId}/pause`,
|
||||||
|
{ method: 'POST' }
|
||||||
|
),
|
||||||
|
resume: (provider: string, accountId: string) =>
|
||||||
|
request<{ provider: string; accountId: string; paused: boolean }>(
|
||||||
|
`/cliproxy/auth/accounts/${provider}/${accountId}/resume`,
|
||||||
|
{ method: 'POST' }
|
||||||
|
),
|
||||||
},
|
},
|
||||||
// OAuth flow
|
// OAuth flow
|
||||||
auth: {
|
auth: {
|
||||||
|
|||||||
Reference in New Issue
Block a user