Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions plugin/lib/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [同步]: mystatus.ts, types.ts, utils.ts, i18n.ts
*/

import { existsSync } from "fs";
import { readFile } from "fs/promises";
import { homedir } from "os";
import { join } from "path";
Expand Down Expand Up @@ -301,10 +302,16 @@ function formatAccountQuota(quotaInfo: AccountQuotaInfo): string {
* 查询所有 Antigravity 账号的额度
* @returns 查询结果
*/
export async function queryGoogleUsage(): Promise<QueryResult> {
export async function queryGoogleUsage(): Promise<QueryResult | null> {
const accountsPath = getAntigravityAccountsPath();

if (!existsSync(accountsPath)) {
return null;
}

try {
// 读取账号文件
const content = await readFile(getAntigravityAccountsPath(), "utf-8");
const content = await readFile(accountsPath, "utf-8");
const file = JSON.parse(content) as AntigravityAccountsFile;

if (!file.accounts || file.accounts.length === 0) {
Expand Down