Skip to content

Commit 0781c2c

Browse files
committed
git add Cargo.toml Cargo.lock src/core/segments/quota.rs && git commit -m "chore: update version to 1.0.12 and adapt to new API wrapper response format
- Update version from 1.0.11 to 1.0.12 - Add ApiWrapper<T> struct to handle wrapped API responses - Adapt usage API response parsing to new format - Adapt subscription API response parsing to new format - Maintain backward compatibility with existing functionality
1 parent 93d2133 commit 0781c2c

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ccometixline-88cc"
3-
version = "1.0.11"
3+
version = "1.0.12"
44
edition = "2021"
55
description = "CCometixLine (ccline) - High-performance Claude Code StatusLine tool written in Rust (88Code version)"
66
authors = ["Hobee Liu"]

src/core/segments/quota.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ use std::hash::{Hash, Hasher};
88
use std::path::PathBuf;
99
use std::time::{Duration, SystemTime};
1010

11-
// API 响应结构
11+
// API 通用包装响应结构
12+
#[derive(Debug, Deserialize)]
13+
struct ApiWrapper<T> {
14+
code: i32,
15+
msg: String,
16+
ok: bool,
17+
data: T,
18+
}
19+
20+
// Usage API 响应数据结构
1221
#[derive(Debug, Deserialize)]
1322
struct C88ApiResponse {
1423
#[serde(rename = "creditLimit")]
@@ -21,7 +30,7 @@ struct C88ApiResponse {
2130
subscription_id: Option<u32>,
2231
}
2332

24-
// 订阅 API 响应结构
33+
// 订阅信息结构
2534
#[derive(Debug, Deserialize)]
2635
struct SubscriptionResponse {
2736
id: u32,
@@ -109,7 +118,11 @@ impl SmartEndpointDetector {
109118
);
110119
}
111120

112-
response.into_json::<C88ApiResponse>().ok()
121+
// 解析包装后的响应
122+
response
123+
.into_json::<ApiWrapper<C88ApiResponse>>()
124+
.ok()
125+
.map(|wrapper| wrapper.data)
113126
} else {
114127
if debug {
115128
eprintln!(
@@ -236,9 +249,9 @@ impl QuotaSegment {
236249

237250
match result {
238251
Ok(response) if response.status() == 200 => {
239-
if let Ok(subscriptions) = response.into_json::<Vec<SubscriptionResponse>>() {
240-
// 查找匹配的订阅ID
241-
subscriptions.into_iter().find(|sub| sub.id == subscription_id)
252+
if let Ok(wrapper) = response.into_json::<ApiWrapper<Vec<SubscriptionResponse>>>() {
253+
// 从包装结构中提取数据并查找匹配的订阅ID
254+
wrapper.data.into_iter().find(|sub| sub.id == subscription_id)
242255
} else {
243256
None
244257
}

0 commit comments

Comments
 (0)