easy-claude 0.3.1 → 0.3.4
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 +14 -0
- package/README.md +15 -7
- package/native/Overlay.swift +129 -10
- package/native/build/EasyClaudeOverlay.app/Contents/Info.plist +1 -1
- package/native/build/EasyClaudeOverlay.app/Contents/MacOS/EasyClaudeOverlay +0 -0
- package/package.json +1 -1
- package/src/public-ip.js +13 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## v0.3.4(2026-10-22,America/Los_Angeles)
|
|
4
|
+
|
|
5
|
+
- 12小时制按所选时区显示五个时段:00:00–06:00 凌晨、06:00–12:00 上午、12:00–18:00 下午、18:00–21:00 晚上、21:00–24:00 深夜。
|
|
6
|
+
- 零点显示 `00:12`,不再显示 `12:12`;正午仍显示 `12:12`。24小时制及额度重置时间的系统格式保持不变。
|
|
7
|
+
- 菜单新增“开机启动”,默认关闭;手动开启后,登录当前macOS用户会自动打开浮窗。关闭取消后续登录启动,不结束当前浮窗。
|
|
8
|
+
- 使用独立的用户级LaunchAgent,无需管理员权限,不修改官方应用。原时区、位置、提醒及更新设置继续保留。
|
|
9
|
+
|
|
10
|
+
## v0.3.3(2026-10-20,America/Los_Angeles)
|
|
11
|
+
|
|
12
|
+
- 改为只请求一次 `https://ipinfo.io/json`,同时获取当前网络出口的公网IP、城市和时区;继续支持环境及系统HTTPS代理。
|
|
13
|
+
- 跟随IP时区时,浮窗时间下方显示接口返回的城市名称,例如 `Los Angeles`,不再显示“IP时区”;时间仍按接口返回的时区计算。
|
|
14
|
+
- 城市名称居中,最大宽度不超过时间文字的实际宽度,过长自动缩小字号。
|
|
15
|
+
- 获取不到IP或有效时区时继续显示自定义时区时间;城市缺失显示“城市未知”。不改变已保存的时区、位置和开关。
|
|
16
|
+
|
|
3
17
|
## v0.3.1(2026-10-20,America/Los_Angeles)
|
|
4
18
|
|
|
5
19
|
- 新增“跟随IP时区”开关,默认关闭;开启后自动显示网络出口时区时间并隐藏手动时区选择,关闭恢复原城市和时区。
|
package/README.md
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
需要 Node.js 22+ 与 Claude Code 订阅登录;不支持把 API Key 账单余额当作订阅额度。
|
|
6
6
|
|
|
7
|
-
## v0.3.
|
|
7
|
+
## v0.3.4 更新说明
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
9
|
+
- 12小时制按所选时区显示五个时段:00:00–06:00 凌晨、06:00–12:00 上午、12:00–18:00 下午、18:00–21:00 晚上、21:00–24:00 深夜。
|
|
10
|
+
- 零点显示 `00:12`,不再显示 `12:12`;正午仍显示 `12:12`。24小时制及额度重置时间的系统格式保持不变。
|
|
11
|
+
- 菜单新增“开机启动”,默认关闭;手动开启后,登录当前macOS用户会自动打开浮窗。关闭取消后续登录启动,不结束当前浮窗。
|
|
12
|
+
- 使用独立的用户级LaunchAgent,无需管理员权限,不修改官方应用。原时区、位置、提醒及更新设置继续保留。
|
|
12
13
|
|
|
13
14
|
历史版本更新记录见 [CHANGELOG](CHANGELOG.md)。
|
|
14
15
|
|
|
@@ -72,7 +73,6 @@ npm run build:overlay
|
|
|
72
73
|
|
|
73
74
|
命令更新:`easy-claude update`,成功后会自动退出旧浮窗并打开新版。旧版本尚未提供 update 时,可先执行 `npm i -g easy-claude@latest`。更新过程中需要正常网络及原安装目录写入权限,不会自动使用 sudo。
|
|
74
75
|
|
|
75
|
-
|
|
76
76
|
菜单中的“更新版本”会后台检查并更新,成功后自动重开浮窗;失败时保留当前浮窗并提示原因。更新期间不能重复点击,已保存设置保持不变。
|
|
77
77
|
|
|
78
78
|
更新前会在线核对版本;已经是最新版本时只提示,不重复安装或重开浮窗。有更高正式版本并安装成功后,才自动重开。
|
|
@@ -93,7 +93,7 @@ npm run build:overlay
|
|
|
93
93
|
|
|
94
94
|
## 公网IP与城市
|
|
95
95
|
|
|
96
|
-
菜单显示“城市名称·IP
|
|
96
|
+
菜单显示“城市名称·IP地址”,仅请求一次 `https://ipinfo.io/json`,同时获取当前请求出口的IP、城市和时区;城市名称按接口返回显示。启动和每5分钟刷新,点击该菜单项可立即重查。IP取不到显示“IP异常”;城市取不到显示“城市未知”。
|
|
97
97
|
|
|
98
98
|
查询遵循已有HTTPS/ALL代理环境或macOS系统HTTPS代理。这里显示查询服务看到的网络出口;Clash分流时可能与AI请求不同,城市不代表电脑所在地,关闭“跟随IP时区”时不改变时钟时区。不主动保存IP历史,不发送账号凭据。
|
|
99
99
|
|
|
@@ -102,6 +102,14 @@ IP地理库的城市与时区可能存在偏差或互相不一致;显示接口
|
|
|
102
102
|
|
|
103
103
|
## 跟随IP时区
|
|
104
104
|
|
|
105
|
-
菜单开启“跟随IP时区”后,时钟按地理接口返回的IANA时区显示当地时间,自动处理夏令时,继续跟随系统12/24
|
|
105
|
+
菜单开启“跟随IP时区”后,时钟按地理接口返回的IANA时区显示当地时间,自动处理夏令时,继续跟随系统12/24小时制;时钟下方显示IP返回的城市名称,宽度不超过时间文字,手动时区选择隐藏。IP每5分钟刷新或点击IP菜单刷新,时区同步更新。
|
|
106
106
|
|
|
107
107
|
关闭后恢复之前手动选择的城市和时区,并重新显示选择菜单。取不到IP或有效时区时,时钟回退到手动设置的时区,菜单提示“IP时区不可用,显示自定义时间”;开关仍开启,获取成功后继续跟随。开关和手动设置跨重启/更新保存,不保存IP历史。IP地理数据可能不准确,跟随的是出口时区,不修改电脑系统时区。
|
|
108
|
+
|
|
109
|
+
## 开机启动与12小时时段
|
|
110
|
+
|
|
111
|
+
从菜单勾选“开机启动”后,在登录当前macOS用户时自动运行本工具的 `show`,默认关闭,不会自动登录系统或打开官方Codex/Claude应用。关闭仅取消下次登录启动,当前浮窗继续运行。系统若禁止此后台项目,则需在系统设置中允许。
|
|
112
|
+
|
|
113
|
+
登录配置保存当前Node/npm安装路径,常规原前缀npm更新可继续使用;删除或迁移Node/npm目录后,从新安装打开浮窗并关闭再开启此选项以更新路径。
|
|
114
|
+
|
|
115
|
+
12小时制时段按时钟所选时区计算;跟随IP时使用有效IP时区,获取失败沿用自定义时间。浮窗、城市菜单和辅助文本使用相同五时段,Codex上方小字独立显示时段,Claude沿用单行时间。零点如“凌晨 00:12”、正午如“下午 12:12”;24小时制不增加时段文字,额度重置时刻继续使用系统格式。
|
package/native/Overlay.swift
CHANGED
|
@@ -187,11 +187,30 @@ func resetDescription(_ resetsAt: Double?, weekly: Bool, now: Date = Date(), zon
|
|
|
187
187
|
return "\(duration)后 \(time) 重置"
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
func clockPeriod(at date: Date, zone: TimeZone) -> String {
|
|
191
|
+
var calendar = Calendar(identifier: .gregorian)
|
|
192
|
+
calendar.timeZone = zone
|
|
193
|
+
switch calendar.component(.hour, from: date) {
|
|
194
|
+
case 0..<6: return "凌晨"
|
|
195
|
+
case 6..<12: return "上午"
|
|
196
|
+
case 12..<18: return "下午"
|
|
197
|
+
case 18..<21: return "晚上"
|
|
198
|
+
default: return "深夜"
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
190
202
|
func clockText(at date: Date, zone: TimeZone, locale: Locale = .autoupdatingCurrent) -> String {
|
|
191
203
|
let formatter = DateFormatter()
|
|
192
204
|
formatter.locale = locale
|
|
193
205
|
formatter.timeZone = zone
|
|
194
206
|
formatter.setLocalizedDateFormatFromTemplate("jm")
|
|
207
|
+
if locale.hourCycle == .oneToTwelve || locale.hourCycle == .zeroToEleven {
|
|
208
|
+
var calendar = Calendar(identifier: .gregorian)
|
|
209
|
+
calendar.timeZone = zone
|
|
210
|
+
formatter.locale = Locale(identifier: "en_US_POSIX")
|
|
211
|
+
formatter.dateFormat = calendar.component(.hour, from: date) == 0 ? "HH:mm" : "h:mm"
|
|
212
|
+
return "\(clockPeriod(at: date, zone: zone)) \(formatter.string(from: date))"
|
|
213
|
+
}
|
|
195
214
|
return formatter.string(from: date)
|
|
196
215
|
}
|
|
197
216
|
|
|
@@ -200,8 +219,16 @@ func clockText(at date: Date, zone: TimeZone, locale: Locale = .autoupdatingCurr
|
|
|
200
219
|
func fittedClockFont(for text: String, width: CGFloat, baseSize: CGFloat) -> NSFont {
|
|
201
220
|
let base = NSFont.monospacedDigitSystemFont(ofSize: baseSize, weight: .medium)
|
|
202
221
|
let measured = max(1, (text as NSString).size(withAttributes: [.font: base]).width)
|
|
203
|
-
|
|
204
|
-
|
|
222
|
+
var size = min(baseSize, baseSize * max(1, width - 2) / measured)
|
|
223
|
+
var font = NSFont.monospacedDigitSystemFont(ofSize: size, weight: .medium)
|
|
224
|
+
// 字体在小字号下的实际字宽不完全按比例缩放,按实测宽度校正。
|
|
225
|
+
for _ in 0..<6 {
|
|
226
|
+
let actual = (text as NSString).size(withAttributes: [.font: font]).width
|
|
227
|
+
if actual <= width { break }
|
|
228
|
+
size *= width / actual * 0.95
|
|
229
|
+
font = NSFont.monospacedDigitSystemFont(ofSize: size, weight: .medium)
|
|
230
|
+
}
|
|
231
|
+
return font
|
|
205
232
|
}
|
|
206
233
|
|
|
207
234
|
func clockState(at date: Date, zone: TimeZone) -> RingState {
|
|
@@ -222,12 +249,14 @@ final class ClockView: RingView {
|
|
|
222
249
|
style.alignment = .center
|
|
223
250
|
let now = Date()
|
|
224
251
|
let time = clockText(at: now, zone: zone)
|
|
252
|
+
let timeFont = fittedClockFont(for: time, width: bounds.width, baseSize: 20)
|
|
253
|
+
let timeWidth = (time as NSString).size(withAttributes: [.font: timeFont]).width
|
|
225
254
|
(time as NSString).draw(in: CGRect(x: 0, y: 17, width: bounds.width, height: 25),
|
|
226
|
-
withAttributes: [.font:
|
|
255
|
+
withAttributes: [.font: timeFont,
|
|
227
256
|
.foregroundColor: clockState(at: now, zone: zone).color, .paragraphStyle: style])
|
|
228
257
|
let city = cityName
|
|
229
258
|
(city as NSString).draw(in: CGRect(x: 0, y: 1, width: bounds.width, height: 15),
|
|
230
|
-
withAttributes: [.font:
|
|
259
|
+
withAttributes: [.font: fittedClockFont(for: city, width: timeWidth, baseSize: 10),
|
|
231
260
|
.foregroundColor: NSColor.secondaryLabelColor, .paragraphStyle: style])
|
|
232
261
|
}
|
|
233
262
|
}
|
|
@@ -280,6 +309,29 @@ struct AvailabilityReminder: Codable {
|
|
|
280
309
|
}
|
|
281
310
|
func reminderWindows(_ windows: [UsageWindow]) -> [UsageWindow] { windows.filter { ["five_hour:primary", "seven_day:primary"].contains($0.id) } }
|
|
282
311
|
|
|
312
|
+
enum LoginStartup {
|
|
313
|
+
static let label = "com.unionschool.easy-claude.login"
|
|
314
|
+
static var file: URL {
|
|
315
|
+
FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("Library/LaunchAgents/" + label + ".plist")
|
|
316
|
+
}
|
|
317
|
+
static func enabled(at file: URL = file) -> Bool { FileManager.default.fileExists(atPath: file.path) }
|
|
318
|
+
static func setEnabled(_ enabled: Bool, node: String, cli: String, environment: [String: String], at file: URL = file) throws {
|
|
319
|
+
if !enabled {
|
|
320
|
+
if self.enabled(at: file) { try FileManager.default.removeItem(at: file) }
|
|
321
|
+
return
|
|
322
|
+
}
|
|
323
|
+
guard node.hasPrefix("/"), cli.hasPrefix("/"),
|
|
324
|
+
FileManager.default.isExecutableFile(atPath: node), FileManager.default.fileExists(atPath: cli) else {
|
|
325
|
+
throw NSError(domain: label, code: 1, userInfo: [NSLocalizedDescriptionKey: "启动路径无效,请从正式安装的命令重新打开浮窗"])
|
|
326
|
+
}
|
|
327
|
+
let config: [String: Any] = ["Label": label, "ProgramArguments": [node, cli, "show"],
|
|
328
|
+
"RunAtLoad": true, "EnvironmentVariables": environment]
|
|
329
|
+
let data = try PropertyListSerialization.data(fromPropertyList: config, format: .xml, options: 0)
|
|
330
|
+
try FileManager.default.createDirectory(at: file.deletingLastPathComponent(), withIntermediateDirectories: true)
|
|
331
|
+
try data.write(to: file, options: .atomic)
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
283
335
|
@MainActor
|
|
284
336
|
final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNotificationCenterDelegate {
|
|
285
337
|
let panel = NSPanel(contentRect: CGRect(x: 0, y: 0, width: 32, height: 32),
|
|
@@ -292,6 +344,7 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
292
344
|
var clockEnabled = true
|
|
293
345
|
var followIPTimeZone = UserDefaults.standard.bool(forKey: "followIPTimeZone")
|
|
294
346
|
var ipClock = IPClockState()
|
|
347
|
+
var ipClockCity: String?
|
|
295
348
|
var manualClockZone = TimeZone(identifier: "America/Los_Angeles")!
|
|
296
349
|
var manualClockCity = "硅谷"
|
|
297
350
|
var status: NSStatusItem?
|
|
@@ -466,11 +519,12 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
466
519
|
}
|
|
467
520
|
func applyClockTimeZone() {
|
|
468
521
|
clock.zone = ipClock.resolved(manual: manualClockZone, following: followIPTimeZone)
|
|
469
|
-
clock.cityName = followIPTimeZone && ipClock.zone != nil ? "
|
|
522
|
+
clock.cityName = followIPTimeZone && ipClock.zone != nil ? (ipClockCity ?? "城市未知") : manualClockCity
|
|
470
523
|
clock.needsDisplay = true
|
|
471
524
|
}
|
|
472
|
-
func receiveIPTimeZone(_ identifier: String?) {
|
|
525
|
+
func receiveIPTimeZone(_ identifier: String?, city: String? = nil) {
|
|
473
526
|
_ = ipClock.update(identifier)
|
|
527
|
+
ipClockCity = ipClock.zone == nil ? nil : city
|
|
474
528
|
applyClockTimeZone()
|
|
475
529
|
}
|
|
476
530
|
@objc func toggleFollowIPTimeZone() {
|
|
@@ -495,10 +549,11 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
495
549
|
let value = try? JSONDecoder().decode(PublicIP.self, from: data)
|
|
496
550
|
let text = publicIPText(ip: process.terminationStatus == 0 ? value?.ip : nil, city: value?.city)
|
|
497
551
|
let timezone = process.terminationStatus == 0 ? value?.timezone : nil
|
|
552
|
+
let city = process.terminationStatus == 0 ? value?.city : nil
|
|
498
553
|
Task { @MainActor in
|
|
499
554
|
guard let self else { return }
|
|
500
555
|
self.ipQuery = nil; self.ipText = text
|
|
501
|
-
self.receiveIPTimeZone(timezone)
|
|
556
|
+
self.receiveIPTimeZone(timezone, city: city)
|
|
502
557
|
}
|
|
503
558
|
}
|
|
504
559
|
ipQuery = process
|
|
@@ -651,9 +706,27 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
651
706
|
menu.addItem(automatic)
|
|
652
707
|
if let automaticUpdateError { menu.addItem(item(automaticUpdateError, nil)) }
|
|
653
708
|
if let versionCheckError { menu.addItem(item(versionCheckError, nil)) }
|
|
709
|
+
let startup = item("开机启动", #selector(toggleLoginStartup))
|
|
710
|
+
startup.state = LoginStartup.enabled() ? .on : .off
|
|
711
|
+
startup.toolTip = "登录当前macOS用户后自动打开浮窗"
|
|
712
|
+
menu.addItem(startup)
|
|
654
713
|
menu.addItem(item("退出浮窗", #selector(quit)))
|
|
655
714
|
return menu
|
|
656
715
|
}
|
|
716
|
+
@objc func toggleLoginStartup() {
|
|
717
|
+
do {
|
|
718
|
+
let cli = URL(fileURLWithPath: script).deletingLastPathComponent().deletingLastPathComponent()
|
|
719
|
+
.appendingPathComponent("bin/easy-claude.js").path
|
|
720
|
+
let environment = ["PATH": searchPath]
|
|
721
|
+
|
|
722
|
+
try LoginStartup.setEnabled(!LoginStartup.enabled(), node: node, cli: cli, environment: environment)
|
|
723
|
+
} catch {
|
|
724
|
+
let alert = NSAlert()
|
|
725
|
+
alert.messageText = "无法设置开机启动"
|
|
726
|
+
alert.informativeText = error.localizedDescription
|
|
727
|
+
alert.runModal()
|
|
728
|
+
}
|
|
729
|
+
}
|
|
657
730
|
func menuNeedsUpdate(_ menu: NSMenu) {
|
|
658
731
|
menu.removeAllItems()
|
|
659
732
|
let fresh = makeMenu()
|
|
@@ -869,13 +942,59 @@ struct Main {
|
|
|
869
942
|
precondition(ipClockTest.update("Asia/Singapore"))
|
|
870
943
|
precondition(ipClockTest.resolved(manual: manualIPTest, following: true).identifier == "Asia/Singapore")
|
|
871
944
|
_ = NSApplication.shared
|
|
945
|
+
let periodZone = TimeZone(secondsFromGMT: 0)!
|
|
946
|
+
for (minutes, expected) in [(0,"凌晨"),(359,"凌晨"),(360,"上午"),(719,"上午"),(720,"下午"),(1079,"下午"),(1080,"晚上"),(1259,"晚上"),(1260,"深夜"),(1439,"深夜")] {
|
|
947
|
+
let date = Date(timeIntervalSince1970: Double(minutes * 60))
|
|
948
|
+
precondition(clockPeriod(at: date, zone: periodZone) == expected)
|
|
949
|
+
precondition(clockText(at: date, zone: periodZone, locale: Locale(identifier: "en_US")).contains(expected))
|
|
950
|
+
}
|
|
951
|
+
let midnight = Date(timeIntervalSince1970: 12 * 60)
|
|
952
|
+
precondition(clockText(at: midnight, zone: periodZone, locale: Locale(identifier: "en_US")) == "凌晨 00:12")
|
|
953
|
+
precondition(clockText(at: midnight, zone: periodZone, locale: Locale(identifier: "en_GB")) == "00:12")
|
|
954
|
+
precondition(clockText(at: Date(timeIntervalSince1970: 12 * 3600 + 12 * 60), zone: periodZone, locale: Locale(identifier: "en_US")) == "下午 12:12")
|
|
955
|
+
precondition(clockPeriod(at: midnight, zone: TimeZone(identifier: "Asia/Shanghai")!) == "上午")
|
|
956
|
+
let startupTest = FileManager.default.temporaryDirectory.appendingPathComponent("easy-startup-" + UUID().uuidString)
|
|
957
|
+
let startupFile = startupTest.appendingPathComponent("launch.plist")
|
|
958
|
+
do {
|
|
959
|
+
defer { try? FileManager.default.removeItem(at: startupTest) }
|
|
960
|
+
precondition(!LoginStartup.enabled(at: startupFile))
|
|
961
|
+
try FileManager.default.createDirectory(at: startupTest, withIntermediateDirectories: true)
|
|
962
|
+
let cli = startupTest.appendingPathComponent("tool with spaces.js")
|
|
963
|
+
try Data().write(to: cli)
|
|
964
|
+
try LoginStartup.setEnabled(true, node: "/usr/bin/true", cli: cli.path, environment: ["PATH":"/usr/bin"], at: startupFile)
|
|
965
|
+
precondition(LoginStartup.enabled(at: startupFile))
|
|
966
|
+
let config = try PropertyListSerialization.propertyList(from: Data(contentsOf: startupFile), options: [], format: nil) as! [String: Any]
|
|
967
|
+
precondition(config["ProgramArguments"] as? [String] == ["/usr/bin/true", cli.path, "show"])
|
|
968
|
+
precondition(config["RunAtLoad"] as? Bool == true && config["KeepAlive"] == nil)
|
|
969
|
+
try LoginStartup.setEnabled(false, node: "", cli: "", environment: [:], at: startupFile)
|
|
970
|
+
precondition(!LoginStartup.enabled(at: startupFile))
|
|
971
|
+
do {
|
|
972
|
+
try LoginStartup.setEnabled(true, node: "relative", cli: cli.path, environment: [:], at: startupFile)
|
|
973
|
+
preconditionFailure("无效启动路径不得保存")
|
|
974
|
+
} catch { precondition(!LoginStartup.enabled(at: startupFile)) }
|
|
975
|
+
} catch { preconditionFailure("登录启动配置测试失败:\(error)") }
|
|
976
|
+
print("12小时时段边界、零点/正午及登录启动开关自检通过")
|
|
977
|
+
|
|
978
|
+
for time in ["8:52", "12:59", "上午8:52"] {
|
|
979
|
+
let font = fittedClockFont(for: time, width: 96, baseSize: 20)
|
|
980
|
+
let width = (time as NSString).size(withAttributes: [.font: font]).width
|
|
981
|
+
for city in ["Los Angeles", "上海", String(repeating: "W", count: 60)] {
|
|
982
|
+
let cityFont = fittedClockFont(for: city, width: width, baseSize: 10)
|
|
983
|
+
precondition((city as NSString).size(withAttributes: [.font: cityFont]).width <= width + 0.01)
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
|
|
872
987
|
let clockMenuTest = Overlay()
|
|
873
988
|
clockMenuTest.manualClockZone = manualIPTest
|
|
874
989
|
clockMenuTest.manualClockCity = "上海"
|
|
875
990
|
clockMenuTest.followIPTimeZone = true
|
|
876
|
-
|
|
991
|
+
clockMenuTest.receiveIPTimeZone("America/Los_Angeles", city: "Los Angeles")
|
|
877
992
|
clockMenuTest.applyClockTimeZone()
|
|
878
993
|
precondition(clockMenuTest.clock.zone.identifier == "America/Los_Angeles")
|
|
994
|
+
precondition(clockMenuTest.clock.cityName == "Los Angeles")
|
|
995
|
+
clockMenuTest.receiveIPTimeZone("America/Los_Angeles")
|
|
996
|
+
precondition(clockMenuTest.clock.cityName == "城市未知")
|
|
997
|
+
clockMenuTest.receiveIPTimeZone("America/Los_Angeles", city: "Los Angeles")
|
|
879
998
|
precondition(!clockMenuTest.makeMenu().items.contains { $0.submenu != nil })
|
|
880
999
|
clockMenuTest.receiveIPTimeZone(nil)
|
|
881
1000
|
precondition(clockMenuTest.clock.zone == manualIPTest && clockMenuTest.clock.cityName == "上海")
|
|
@@ -931,13 +1050,13 @@ struct Main {
|
|
|
931
1050
|
let afternoon = ISO8601DateFormatter().date(from: "2026-10-21T14:30:00Z")!
|
|
932
1051
|
for identifier in ["en_US", "en_GB", "zh_CN"] {
|
|
933
1052
|
let text = clockText(at: afternoon, zone: countdownUTC, locale: Locale(identifier: identifier))
|
|
934
|
-
if identifier == "en_US" { precondition(text.contains("
|
|
1053
|
+
if identifier == "en_US" { precondition(text.contains("下午") && !text.contains("14:30")) }
|
|
935
1054
|
else { precondition(text == "14:30") }
|
|
936
1055
|
let font = fittedClockFont(for: text, width: 96, baseSize: 20)
|
|
937
1056
|
precondition((text as NSString).size(withAttributes: [.font: font]).width <= 96 - 1)
|
|
938
1057
|
}
|
|
939
1058
|
let laClock = clockText(at: afternoon, zone: TimeZone(identifier: "America/Los_Angeles")!, locale: Locale(identifier: "en_US"))
|
|
940
|
-
precondition(laClock.contains("7:30") && laClock.contains("
|
|
1059
|
+
precondition(laClock.contains("7:30") && laClock.contains("上午"))
|
|
941
1060
|
|
|
942
1061
|
let morning = ISO8601DateFormatter().date(from: "2026-10-21T02:30:00Z")!
|
|
943
1062
|
for weekly in [false, true] {
|
|
@@ -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.3.
|
|
8
|
+
<key>CFBundleShortVersionString</key><string>0.3.4</string>
|
|
9
9
|
<key>LSMinimumSystemVersion</key><string>14.0</string>
|
|
10
10
|
<key>LSUIElement</key><true/>
|
|
11
11
|
<key>NSHighResolutionCapable</key><true/>
|
|
Binary file
|
package/package.json
CHANGED
package/src/public-ip.js
CHANGED
|
@@ -16,24 +16,20 @@ export async function readPublicIP({ run = promisify(execFile), env = process.en
|
|
|
16
16
|
});
|
|
17
17
|
return stdout;
|
|
18
18
|
};
|
|
19
|
-
let
|
|
20
|
-
try {
|
|
19
|
+
let data;
|
|
20
|
+
try { data = JSON.parse(await request('https://ipinfo.io/json')); }
|
|
21
21
|
catch { throw new Error('IP异常'); }
|
|
22
|
-
if (!isIP(ip)) throw new Error('IP异常');
|
|
22
|
+
if (!data || typeof data.ip !== 'string' || !isIP(data.ip)) throw new Error('IP异常');
|
|
23
|
+
const ip = data.ip;
|
|
23
24
|
let city = null, timezone = null;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
timezone = data.timezone;
|
|
34
|
-
} catch { /* 无效时区保持未知,不改用电脑时区。 */ }
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
} catch { /* 城市查询失败仍保留已确认的IP。 */ }
|
|
25
|
+
if (typeof data.city === 'string') {
|
|
26
|
+
city = data.city.replace(/[\x00-\x1f\x7f-\x9f]/g, ' ').trim().slice(0, 60) || null;
|
|
27
|
+
}
|
|
28
|
+
if (typeof data.timezone === 'string' && data.timezone.length <= 100) {
|
|
29
|
+
try {
|
|
30
|
+
new Intl.DateTimeFormat('en', { timeZone: data.timezone });
|
|
31
|
+
timezone = data.timezone;
|
|
32
|
+
} catch { /* 无效时区保持未知,不改用电脑时区。 */ }
|
|
33
|
+
}
|
|
38
34
|
return { ip, city, timezone };
|
|
39
35
|
}
|