mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-29 18:05:37 +08:00
feat(tray): show coding-plan usage for Kimi / Zhipu / MiniMax
dc04165f surfaced tray usage badges for Claude/Codex/Gemini official
OAuth only. Chinese coding-plan providers already expose 5h + weekly
windows through coding_plan::get_coding_plan_quota, but two gaps kept
the tray from rendering them.
- format_script_summary read only data.first(), truncating the tier-
flattened UsageResult to a single window. Detect plan_name matching
TIER_FIVE_HOUR / TIER_WEEKLY_LIMIT and emit the "🟢 h12% w80%" layout
used by format_subscription_summary; worst utilization drives the
emoji. Copilot / balance / custom scripts keep the legacy single-
bucket output via fallback.
- usage_script previously required manual activation through
UsageScriptModal. Auto-inject meta.usage_script on Claude provider
creation when ANTHROPIC_BASE_URL matches a known coding plan, so the
tray lights up without the user opening the modal. Does not overwrite
existing usage_script on update.
Extract the URL route table out of UsageScriptModal into a shared
codingPlanProviders module so the modal, the creation hook, and the
Rust coding_plan::detect_provider mirror all agree on one list.
Add TIER_WEEKLY_LIMIT alongside TIER_FIVE_HOUR and a createUsageScript()
factory to collapse the duplicated default fields across four call
sites and drop the remaining stringly-typed tier names.
This commit is contained in:
@@ -74,6 +74,20 @@ export interface UsageScript {
|
||||
};
|
||||
}
|
||||
|
||||
const DEFAULT_USAGE_SCRIPT: UsageScript = {
|
||||
enabled: false,
|
||||
language: "javascript",
|
||||
code: "",
|
||||
timeout: 10,
|
||||
autoQueryInterval: 5,
|
||||
};
|
||||
|
||||
export function createUsageScript(
|
||||
overrides?: Partial<UsageScript>,
|
||||
): UsageScript {
|
||||
return { ...DEFAULT_USAGE_SCRIPT, ...overrides };
|
||||
}
|
||||
|
||||
// 单个套餐用量数据
|
||||
export interface UsageData {
|
||||
planName?: string; // 套餐名称(可选)
|
||||
|
||||
Reference in New Issue
Block a user