easy-claude 0.2.7 → 0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # 更新记录
2
2
 
3
+ ## v0.2.8(2026-10-21)
4
+
5
+ - 当前时间浮窗和城市菜单跟随系统12/24小时制及地区格式,保留所选城市时区;字体自动适应宽度,避免上午/下午标记截断。
6
+
3
7
  ## v0.2.7(2026-10-21)
4
8
 
5
9
  - 修复旧浮窗退出后日志清理失效;检查失败保留上次成功的新版提示并显示检查失败状态。
package/README.md CHANGED
@@ -4,12 +4,10 @@
4
4
 
5
5
  需要 Node.js 22+ 与 Claude Code 订阅登录;不支持把 API Key 账单余额当作订阅额度。
6
6
 
7
- ## v0.2.7 更新说明
7
+ ## v0.2.8 更新说明
8
8
 
9
- - 新增“自动更新”开关,默认关闭;开启后每天检查,有新版才安装并自动重开,保留设置。
10
- - 已是最新版本时仅提示,不重复安装或重开;同一安装目录的更新互斥执行。
11
- - 额度菜单重置时间跟随系统12/24小时制及AM/PM。
12
- - 修复更新重开后临时日志残留;检查失败保留已知新版绿点并显示失败提示。
9
+ - 当前时间浮窗与城市菜单跟随系统12/24小时制及地区格式,继续使用所选城市时区。
10
+ - 浮窗文字自动适应宽度,12小时制的上午/下午标记不会被截断;保留位置、配色和显示设置。
13
11
 
14
12
  历史版本更新记录见 [CHANGELOG](CHANGELOG.md)。
15
13
 
@@ -185,14 +185,23 @@ func resetDescription(_ resetsAt: Double?, weekly: Bool, now: Date = Date(), zon
185
185
  return "\(duration)后 \(time) 重置"
186
186
  }
187
187
 
188
- func clockText(at date: Date, zone: TimeZone) -> String {
188
+ func clockText(at date: Date, zone: TimeZone, locale: Locale = .autoupdatingCurrent) -> String {
189
189
  let formatter = DateFormatter()
190
- formatter.locale = Locale(identifier: "en_US_POSIX")
190
+ formatter.locale = locale
191
191
  formatter.timeZone = zone
192
- formatter.dateFormat = "HH:mm"
192
+ formatter.setLocalizedDateFormatFromTemplate("jm")
193
193
  return formatter.string(from: date)
194
194
  }
195
195
 
196
+
197
+ @MainActor
198
+ func fittedClockFont(for text: String, width: CGFloat, baseSize: CGFloat) -> NSFont {
199
+ let base = NSFont.monospacedDigitSystemFont(ofSize: baseSize, weight: .medium)
200
+ let measured = max(1, (text as NSString).size(withAttributes: [.font: base]).width)
201
+ let size = min(baseSize, baseSize * max(1, width - 2) / measured)
202
+ return NSFont.monospacedDigitSystemFont(ofSize: size, weight: .medium)
203
+ }
204
+
196
205
  func clockState(at date: Date, zone: TimeZone) -> RingState {
197
206
  var calendar = Calendar(identifier: .gregorian)
198
207
  calendar.timeZone = zone
@@ -212,7 +221,7 @@ final class ClockView: RingView {
212
221
  let now = Date()
213
222
  let time = clockText(at: now, zone: zone)
214
223
  (time as NSString).draw(in: CGRect(x: 0, y: 17, width: bounds.width, height: 25),
215
- withAttributes: [.font: NSFont.monospacedDigitSystemFont(ofSize: 20, weight: .medium),
224
+ withAttributes: [.font: fittedClockFont(for: time, width: bounds.width, baseSize: 20),
216
225
  .foregroundColor: clockState(at: now, zone: zone).color, .paragraphStyle: style])
217
226
  let city = cityName
218
227
  (city as NSString).draw(in: CGRect(x: 0, y: 1, width: bounds.width, height: 15),
@@ -648,6 +657,16 @@ struct Main {
648
657
  let countdownStart = ISO8601DateFormatter().date(from: "2026-10-15T04:57:00Z")!
649
658
  let countdownUTC = TimeZone(secondsFromGMT: 0)!
650
659
  let afternoon = ISO8601DateFormatter().date(from: "2026-10-21T14:30:00Z")!
660
+ for identifier in ["en_US", "en_GB", "zh_CN"] {
661
+ let text = clockText(at: afternoon, zone: countdownUTC, locale: Locale(identifier: identifier))
662
+ if identifier == "en_US" { precondition(text.contains("PM") && !text.contains("14:30")) }
663
+ else { precondition(text == "14:30") }
664
+ let font = fittedClockFont(for: text, width: 96, baseSize: 20)
665
+ precondition((text as NSString).size(withAttributes: [.font: font]).width <= 96 - 1)
666
+ }
667
+ let laClock = clockText(at: afternoon, zone: TimeZone(identifier: "America/Los_Angeles")!, locale: Locale(identifier: "en_US"))
668
+ precondition(laClock.contains("7:30") && laClock.contains("AM"))
669
+
651
670
  let morning = ISO8601DateFormatter().date(from: "2026-10-21T02:30:00Z")!
652
671
  for weekly in [false, true] {
653
672
  let us = resetDescription(afternoon.timeIntervalSince1970, weekly: weekly,
@@ -683,9 +702,9 @@ struct Main {
683
702
  let singapore = TimeZone(identifier: "Asia/Singapore")!
684
703
  let winter = ISO8601DateFormatter().date(from: "2026-01-15T12:00:00Z")!
685
704
  let summer = ISO8601DateFormatter().date(from: "2026-07-15T12:00:00Z")!
686
- precondition(clockText(at: winter, zone: la) == "04:00")
687
- precondition(clockText(at: summer, zone: la) == "05:00")
688
- precondition(clockText(at: winter, zone: singapore) == "20:00")
705
+ precondition(clockText(at: winter, zone: la, locale: Locale(identifier: "en_GB")) == "04:00")
706
+ precondition(clockText(at: summer, zone: la, locale: Locale(identifier: "en_GB")) == "05:00")
707
+ precondition(clockText(at: winter, zone: singapore, locale: Locale(identifier: "en_GB")) == "20:00")
689
708
  precondition(TimeZone(identifier: "Invalid/Zone") == nil)
690
709
  let utc = TimeZone(secondsFromGMT: 0)!
691
710
  for (hour, state) in [(0, RingState.red), (6, .red), (8, .red), (9, .green), (14, .green), (15, .green), (17, .green), (18, .orange), (23, .orange)] {
@@ -5,7 +5,7 @@
5
5
  <key>CFBundleIdentifier</key><string>com.unionschool.easy-claude.overlay</string>
6
6
  <key>CFBundleName</key><string>Easy Claude Overlay</string>
7
7
  <key>CFBundlePackageType</key><string>APPL</string>
8
- <key>CFBundleShortVersionString</key><string>0.2.7</string>
8
+ <key>CFBundleShortVersionString</key><string>0.2.8</string>
9
9
  <key>LSMinimumSystemVersion</key><string>14.0</string>
10
10
  <key>LSUIElement</key><true/>
11
11
  <key>NSHighResolutionCapable</key><true/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-claude",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Claude Code quota rings and transparent world clock for Claude desktop",
5
5
  "type": "module",
6
6
  "bin": {