mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-31 02:51:21 +08:00
95c917b337
智谱团队套餐(Team Plan)的额度查询与个人版不同:同一 quota 端点加 `?type=2`,需额外 `bigmodel-organization` / `bigmodel-project` 请求头 (api_key + 组织 ID + 项目 ID 三者缺一不可),且仅存在于国内站 open.bigmodel.cn。参考 token-monitor/src/shared/zaiTeamLimits.js 实现。 - Backend (services/coding_plan.rs): 新增 query_zhipu_team(固定 CN 站、 ?type=2、org/project 头);抽出 zhipu_quota_from_body 与个人版共用解析; 入口 get_coding_plan_quota 靠显式 coding_plan_provider == "zhipu_team" 路由(base_url 与个人版智谱相同,detect_provider 无法区分)。新字段经 UsageScript、IPC 命令、后台查询路径(query_provider_usage_inner)透传。 - Frontend: UsageScriptModal 新增「Zhipu GLM Team」选项 + 组织/项目 ID 输入;模板切换时保留 team 字段;测试与保存逻辑按 team 传参。 - i18n: en/zh/zh-TW/ja 四个 locale 更新。 - Tests: 凭据校验/路由(缺任一凭据 → NotFound,标识大小写不敏感)+ 本地 server 验证 ?type=2 与 org/project 请求头形状。 Co-authored-by: XuZhanXin <1239576606@qq.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
900 B
Rust
26 lines
900 B
Rust
use crate::services::subscription::SubscriptionQuota;
|
|
|
|
#[tauri::command]
|
|
pub async fn get_coding_plan_quota(
|
|
base_url: String,
|
|
api_key: String,
|
|
// 火山方舟用控制面 AK/SK 签名查询用量;其他供应商不传,沿用 api_key。
|
|
access_key_id: Option<String>,
|
|
secret_access_key: Option<String>,
|
|
// 智谱团队版(zhipu_team)靠显式标识路由(base_url 与个人版相同无法区分)。
|
|
coding_plan_provider: Option<String>,
|
|
team_organization_id: Option<String>,
|
|
team_project_id: Option<String>,
|
|
) -> Result<SubscriptionQuota, String> {
|
|
crate::services::coding_plan::get_coding_plan_quota(
|
|
&base_url,
|
|
&api_key,
|
|
access_key_id.as_deref(),
|
|
secret_access_key.as_deref(),
|
|
coding_plan_provider.as_deref(),
|
|
team_organization_id.as_deref(),
|
|
team_project_id.as_deref(),
|
|
)
|
|
.await
|
|
}
|