mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
feat(xai): add Grok account management UI with four-locale strings
Add XaiOAuthSection (device-code login, account list, default selection) backed by the generalized useManagedAuth hook, wire it into the Auth Center and both Claude provider forms, and expose model fetching for signed-in accounts. - Accounts requiring re-auth stay visible in the account selector as disabled items with an expired badge instead of silently vanishing. - Auth status refetches periodically so a revoked refresh token surfaces without reloading the panel. - All strings ship in zh/en/ja/zh-TW; a locale coverage test pins every required key in all four locales.
This commit is contained in:
+5
-1
@@ -1,6 +1,9 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
export type ManagedAuthProvider = "github_copilot" | "codex_oauth";
|
||||
export type ManagedAuthProvider =
|
||||
| "github_copilot"
|
||||
| "codex_oauth"
|
||||
| "xai_oauth";
|
||||
|
||||
export interface ManagedAuthAccount {
|
||||
id: string;
|
||||
@@ -10,6 +13,7 @@ export interface ManagedAuthAccount {
|
||||
authenticated_at: number;
|
||||
is_default: boolean;
|
||||
github_domain: string;
|
||||
requires_reauth: boolean;
|
||||
}
|
||||
|
||||
export interface ManagedAuthStatus {
|
||||
|
||||
@@ -42,6 +42,15 @@ export async function fetchCodexOauthModels(
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取当前 xAI OAuth 账号可访问的模型列表。 */
|
||||
export async function fetchXaiOauthModels(
|
||||
accountId?: string | null,
|
||||
): Promise<FetchedModel[]> {
|
||||
return invoke("get_xai_oauth_models", {
|
||||
accountId: accountId || null,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据错误类型显示对应的 toast 提示
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user