cc-pets 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Sources/CCPets/CCPetsAppDelegate.m +0 -9
- package/Sources/CCPets/CCPetsPreviews.m +0 -1
- package/Sources/CCPets/CCPetsQuotaHistory.h +1 -1
- package/Sources/CCPets/CCPetsQuotaHistory.m +0 -1
- package/Sources/CCPets/PetView.m +0 -5
- package/Sources/CCPets/QuotaDashboardView.h +0 -1
- package/Sources/CCPets/QuotaDashboardView.m +9 -11
- package/package.json +1 -1
|
@@ -252,14 +252,6 @@ static void TrimUpdateLog(NSString *path) {
|
|
|
252
252
|
}];
|
|
253
253
|
[task resume];
|
|
254
254
|
}
|
|
255
|
-
- (void)toggleQuotaHistory:(NSButton *)sender {
|
|
256
|
-
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
|
|
257
|
-
BOOL enabled = ![defaults boolForKey:HistoryEnabledKey];
|
|
258
|
-
[defaults setBool:enabled forKey:HistoryEnabledKey];
|
|
259
|
-
sender.state = enabled ? NSControlStateValueOn : NSControlStateValueOff;
|
|
260
|
-
self.quotaView.historyEnabled = enabled;
|
|
261
|
-
[self refreshUsage:nil];
|
|
262
|
-
}
|
|
263
255
|
- (NSString *)systemMetricKeyForTag:(NSInteger)tag {
|
|
264
256
|
if (tag == 1) return SystemCPUEnabledKey;
|
|
265
257
|
if (tag == 2) return SystemTemperatureEnabledKey;
|
|
@@ -907,7 +899,6 @@ static void TrimUpdateLog(NSString *path) {
|
|
|
907
899
|
glass.layer.masksToBounds = YES;
|
|
908
900
|
[quotaRoot addSubview:glass];
|
|
909
901
|
self.quotaView = [[QuotaDashboardView alloc] initWithFrame:NSMakeRect(0, 0, quotaSize.width, quotaSize.height)];
|
|
910
|
-
self.quotaView.historyEnabled = [defaults boolForKey:HistoryEnabledKey];
|
|
911
902
|
[self applySystemMetricPreferences];
|
|
912
903
|
self.quotaView.codexLogo = OfficialAppIcon(@"com.openai.codex", @"icon-chatgpt.icns");
|
|
913
904
|
self.quotaView.claudeLogo = OfficialAppIcon(@"com.anthropic.claudefordesktop", @"electron.icns");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// 本地额度历史始终记录并展示。
|
|
4
4
|
// RecordQuotaHistory 返回当前文档,调用方直接复用,避免一轮刷新里重复读盘。
|
|
5
5
|
NSDictionary *QuotaHistoryDocument(void);
|
|
6
6
|
NSDictionary *RecordQuotaHistory(NSDictionary *codexUsage, NSDictionary *claudeUsage);
|
|
@@ -39,7 +39,6 @@ static NSDictionary *HistoryProviderSample(NSDictionary *usage, NSString *usedKe
|
|
|
39
39
|
// (这里一次、两条曲线各一次),现在整轮只读一次。
|
|
40
40
|
NSDictionary *RecordQuotaHistory(NSDictionary *codexUsage, NSDictionary *claudeUsage) {
|
|
41
41
|
NSDictionary *document = QuotaHistoryDocument();
|
|
42
|
-
if (![NSUserDefaults.standardUserDefaults boolForKey:HistoryEnabledKey]) return document;
|
|
43
42
|
NSDictionary *codex = HistoryProviderSample(codexUsage, @"used_percent");
|
|
44
43
|
NSDictionary *claude = HistoryProviderSample(claudeUsage, @"used_percentage");
|
|
45
44
|
if (codex.count == 0 && claude.count == 0) return document;
|
package/Sources/CCPets/PetView.m
CHANGED
|
@@ -509,11 +509,6 @@ static const CGFloat PetDragThreshold = 3.0;
|
|
|
509
509
|
checked:[NSUserDefaults.standardUserDefaults boolForKey:StatusBubbleExpandedKey]
|
|
510
510
|
action:@selector(toggleStatusBubbleFromMenu:)
|
|
511
511
|
tag:0];
|
|
512
|
-
[self addPersistentSwitchToMenu:menu
|
|
513
|
-
title:@"记录本地额度历史"
|
|
514
|
-
checked:[NSUserDefaults.standardUserDefaults boolForKey:HistoryEnabledKey]
|
|
515
|
-
action:@selector(toggleQuotaHistory:)
|
|
516
|
-
tag:0];
|
|
517
512
|
[self addPersistentSwitchToMenu:menu
|
|
518
513
|
title:@"导入 Codex 素材"
|
|
519
514
|
checked:[NSUserDefaults.standardUserDefaults boolForKey:ImportCodexPetsKey]
|
|
@@ -12,7 +12,6 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName);
|
|
|
12
12
|
@property NSDictionary *claudeUsage;
|
|
13
13
|
@property NSArray<NSDictionary *> *codexHistory;
|
|
14
14
|
@property NSArray<NSDictionary *> *claudeHistory;
|
|
15
|
-
@property BOOL historyEnabled;
|
|
16
15
|
@property NSInteger activeAgentCount;
|
|
17
16
|
// 仍在运行的客户端所属的 provider("Codex" / "Claude")。卡片的在线徽章据此判定,
|
|
18
17
|
// 而不是看有没有额度数据——额度会一直缓存着,拿它当在线信号会恒亮。
|
|
@@ -297,17 +297,15 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
297
297
|
NSTimeInterval now = NSDate.date.timeIntervalSince1970;
|
|
298
298
|
NSTimeInterval cutoff = now - 7 * 24 * 60 * 60;
|
|
299
299
|
NSMutableArray<NSDictionary *> *points = [NSMutableArray array];
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
[points addObject:@{@"timestamp": timestamp, @"used": @(used)}];
|
|
310
|
-
}
|
|
300
|
+
for (NSDictionary *sample in history) {
|
|
301
|
+
if (![sample isKindOfClass:NSDictionary.class]) continue;
|
|
302
|
+
NSNumber *timestamp = [sample[@"timestamp"] isKindOfClass:NSNumber.class]
|
|
303
|
+
? sample[@"timestamp"] : nil;
|
|
304
|
+
NSNumber *remaining = [sample[@"remaining"] isKindOfClass:NSNumber.class]
|
|
305
|
+
? sample[@"remaining"] : nil;
|
|
306
|
+
if (!timestamp || !remaining || timestamp.doubleValue < cutoff) continue;
|
|
307
|
+
double used = 100.0 - fmax(0, fmin(100, remaining.doubleValue));
|
|
308
|
+
[points addObject:@{@"timestamp": timestamp, @"used": @(used)}];
|
|
311
309
|
}
|
|
312
310
|
// 终点必须和卡片上的当前官方额度同源;历史落盘最多会慢 15 分钟,不能直接拿它
|
|
313
311
|
// 冒充“当前”,否则同一张卡里会出现两个不同百分比。
|