cc-pets 1.0.3 → 1.0.5
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/CHANGELOG.md +19 -0
- package/README.md +42 -5
- package/Sources/CCPets/CCPetsAppDelegate.h +8 -2
- package/Sources/CCPets/CCPetsAppDelegate.m +118 -11
- package/Sources/CCPets/CCPetsCleanup.h +7 -0
- package/Sources/CCPets/CCPetsCleanup.m +126 -0
- package/Sources/CCPets/CCPetsImageLoader.h +4 -0
- package/Sources/CCPets/CCPetsImageLoader.m +36 -0
- package/Sources/CCPets/CCPetsPaths.h +1 -0
- package/Sources/CCPets/CCPetsPaths.m +6 -4
- package/Sources/CCPets/CCPetsPreviews.m +20 -2
- package/Sources/CCPets/CCPetsUsage.h +10 -0
- package/Sources/CCPets/CCPetsUsage.m +694 -22
- package/Sources/CCPets/CCPetsUsageMonitor.h +10 -0
- package/Sources/CCPets/CCPetsUsageMonitor.m +167 -0
- package/Sources/CCPets/PetView.h +3 -1
- package/Sources/CCPets/PetView.m +40 -7
- package/Sources/CCPets/QuotaDashboardView.h +8 -0
- package/Sources/CCPets/QuotaDashboardView.m +222 -142
- package/Sources/CCPets/main.m +4 -0
- package/bin/cc-pets +5 -0
- package/package.json +1 -1
- package/scripts/build.sh +2 -0
- package/scripts/uninstall-app.sh +9 -0
- package/scripts/uninstall-shell-integration.sh +50 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#import "QuotaDashboardView.h"
|
|
2
2
|
|
|
3
|
-
const CGFloat QuotaLogicalWidth =
|
|
4
|
-
const CGFloat QuotaLogicalHeight =
|
|
5
|
-
const CGFloat QuotaScale = 0.
|
|
3
|
+
const CGFloat QuotaLogicalWidth = 760;
|
|
4
|
+
const CGFloat QuotaLogicalHeight = 590;
|
|
5
|
+
const CGFloat QuotaScale = 0.58;
|
|
6
6
|
|
|
7
7
|
NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
8
8
|
NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:bundleIdentifier];
|
|
@@ -92,19 +92,68 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
92
92
|
id value = usage[key];
|
|
93
93
|
return [value isKindOfClass:NSDictionary.class] ? value : nil;
|
|
94
94
|
}
|
|
95
|
-
- (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return
|
|
95
|
+
- (NSDictionary *)tokenTotals:(NSDictionary *)usage key:(NSString *)key {
|
|
96
|
+
NSDictionary *tokenUsage = [usage[@"tokenUsage"] isKindOfClass:NSDictionary.class]
|
|
97
|
+
? usage[@"tokenUsage"] : nil;
|
|
98
|
+
return [tokenUsage[key] isKindOfClass:NSDictionary.class] ? tokenUsage[key] : nil;
|
|
99
99
|
}
|
|
100
|
-
- (NSString *)
|
|
101
|
-
NSNumber *
|
|
102
|
-
|
|
100
|
+
- (NSString *)formattedTokenCount:(NSDictionary *)totals {
|
|
101
|
+
NSNumber *number = [totals[@"total_tokens"] isKindOfClass:NSNumber.class]
|
|
102
|
+
? totals[@"total_tokens"] : nil;
|
|
103
|
+
if (!number) return @"--";
|
|
104
|
+
double value = number.doubleValue;
|
|
105
|
+
if (value >= 1000000000) return [NSString stringWithFormat:@"%.2fB", value / 1000000000.0];
|
|
106
|
+
if (value >= 1000000) return [NSString stringWithFormat:@"%.2fM", value / 1000000.0];
|
|
107
|
+
if (value >= 1000) return [NSString stringWithFormat:@"%.1fK", value / 1000.0];
|
|
108
|
+
return [NSString stringWithFormat:@"%.0f", value];
|
|
109
|
+
}
|
|
110
|
+
// 两个窗口共用。resets_at 是整分对齐的,带秒只会多占宽度。
|
|
111
|
+
- (NSString *)resetText:(NSDictionary *)quota {
|
|
112
|
+
NSNumber *reset = [quota[@"resets_at"] isKindOfClass:NSNumber.class] ? quota[@"resets_at"] : nil;
|
|
113
|
+
if (!reset) return @"--";
|
|
103
114
|
NSDateFormatter *formatter = [NSDateFormatter new];
|
|
104
115
|
formatter.locale = [NSLocale localeWithLocaleIdentifier:@"zh_CN"];
|
|
105
116
|
formatter.timeZone = NSTimeZone.localTimeZone;
|
|
106
|
-
formatter.dateFormat = @"M/d HH:mm
|
|
107
|
-
return [formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:
|
|
117
|
+
formatter.dateFormat = @"M/d HH:mm";
|
|
118
|
+
return [formatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:reset.doubleValue]];
|
|
119
|
+
}
|
|
120
|
+
// 在线 = 这一家还有活着的客户端,和有没有额度数据无关:额度会一直缓存着,
|
|
121
|
+
// 拿它当在线信号会恒亮。身份不明的老客户端无法归属到某一家,保守地都算在线。
|
|
122
|
+
- (BOOL)isProviderOnline:(NSString *)name {
|
|
123
|
+
return [self.liveProviders containsObject:name] || self.hasUnlabeledClient;
|
|
124
|
+
}
|
|
125
|
+
- (NSColor *)primaryColor { return [NSColor colorWithWhite:0.97 alpha:1]; }
|
|
126
|
+
- (NSColor *)secondaryColor { return [NSColor colorWithWhite:0.68 alpha:1]; }
|
|
127
|
+
- (NSColor *)accentColor { return [NSColor colorWithRed:0.30 green:0.82 blue:0.90 alpha:1]; }
|
|
128
|
+
// 有 Agent 在线才用绿色,否则整块转灰,避免"暂无 Agent 在线"配一个绿点。
|
|
129
|
+
- (NSColor *)agentStatusColor {
|
|
130
|
+
return self.activeAgentCount > 0 ? NSColor.systemGreenColor : self.secondaryColor;
|
|
131
|
+
}
|
|
132
|
+
// 汇总条展示两个 Provider 的合计,任一侧缺数据时按 0 计入,两侧都没有才显示 `--`。
|
|
133
|
+
// 只能传自然日口径的 key(today / recentWeek):两家的订阅窗口起止并不一致,
|
|
134
|
+
// 按各自 resets_at 算出来的数不在同一区间上,相加得不到任何有意义的量。
|
|
135
|
+
- (NSDictionary *)combinedTokens:(NSString *)key {
|
|
136
|
+
NSDictionary *codex = [self tokenTotals:self.codexUsage key:key];
|
|
137
|
+
NSDictionary *claude = [self tokenTotals:self.claudeUsage key:key];
|
|
138
|
+
NSNumber *codexTotal = [codex[@"total_tokens"] isKindOfClass:NSNumber.class]
|
|
139
|
+
? codex[@"total_tokens"] : nil;
|
|
140
|
+
NSNumber *claudeTotal = [claude[@"total_tokens"] isKindOfClass:NSNumber.class]
|
|
141
|
+
? claude[@"total_tokens"] : nil;
|
|
142
|
+
if (!codexTotal && !claudeTotal) return @{};
|
|
143
|
+
return @{@"total_tokens": @(codexTotal.unsignedLongLongValue +
|
|
144
|
+
claudeTotal.unsignedLongLongValue)};
|
|
145
|
+
}
|
|
146
|
+
- (NSNumber *)usedForQuota:(NSDictionary *)quota usedKey:(NSString *)usedKey {
|
|
147
|
+
NSNumber *used = [quota[usedKey] isKindOfClass:NSNumber.class] ? quota[usedKey] : nil;
|
|
148
|
+
return used ? @(fmax(0, fmin(100, used.doubleValue))) : nil;
|
|
149
|
+
}
|
|
150
|
+
- (NSString *)refreshAgeText {
|
|
151
|
+
if (self.lastUpdatedAt <= 0) return @"等待数据";
|
|
152
|
+
NSTimeInterval age = fmax(0, NSDate.date.timeIntervalSince1970 - self.lastUpdatedAt);
|
|
153
|
+
if (age < 5) return @"刚刚";
|
|
154
|
+
if (age < 60) return [NSString stringWithFormat:@"%.0f 秒前", age];
|
|
155
|
+
if (age < 3600) return [NSString stringWithFormat:@"%.0f 分钟前", floor(age / 60)];
|
|
156
|
+
return [NSString stringWithFormat:@"%.0f 小时前", floor(age / 3600)];
|
|
108
157
|
}
|
|
109
158
|
- (NSDictionary *)textAttributesWithSize:(CGFloat)size color:(NSColor *)color weight:(NSFontWeight)weight {
|
|
110
159
|
return @{NSFontAttributeName: [NSFont systemFontOfSize:size weight:weight],
|
|
@@ -121,131 +170,122 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
121
170
|
[color setFill];
|
|
122
171
|
[[NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius] fill];
|
|
123
172
|
}
|
|
124
|
-
- (void)
|
|
173
|
+
- (void)drawUsageBars:(NSArray<NSNumber *> *)series inRect:(NSRect)rect color:(NSColor *)color {
|
|
174
|
+
// 柱高按 0–100% 绝对映射,低用量时上半截会空着。补一层底框把空白说明成刻度,
|
|
175
|
+
// 否则看起来像没画完。
|
|
176
|
+
[self fillRoundedRect:rect radius:4 color:[NSColor colorWithWhite:1 alpha:0.05]];
|
|
125
177
|
if (!self.historyEnabled || series.count == 0) return;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
CGFloat
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
CGFloat
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
else [line lineToPoint:point];
|
|
136
|
-
if (series.count == 1) {
|
|
137
|
-
[[color colorWithAlphaComponent:0.9] setFill];
|
|
138
|
-
[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(point.x - 2, point.y - 2, 4, 4)] fill];
|
|
139
|
-
}
|
|
178
|
+
NSUInteger visibleCount = MIN((NSUInteger)14, series.count);
|
|
179
|
+
CGFloat gap = 4;
|
|
180
|
+
CGFloat width = (NSWidth(rect) - gap * (visibleCount - 1)) / visibleCount;
|
|
181
|
+
for (NSUInteger index = 0; index < visibleCount; index++) {
|
|
182
|
+
NSNumber *remaining = series[series.count - visibleCount + index];
|
|
183
|
+
CGFloat used = 100.0 - fmax(0, fmin(100, remaining.doubleValue));
|
|
184
|
+
CGFloat height = fmax(3, NSHeight(rect) * used / 100.0);
|
|
185
|
+
NSRect bar = NSMakeRect(NSMinX(rect) + index * (width + gap), NSMinY(rect), width, height);
|
|
186
|
+
[self fillRoundedRect:bar radius:2 color:[color colorWithAlphaComponent:0.85]];
|
|
140
187
|
}
|
|
141
|
-
line.lineWidth = 2;
|
|
142
|
-
line.lineJoinStyle = NSLineJoinStyleRound;
|
|
143
|
-
line.lineCapStyle = NSLineCapStyleRound;
|
|
144
|
-
[[color colorWithAlphaComponent:0.9] setStroke];
|
|
145
|
-
[line stroke];
|
|
146
188
|
}
|
|
147
189
|
- (void)drawProvider:(NSString *)name usage:(NSDictionary *)usage usedKey:(NSString *)usedKey
|
|
148
190
|
color:(NSColor *)color cardRect:(NSRect)card {
|
|
149
|
-
NSColor *primary =
|
|
150
|
-
NSColor *secondary =
|
|
151
|
-
NSColor *track = [NSColor colorWithWhite:0.28 alpha:0.55];
|
|
191
|
+
NSColor *primary = self.primaryColor;
|
|
192
|
+
NSColor *secondary = self.secondaryColor;
|
|
152
193
|
NSDictionary *five = [self quota:usage key:@"fiveHour"];
|
|
153
194
|
NSDictionary *week = [self quota:usage key:@"week"];
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
195
|
+
NSDictionary *fiveTokens = [self tokenTotals:usage key:@"fiveHour"];
|
|
196
|
+
NSDictionary *weekTokens = [self tokenTotals:usage key:@"week"];
|
|
197
|
+
NSNumber *fiveUsed = [self usedForQuota:five usedKey:usedKey];
|
|
198
|
+
NSNumber *weekUsed = [self usedForQuota:week usedKey:usedKey];
|
|
199
|
+
BOOL hasData = fiveUsed || weekUsed || fiveTokens || weekTokens;
|
|
200
|
+
BOOL online = [self isProviderOnline:name];
|
|
157
201
|
|
|
158
|
-
NSBezierPath *cardPath = [NSBezierPath bezierPathWithRoundedRect:card xRadius:
|
|
202
|
+
NSBezierPath *cardPath = [NSBezierPath bezierPathWithRoundedRect:card xRadius:18 yRadius:18];
|
|
159
203
|
NSGradient *cardGlass = [[NSGradient alloc]
|
|
160
|
-
initWithStartingColor:[NSColor colorWithWhite:1 alpha:0.
|
|
161
|
-
endingColor:[
|
|
162
|
-
[cardGlass drawInBezierPath:cardPath angle:-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
[[NSColor
|
|
170
|
-
|
|
171
|
-
|
|
204
|
+
initWithStartingColor:[NSColor colorWithWhite:1 alpha:0.085]
|
|
205
|
+
endingColor:[color colorWithAlphaComponent:0.025]];
|
|
206
|
+
[cardGlass drawInBezierPath:cardPath angle:-25];
|
|
207
|
+
[[NSColor colorWithWhite:1 alpha:0.18] setStroke];
|
|
208
|
+
cardPath.lineWidth = 1;
|
|
209
|
+
[cardPath stroke];
|
|
210
|
+
|
|
211
|
+
NSArray<NSNumber *> *separators = @[@(NSMinX(card) + 190), @(NSMinX(card) + 370),
|
|
212
|
+
@(NSMinX(card) + 540)];
|
|
213
|
+
[[NSColor colorWithWhite:1 alpha:0.10] setStroke];
|
|
214
|
+
for (NSNumber *value in separators) {
|
|
215
|
+
[NSBezierPath strokeLineFromPoint:NSMakePoint(value.doubleValue, NSMinY(card) + 14)
|
|
216
|
+
toPoint:NSMakePoint(value.doubleValue, NSMaxY(card) - 14)];
|
|
217
|
+
}
|
|
172
218
|
|
|
173
|
-
NSRect icon = NSMakeRect(NSMinX(card) +
|
|
219
|
+
NSRect icon = NSMakeRect(NSMinX(card) + 28, NSMinY(card) + 53, 54, 54);
|
|
174
220
|
NSImage *logo = [name isEqualToString:@"Codex"] ? self.codexLogo : self.claudeLogo;
|
|
175
221
|
if (logo) {
|
|
176
222
|
[NSGraphicsContext saveGraphicsState];
|
|
177
|
-
[[NSBezierPath bezierPathWithRoundedRect:icon xRadius:
|
|
223
|
+
[[NSBezierPath bezierPathWithRoundedRect:icon xRadius:14 yRadius:14] addClip];
|
|
178
224
|
[logo drawInRect:icon fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0
|
|
179
225
|
respectFlipped:YES hints:@{NSImageHintInterpolation: @(NSImageInterpolationHigh)}];
|
|
180
226
|
[NSGraphicsContext restoreGraphicsState];
|
|
181
227
|
} else {
|
|
182
|
-
[self fillRoundedRect:icon radius:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
withAttributes:[self centeredTextAttributesWithSize:20 color:NSColor.whiteColor weight:NSFontWeightBold]];
|
|
228
|
+
[self fillRoundedRect:icon radius:14 color:[color colorWithAlphaComponent:0.7]];
|
|
229
|
+
[name drawInRect:NSInsetRect(icon, 4, 17)
|
|
230
|
+
withAttributes:[self centeredTextAttributesWithSize:13 color:NSColor.whiteColor weight:NSFontWeightBold]];
|
|
186
231
|
}
|
|
232
|
+
[name drawInRect:NSMakeRect(NSMinX(card) + 94, NSMinY(card) + 84, 88, 30)
|
|
233
|
+
withAttributes:[self textAttributesWithSize:22 color:primary weight:NSFontWeightBold]];
|
|
234
|
+
// 三态:没有任何额度数据 → 等待数据;有数据但客户端已退出 → 离线;两者都有 → 在线。
|
|
235
|
+
NSString *statusText = !hasData ? @"等待数据" : (online ? @"● 在线" : @"离线");
|
|
236
|
+
NSColor *statusColor = online && hasData ? NSColor.systemGreenColor : secondary;
|
|
237
|
+
NSDictionary *statusAttributes = [self textAttributesWithSize:11 color:statusColor
|
|
238
|
+
weight:NSFontWeightMedium];
|
|
239
|
+
CGFloat statusWidth = ceil([statusText sizeWithAttributes:statusAttributes].width) + 18;
|
|
240
|
+
NSRect status = NSMakeRect(NSMinX(card) + 94, NSMinY(card) + 55, statusWidth, 24);
|
|
241
|
+
[self fillRoundedRect:status radius:12 color:[statusColor colorWithAlphaComponent:0.13]];
|
|
242
|
+
[statusText drawInRect:NSInsetRect(status, 9, 4) withAttributes:statusAttributes];
|
|
187
243
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
[
|
|
244
|
+
// 层级:官方剩余额度是订阅限额的权威值,占主位;本机 Token 是参考量,降一级并用
|
|
245
|
+
// 强调色区分;重置时间最小。反过来会让最抢眼的数字恰好是最不该照着做决定的那个。
|
|
246
|
+
NSArray<NSDictionary *> *windows = @[
|
|
247
|
+
@{@"x": @(NSMinX(card) + 214), @"title": @"5 小时", @"quota": five ?: @{},
|
|
248
|
+
@"tokens": fiveTokens ?: @{}, @"used": fiveUsed ?: NSNull.null},
|
|
249
|
+
@{@"x": @(NSMinX(card) + 394), @"title": @"7 天", @"quota": week ?: @{},
|
|
250
|
+
@"tokens": weekTokens ?: @{}, @"used": weekUsed ?: NSNull.null}
|
|
251
|
+
];
|
|
252
|
+
for (NSDictionary *window in windows) {
|
|
253
|
+
CGFloat x = [window[@"x"] doubleValue];
|
|
254
|
+
[window[@"title"] drawInRect:NSMakeRect(x, NSMinY(card) + 114, 130, 20)
|
|
255
|
+
withAttributes:[self textAttributesWithSize:13 color:secondary weight:NSFontWeightRegular]];
|
|
256
|
+
NSNumber *used = [window[@"used"] isKindOfClass:NSNumber.class] ? window[@"used"] : nil;
|
|
257
|
+
NSString *official = used ? [NSString stringWithFormat:@"%.0f%%",
|
|
258
|
+
100.0 - used.doubleValue] : @"--";
|
|
259
|
+
[official drawInRect:NSMakeRect(x, NSMinY(card) + 78, 145, 34)
|
|
260
|
+
withAttributes:[self textAttributesWithSize:25 color:primary weight:NSFontWeightBold]];
|
|
261
|
+
[@"剩余额度" drawInRect:NSMakeRect(x, NSMinY(card) + 60, 145, 18)
|
|
262
|
+
withAttributes:[self textAttributesWithSize:11 color:secondary weight:NSFontWeightRegular]];
|
|
263
|
+
NSString *tokenText = [NSString stringWithFormat:@"Token %@",
|
|
264
|
+
[self formattedTokenCount:window[@"tokens"]]];
|
|
265
|
+
[tokenText drawInRect:NSMakeRect(x, NSMinY(card) + 36, 145, 22)
|
|
266
|
+
withAttributes:[self textAttributesWithSize:15 color:color weight:NSFontWeightSemibold]];
|
|
267
|
+
// 整列都是 `--` 时说明这个窗口当前根本没有额度数据,直接说清楚,
|
|
268
|
+
// 比堆三个 `--` 让人以为是渲染坏了要好。
|
|
269
|
+
NSString *resetValue = [self resetText:window[@"quota"]];
|
|
270
|
+
NSString *reset = [resetValue isEqualToString:@"--"]
|
|
271
|
+
? @"当前无活跃窗口" : [NSString stringWithFormat:@"重置于 %@", resetValue];
|
|
272
|
+
[reset drawInRect:NSMakeRect(x, NSMinY(card) + 16, 145, 18)
|
|
273
|
+
withAttributes:[self textAttributesWithSize:11 color:secondary weight:NSFontWeightRegular]];
|
|
208
274
|
}
|
|
209
275
|
|
|
210
|
-
CGFloat
|
|
211
|
-
[
|
|
212
|
-
|
|
213
|
-
toPoint:NSMakePoint(separatorOne, NSMaxY(card) - 20)];
|
|
214
|
-
CGFloat ringX = separatorOne + 38;
|
|
215
|
-
NSPoint center = NSMakePoint(ringX, NSMinY(card) + 51);
|
|
216
|
-
NSBezierPath *ringTrack = [NSBezierPath bezierPath];
|
|
217
|
-
[ringTrack appendBezierPathWithArcWithCenter:center radius:24 startAngle:0 endAngle:360];
|
|
218
|
-
ringTrack.lineWidth = 7;
|
|
219
|
-
[track setStroke];
|
|
220
|
-
[ringTrack stroke];
|
|
221
|
-
if (weekRemaining) {
|
|
222
|
-
NSBezierPath *ring = [NSBezierPath bezierPath];
|
|
223
|
-
[ring appendBezierPathWithArcWithCenter:center radius:24 startAngle:90
|
|
224
|
-
endAngle:90 - 360 * weekRemaining.doubleValue / 100.0 clockwise:YES];
|
|
225
|
-
ring.lineWidth = 7;
|
|
226
|
-
ring.lineCapStyle = NSLineCapStyleRound;
|
|
227
|
-
[color setStroke];
|
|
228
|
-
[ring stroke];
|
|
229
|
-
}
|
|
230
|
-
NSString *weekText = weekRemaining ? [NSString stringWithFormat:@"%.0f%%", weekRemaining.doubleValue] : @"--";
|
|
231
|
-
[weekText drawInRect:NSMakeRect(ringX - 19, NSMinY(card) + 42, 38, 18)
|
|
232
|
-
withAttributes:[self centeredTextAttributesWithSize:13 color:primary weight:NSFontWeightSemibold]];
|
|
233
|
-
[@"周剩余" drawInRect:NSMakeRect(separatorOne + 68, NSMinY(card) + 66, 55, 20)
|
|
234
|
-
withAttributes:[self textAttributesWithSize:12 color:secondary weight:NSFontWeightRegular]];
|
|
235
|
-
|
|
236
|
-
CGFloat separatorTwo = NSMinX(card) + 414;
|
|
237
|
-
[[NSColor colorWithWhite:1 alpha:0.12] setStroke];
|
|
238
|
-
[NSBezierPath strokeLineFromPoint:NSMakePoint(separatorTwo, NSMinY(card) + 20)
|
|
239
|
-
toPoint:NSMakePoint(separatorTwo, NSMaxY(card) - 20)];
|
|
240
|
-
[@"周重置" drawInRect:NSMakeRect(separatorTwo + 16, NSMinY(card) + 66, 80, 20)
|
|
241
|
-
withAttributes:[self textAttributesWithSize:12 color:secondary weight:NSFontWeightRegular]];
|
|
242
|
-
[[self weeklyReset:week] drawInRect:NSMakeRect(separatorTwo + 16, NSMinY(card) + 39,
|
|
243
|
-
NSMaxX(card) - separatorTwo - 28, 24)
|
|
244
|
-
withAttributes:[self textAttributesWithSize:15 color:primary weight:NSFontWeightMedium]];
|
|
276
|
+
CGFloat trendX = NSMinX(card) + 564;
|
|
277
|
+
[@"过去 7 天额度趋势" drawInRect:NSMakeRect(trendX, NSMinY(card) + 114, 145, 20)
|
|
278
|
+
withAttributes:[self textAttributesWithSize:13 color:secondary weight:NSFontWeightRegular]];
|
|
245
279
|
NSArray<NSNumber *> *history = [name isEqualToString:@"Codex"] ? self.codexHistory : self.claudeHistory;
|
|
246
|
-
[self
|
|
247
|
-
|
|
248
|
-
|
|
280
|
+
[self drawUsageBars:history inRect:NSMakeRect(trendX, NSMinY(card) + 42, 135, 64) color:color];
|
|
281
|
+
NSString *trendDetail = @"等待历史数据";
|
|
282
|
+
if (self.historyEnabled && history.count > 0) {
|
|
283
|
+
double peak = 0;
|
|
284
|
+
for (NSNumber *remaining in history) peak = fmax(peak, 100.0 - remaining.doubleValue);
|
|
285
|
+
trendDetail = [NSString stringWithFormat:@"峰值额度已用 %.0f%%", peak];
|
|
286
|
+
}
|
|
287
|
+
[trendDetail drawInRect:NSMakeRect(trendX, NSMinY(card) + 18, 145, 18)
|
|
288
|
+
withAttributes:[self textAttributesWithSize:11 color:secondary weight:NSFontWeightRegular]];
|
|
249
289
|
}
|
|
250
290
|
- (void)drawRect:(NSRect)dirtyRect {
|
|
251
291
|
[NSGraphicsContext saveGraphicsState];
|
|
@@ -254,10 +294,10 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
254
294
|
[scale concat];
|
|
255
295
|
NSRect logicalBounds = NSMakeRect(0, 0, QuotaLogicalWidth, QuotaLogicalHeight);
|
|
256
296
|
NSRect outer = NSInsetRect(logicalBounds, 1, 1);
|
|
257
|
-
NSBezierPath *background = [NSBezierPath bezierPathWithRoundedRect:outer xRadius:
|
|
297
|
+
NSBezierPath *background = [NSBezierPath bezierPathWithRoundedRect:outer xRadius:24 yRadius:24];
|
|
258
298
|
NSGradient *gradient = [[NSGradient alloc]
|
|
259
|
-
initWithStartingColor:[NSColor colorWithRed:0.
|
|
260
|
-
endingColor:[NSColor colorWithRed:0.
|
|
299
|
+
initWithStartingColor:[NSColor colorWithRed:0.025 green:0.055 blue:0.095 alpha:0.88]
|
|
300
|
+
endingColor:[NSColor colorWithRed:0.07 green:0.12 blue:0.19 alpha:0.80]];
|
|
261
301
|
[gradient drawInBezierPath:background angle:-20];
|
|
262
302
|
|
|
263
303
|
[NSGraphicsContext saveGraphicsState];
|
|
@@ -265,36 +305,40 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
265
305
|
NSGradient *topGlow = [[NSGradient alloc]
|
|
266
306
|
initWithStartingColor:[NSColor colorWithWhite:1 alpha:0.34]
|
|
267
307
|
endingColor:[NSColor colorWithWhite:1 alpha:0.0]];
|
|
268
|
-
[topGlow drawFromCenter:NSMakePoint(
|
|
269
|
-
toCenter:NSMakePoint(
|
|
308
|
+
[topGlow drawFromCenter:NSMakePoint(700, 650) radius:0
|
|
309
|
+
toCenter:NSMakePoint(700, 650) radius:250 options:0];
|
|
270
310
|
NSGradient *cyanGlow = [[NSGradient alloc]
|
|
271
311
|
initWithStartingColor:[NSColor colorWithRed:0.18 green:0.72 blue:1 alpha:0.11]
|
|
272
312
|
endingColor:[NSColor colorWithRed:0.18 green:0.88 blue:1 alpha:0.0]];
|
|
273
|
-
[cyanGlow drawFromCenter:NSMakePoint(
|
|
274
|
-
toCenter:NSMakePoint(
|
|
313
|
+
[cyanGlow drawFromCenter:NSMakePoint(660, 250) radius:0
|
|
314
|
+
toCenter:NSMakePoint(660, 250) radius:260 options:0];
|
|
275
315
|
[NSGraphicsContext restoreGraphicsState];
|
|
276
316
|
|
|
277
|
-
[[NSColor colorWithWhite:1 alpha:0.
|
|
317
|
+
[[NSColor colorWithWhite:1 alpha:0.34] setStroke];
|
|
278
318
|
background.lineWidth = 1.5;
|
|
279
319
|
[background stroke];
|
|
280
320
|
NSBezierPath *innerGlassBorder = [NSBezierPath bezierPathWithRoundedRect:NSInsetRect(outer, 2, 2)
|
|
281
|
-
xRadius:
|
|
321
|
+
xRadius:22 yRadius:22];
|
|
282
322
|
[[NSColor colorWithRed:0.58 green:0.82 blue:1 alpha:0.22] setStroke];
|
|
283
323
|
innerGlassBorder.lineWidth = 0.8;
|
|
284
324
|
[innerGlassBorder stroke];
|
|
325
|
+
NSColor *primary = self.primaryColor;
|
|
326
|
+
NSColor *secondary = self.secondaryColor;
|
|
327
|
+
NSColor *cyan = self.accentColor;
|
|
328
|
+
NSColor *agentColor = self.agentStatusColor;
|
|
329
|
+
[@"Agent Usage" drawInRect:NSMakeRect(28, QuotaLogicalHeight - 65, 260, 42)
|
|
330
|
+
withAttributes:[self textAttributesWithSize:30 color:primary weight:NSFontWeightBold]];
|
|
331
|
+
[@"实时使用统计" drawInRect:NSMakeRect(30, QuotaLogicalHeight - 94, 130, 22)
|
|
332
|
+
withAttributes:[self textAttributesWithSize:14 color:secondary weight:NSFontWeightRegular]];
|
|
333
|
+
[agentColor setFill];
|
|
334
|
+
[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(174, QuotaLogicalHeight - 88, 9, 9)] fill];
|
|
335
|
+
NSString *agentText = self.activeAgentCount > 0
|
|
336
|
+
? [NSString stringWithFormat:@"%ld 个 Agent 在线", (long)self.activeAgentCount]
|
|
337
|
+
: @"暂无 Agent 在线";
|
|
338
|
+
[agentText drawInRect:NSMakeRect(190, QuotaLogicalHeight - 95, 160, 22)
|
|
339
|
+
withAttributes:[self textAttributesWithSize:14 color:agentColor weight:NSFontWeightMedium]];
|
|
285
340
|
|
|
286
|
-
|
|
287
|
-
[@"Agent 余量" drawInRect:NSMakeRect(24, QuotaLogicalHeight - 53, 180, 30)
|
|
288
|
-
withAttributes:[self textAttributesWithSize:23 color:[NSColor colorWithWhite:0.97 alpha:1] weight:NSFontWeightBold]];
|
|
289
|
-
[@"实时配额状态" drawInRect:NSMakeRect(25, QuotaLogicalHeight - 76, 130, 20)
|
|
290
|
-
withAttributes:[self textAttributesWithSize:12 color:[NSColor colorWithWhite:0.63 alpha:1] weight:NSFontWeightRegular]];
|
|
291
341
|
BOOL recentlyRefreshed = self.refreshedUntil > NSDate.date.timeIntervalSince1970;
|
|
292
|
-
NSRect live = NSMakeRect(QuotaLogicalWidth - 145, QuotaLogicalHeight - 51, 78, 28);
|
|
293
|
-
[self fillRoundedRect:live radius:14 color:[NSColor colorWithWhite:1 alpha:0.055]];
|
|
294
|
-
[[NSColor systemGreenColor] setFill];
|
|
295
|
-
[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(NSMinX(live) + 12, NSMinY(live) + 10, 8, 8)] fill];
|
|
296
|
-
[recentlyRefreshed ? @"已刷新" : @"实时更新" drawInRect:NSMakeRect(NSMinX(live) + 26, NSMinY(live) + 6, 50, 18)
|
|
297
|
-
withAttributes:[self textAttributesWithSize:11 color:[NSColor colorWithWhite:0.87 alpha:1] weight:NSFontWeightMedium]];
|
|
298
342
|
CGFloat buttonAlpha = self.refreshPressed ? 0.18 : (self.refreshHovered ? 0.12 : 0.06);
|
|
299
343
|
NSRect logicalRefreshRect = [self logicalRefreshRect];
|
|
300
344
|
NSRect refreshRect = self.refreshPressed ? NSInsetRect(logicalRefreshRect, 1.5, 1.5) : logicalRefreshRect;
|
|
@@ -302,16 +346,52 @@ NSImage *OfficialAppIcon(NSString *bundleIdentifier, NSString *resourceName) {
|
|
|
302
346
|
[recentlyRefreshed ? @"✓" : @"↻" drawInRect:NSInsetRect(refreshRect, 8, 4)
|
|
303
347
|
withAttributes:[self textAttributesWithSize:19 color:[NSColor colorWithWhite:0.9 alpha:1] weight:NSFontWeightRegular]];
|
|
304
348
|
|
|
349
|
+
NSRect summary = NSMakeRect(20, 372, QuotaLogicalWidth - 40, 86);
|
|
350
|
+
NSBezierPath *summaryPath = [NSBezierPath bezierPathWithRoundedRect:summary xRadius:18 yRadius:18];
|
|
351
|
+
[[NSColor colorWithWhite:1 alpha:0.065] setFill];
|
|
352
|
+
[summaryPath fill];
|
|
353
|
+
[[NSColor colorWithWhite:1 alpha:0.16] setStroke];
|
|
354
|
+
[summaryPath stroke];
|
|
355
|
+
|
|
356
|
+
// 在线 Agent 数已经在标题旁展示过,这里换成 5 小时合计,和第二格的 7 天形成对照。
|
|
357
|
+
// 三格等宽由 summary 推导,改宽度时分隔线和内容不会各走各的。
|
|
358
|
+
NSArray<NSDictionary *> *cells = @[
|
|
359
|
+
@{@"icon": @"◔", @"tint": cyan, @"value": [self formattedTokenCount:
|
|
360
|
+
[self combinedTokens:@"today"]], @"label": @"今日 Token"},
|
|
361
|
+
@{@"icon": @"◉", @"tint": cyan, @"value": [self formattedTokenCount:
|
|
362
|
+
[self combinedTokens:@"recentWeek"]], @"label": @"最近 7 天"},
|
|
363
|
+
@{@"icon": @"◷", @"tint": NSColor.systemPurpleColor, @"value": [self refreshAgeText],
|
|
364
|
+
@"label": @"数据刷新"}
|
|
365
|
+
];
|
|
366
|
+
CGFloat cellWidth = NSWidth(summary) / cells.count;
|
|
367
|
+
[[NSColor colorWithWhite:1 alpha:0.10] setStroke];
|
|
368
|
+
for (NSUInteger index = 1; index < cells.count; index++) {
|
|
369
|
+
CGFloat x = NSMinX(summary) + cellWidth * index;
|
|
370
|
+
[NSBezierPath strokeLineFromPoint:NSMakePoint(x, NSMinY(summary) + 16)
|
|
371
|
+
toPoint:NSMakePoint(x, NSMaxY(summary) - 16)];
|
|
372
|
+
}
|
|
373
|
+
for (NSUInteger index = 0; index < cells.count; index++) {
|
|
374
|
+
NSDictionary *cell = cells[index];
|
|
375
|
+
CGFloat x = NSMinX(summary) + cellWidth * index;
|
|
376
|
+
[cell[@"icon"] drawInRect:NSMakeRect(x + 26, NSMinY(summary) + 23, 42, 42)
|
|
377
|
+
withAttributes:[self textAttributesWithSize:30 color:cell[@"tint"]
|
|
378
|
+
weight:NSFontWeightRegular]];
|
|
379
|
+
[cell[@"value"] drawInRect:NSMakeRect(x + 74, NSMinY(summary) + 40, 150, 28)
|
|
380
|
+
withAttributes:[self textAttributesWithSize:22 color:primary weight:NSFontWeightBold]];
|
|
381
|
+
[cell[@"label"] drawInRect:NSMakeRect(x + 74, NSMinY(summary) + 17, 150, 20)
|
|
382
|
+
withAttributes:[self textAttributesWithSize:12 color:secondary
|
|
383
|
+
weight:NSFontWeightRegular]];
|
|
384
|
+
}
|
|
385
|
+
|
|
305
386
|
[self drawProvider:@"Codex" usage:self.codexUsage usedKey:@"used_percent"
|
|
306
|
-
color:
|
|
307
|
-
cardRect:NSMakeRect(18, 174, QuotaLogicalWidth - 36, 104)];
|
|
387
|
+
color:cyan cardRect:NSMakeRect(20, 208, QuotaLogicalWidth - 40, 152)];
|
|
308
388
|
[self drawProvider:@"Claude" usage:self.claudeUsage usedKey:@"used_percentage"
|
|
309
389
|
color:[NSColor colorWithRed:0.66 green:0.43 blue:0.94 alpha:1]
|
|
310
|
-
cardRect:NSMakeRect(
|
|
311
|
-
NSString *footer =
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
[footer drawInRect:NSMakeRect(
|
|
390
|
+
cardRect:NSMakeRect(20, 44, QuotaLogicalWidth - 40, 152)];
|
|
391
|
+
NSString *footer = @"ⓘ Token 为本机统计;官方订阅额度以服务端百分比为准,数据可能存在短暂延迟";
|
|
392
|
+
// 卡片底边在 y=44,原来 footer 顶到 44 完全没有间隙。下移到与卡片留约 8pt,
|
|
393
|
+
// 同时底部留白 16pt,和顶部标题的留白大致对称。
|
|
394
|
+
[footer drawInRect:NSMakeRect(28, 16, 650, 20)
|
|
315
395
|
withAttributes:[self textAttributesWithSize:11 color:[NSColor colorWithWhite:0.58 alpha:1] weight:NSFontWeightRegular]];
|
|
316
396
|
[NSGraphicsContext restoreGraphicsState];
|
|
317
397
|
}
|
package/Sources/CCPets/main.m
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#import "CCPetsQuotaHistory.h"
|
|
7
7
|
#import "CCPetsUsage.h"
|
|
8
8
|
#import "CCPetsVersion.h"
|
|
9
|
+
#import "CCPetsCleanup.h"
|
|
9
10
|
#import <sys/file.h>
|
|
10
11
|
#import <sys/stat.h>
|
|
11
12
|
#import <fcntl.h>
|
|
@@ -39,6 +40,8 @@ int main(int argc, const char *argv[]) {
|
|
|
39
40
|
if (argc > 1 && (strcmp(argv[1], "--provider-event") == 0 ||
|
|
40
41
|
strcmp(argv[1], "provider-event") == 0)) return RecordProviderEvent();
|
|
41
42
|
if (argc > 1 && strcmp(argv[1], "--claude-usage") == 0) return RecordClaudeUsage();
|
|
43
|
+
if (argc > 1 && strcmp(argv[1], "--clean") == 0) return CleanCCPetsData(NO);
|
|
44
|
+
if (argc > 1 && strcmp(argv[1], "--purge-data") == 0) return CleanCCPetsData(YES);
|
|
42
45
|
if (argc > 1 && strcmp(argv[1], "--history") == 0) {
|
|
43
46
|
NSData *json = [NSJSONSerialization dataWithJSONObject:QuotaHistoryDocument()
|
|
44
47
|
options:NSJSONWritingPrettyPrinted error:nil];
|
|
@@ -74,6 +77,7 @@ int main(int argc, const char *argv[]) {
|
|
|
74
77
|
NSString *lockPath = [PetStateDirectory() stringByAppendingPathComponent:lockName];
|
|
75
78
|
int lock = open(lockPath.fileSystemRepresentation, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
|
76
79
|
if (lock < 0 || flock(lock, LOCK_EX | LOCK_NB) != 0) return EXIT_SUCCESS;
|
|
80
|
+
PruneStaleRuntimeState();
|
|
77
81
|
|
|
78
82
|
NSApplication *app = NSApplication.sharedApplication;
|
|
79
83
|
AppDelegate *delegate = [AppDelegate new];
|
package/bin/cc-pets
CHANGED
|
@@ -23,6 +23,11 @@ if [[ "${1:-}" == "build" ]]; then
|
|
|
23
23
|
exec "${PROJECT_DIR}/scripts/build.sh"
|
|
24
24
|
fi
|
|
25
25
|
|
|
26
|
+
if [[ "${1:-}" == "clean" ]]; then
|
|
27
|
+
shift
|
|
28
|
+
exec "${PET_BIN}" --clean "$@"
|
|
29
|
+
fi
|
|
30
|
+
|
|
26
31
|
if [[ ! -x "${PET_BIN}" || ! -d "${BUILD_APP}" ]]; then
|
|
27
32
|
"${PROJECT_DIR}/scripts/build.sh" >/dev/null
|
|
28
33
|
fi
|
package/package.json
CHANGED
package/scripts/build.sh
CHANGED
|
@@ -35,6 +35,8 @@ CLANG_MODULE_CACHE_PATH="${CACHE_DIR}" clang \
|
|
|
35
35
|
"-DCC_PETS_VERSION=\"${PACKAGE_VERSION}\"" \
|
|
36
36
|
-I"${PROJECT_DIR}/Sources/CCPets" \
|
|
37
37
|
-framework Cocoa \
|
|
38
|
+
-framework CoreServices \
|
|
39
|
+
-framework ImageIO \
|
|
38
40
|
-framework QuartzCore \
|
|
39
41
|
-framework UserNotifications \
|
|
40
42
|
"${SOURCES[@]}" \
|
package/scripts/uninstall-app.sh
CHANGED
|
@@ -5,6 +5,15 @@ APPLICATIONS_DIR="${CC_PETS_APPLICATIONS_DIR:-${HOME}/Applications}"
|
|
|
5
5
|
TARGET_APP="${APPLICATIONS_DIR}/CC Pets.app"
|
|
6
6
|
TARGET_EXECUTABLE="${TARGET_APP}/Contents/MacOS/cc-pets"
|
|
7
7
|
|
|
8
|
+
if [[ -e "${TARGET_APP}" ]]; then
|
|
9
|
+
BUNDLE_ID="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' \
|
|
10
|
+
"${TARGET_APP}/Contents/Info.plist" 2>/dev/null || true)"
|
|
11
|
+
if [[ "${BUNDLE_ID}" != "com.universewang.cc-pets" ]]; then
|
|
12
|
+
print -u2 "拒绝删除:${TARGET_APP} 不是 CC Pets 应用(Bundle ID 不匹配)。"
|
|
13
|
+
exit 2
|
|
14
|
+
fi
|
|
15
|
+
fi
|
|
16
|
+
|
|
8
17
|
if [[ "${CC_PETS_SKIP_APP_STOP:-0}" != "1" ]] && pgrep -f "${TARGET_EXECUTABLE}" >/dev/null 2>&1; then
|
|
9
18
|
pkill -f "${TARGET_EXECUTABLE}" || true
|
|
10
19
|
fi
|
|
@@ -4,17 +4,65 @@ set -eu
|
|
|
4
4
|
SCRIPT_DIR="${0:A:h}"
|
|
5
5
|
PROJECT_DIR="${SCRIPT_DIR:h}"
|
|
6
6
|
SHELL_RC="${ZDOTDIR:-${HOME}}/.zshrc"
|
|
7
|
+
PET_BIN="${PROJECT_DIR}/.build/release/cc-pets"
|
|
7
8
|
PET_APP_EXECUTABLE="${PROJECT_DIR}/.build/release/CC Pets.app/Contents/MacOS/cc-pets"
|
|
9
|
+
INSTALLED_APP_EXECUTABLE="${CC_PETS_APPLICATIONS_DIR:-${HOME}/Applications}/CC Pets.app/Contents/MacOS/cc-pets"
|
|
8
10
|
LEGACY_PET_APP_EXECUTABLE="${PROJECT_DIR}/.build/release/CodexPet.app/Contents/MacOS/codex-pet"
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
PURGE=0
|
|
13
|
+
ASSUME_YES=0
|
|
14
|
+
for argument in "$@"; do
|
|
15
|
+
[[ "${argument}" == "--purge" ]] && PURGE=1
|
|
16
|
+
[[ "${argument}" == "--yes" ]] && ASSUME_YES=1
|
|
17
|
+
done
|
|
18
|
+
|
|
19
|
+
if (( PURGE && ! ASSUME_YES )); then
|
|
20
|
+
if [[ ! -t 0 ]]; then
|
|
21
|
+
print -u2 "完整卸载会删除应用、额度历史、更新配置、日志和偏好。非交互环境请显式添加 --yes。"
|
|
22
|
+
exit 2
|
|
23
|
+
fi
|
|
24
|
+
print -u2 "完整卸载会永久删除 CC Pets 应用及全部本地数据,是否继续?[y/N] "
|
|
25
|
+
if ! read -r reply || [[ "${reply:l}" != "y" && "${reply:l}" != "yes" ]]; then
|
|
26
|
+
print "已取消完整卸载。"
|
|
27
|
+
exit 0
|
|
28
|
+
fi
|
|
29
|
+
fi
|
|
11
30
|
|
|
12
31
|
if [[ "${CC_PETS_SKIP_APP_STOP:-0}" != "1" ]]; then
|
|
13
|
-
for executable in "${PET_APP_EXECUTABLE}" "${LEGACY_PET_APP_EXECUTABLE}"; do
|
|
32
|
+
for executable in "${PET_APP_EXECUTABLE}" "${INSTALLED_APP_EXECUTABLE}" "${LEGACY_PET_APP_EXECUTABLE}"; do
|
|
14
33
|
if pgrep -f "${executable}" >/dev/null 2>&1; then
|
|
15
34
|
pkill -f "${executable}" || true
|
|
16
35
|
fi
|
|
17
36
|
done
|
|
37
|
+
if (( PURGE )); then
|
|
38
|
+
for _ in {1..30}; do
|
|
39
|
+
running=0
|
|
40
|
+
for executable in "${PET_APP_EXECUTABLE}" "${INSTALLED_APP_EXECUTABLE}" "${LEGACY_PET_APP_EXECUTABLE}"; do
|
|
41
|
+
if pgrep -f "${executable}" >/dev/null 2>&1; then
|
|
42
|
+
running=1
|
|
43
|
+
fi
|
|
44
|
+
done
|
|
45
|
+
(( running == 0 )) && break
|
|
46
|
+
sleep 0.1
|
|
47
|
+
done
|
|
48
|
+
if (( running != 0 )); then
|
|
49
|
+
print -u2 "完整卸载失败:CC Pets 未能退出,尚未删除集成或本地数据。"
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
fi
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
node "${PROJECT_DIR}/scripts/uninstall-integrations.mjs" "${SHELL_RC}"
|
|
56
|
+
|
|
57
|
+
if (( PURGE )); then
|
|
58
|
+
if [[ ! -x "${PET_BIN}" ]]; then
|
|
59
|
+
print -u2 "完整卸载失败:找不到 ${PET_BIN},本地数据尚未删除。"
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
"${PET_BIN}" --purge-data
|
|
63
|
+
CC_PETS_SKIP_APP_STOP=1 "${PROJECT_DIR}/scripts/uninstall-app.sh"
|
|
64
|
+
print "完整卸载完成;npm 包本身如仍存在,可继续执行 npm uninstall -g cc-pets。"
|
|
65
|
+
exit 0
|
|
18
66
|
fi
|
|
19
67
|
|
|
20
68
|
print "卸载集成完成。执行 source ${(q)SHELL_RC} 更新当前终端;如需删除 npm 包,再执行 npm uninstall -g cc-pets。"
|