easy-claude 0.2.13 → 0.3.3
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,6 +1,13 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
-
## v0.
|
|
3
|
+
## v0.3.3(2026-10-20,America/Los_Angeles)
|
|
4
|
+
|
|
5
|
+
- 改为只请求一次 `https://ipinfo.io/json`,同时获取当前网络出口的公网IP、城市和时区;继续支持环境及系统HTTPS代理。
|
|
6
|
+
- 跟随IP时区时,浮窗时间下方显示接口返回的城市名称,例如 `Los Angeles`,不再显示“IP时区”;时间仍按接口返回的时区计算。
|
|
7
|
+
- 城市名称居中,最大宽度不超过时间文字的实际宽度,过长自动缩小字号。
|
|
8
|
+
- 获取不到IP或有效时区时继续显示自定义时区时间;城市缺失显示“城市未知”。不改变已保存的时区、位置和开关。
|
|
9
|
+
|
|
10
|
+
## v0.3.1(2026-10-20,America/Los_Angeles)
|
|
4
11
|
|
|
5
12
|
- 新增“跟随IP时区”开关,默认关闭;开启后自动显示网络出口时区时间并隐藏手动时区选择,关闭恢复原城市和时区。
|
|
6
13
|
- 获取不到IP或有效时区时显示自定义时区的时间;开关保持开启,后续获取成功自动继续跟随。继续支持系统12/24小时制与夏令时。
|
package/README.md
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
需要 Node.js 22+ 与 Claude Code 订阅登录;不支持把 API Key 账单余额当作订阅额度。
|
|
6
6
|
|
|
7
|
-
## v0.
|
|
7
|
+
## v0.3.3 更新说明
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
9
|
+
- 改为只请求一次 `https://ipinfo.io/json`,同时获取当前网络出口的公网IP、城市和时区;继续支持环境及系统HTTPS代理。
|
|
10
|
+
- 跟随IP时区时,浮窗时间下方显示接口返回的城市名称,例如 `Los Angeles`,不再显示“IP时区”;时间仍按接口返回的时区计算。
|
|
11
|
+
- 城市名称居中,最大宽度不超过时间文字的实际宽度,过长自动缩小字号。
|
|
12
|
+
- 获取不到IP或有效时区时继续显示自定义时区时间;城市缺失显示“城市未知”。不改变已保存的时区、位置和开关。
|
|
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,6 @@ 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地理数据可能不准确,跟随的是出口时区,不修改电脑系统时区。
|
package/native/Overlay.swift
CHANGED
|
@@ -200,8 +200,16 @@ func clockText(at date: Date, zone: TimeZone, locale: Locale = .autoupdatingCurr
|
|
|
200
200
|
func fittedClockFont(for text: String, width: CGFloat, baseSize: CGFloat) -> NSFont {
|
|
201
201
|
let base = NSFont.monospacedDigitSystemFont(ofSize: baseSize, weight: .medium)
|
|
202
202
|
let measured = max(1, (text as NSString).size(withAttributes: [.font: base]).width)
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
var size = min(baseSize, baseSize * max(1, width - 2) / measured)
|
|
204
|
+
var font = NSFont.monospacedDigitSystemFont(ofSize: size, weight: .medium)
|
|
205
|
+
// 字体在小字号下的实际字宽不完全按比例缩放,按实测宽度校正。
|
|
206
|
+
for _ in 0..<6 {
|
|
207
|
+
let actual = (text as NSString).size(withAttributes: [.font: font]).width
|
|
208
|
+
if actual <= width { break }
|
|
209
|
+
size *= width / actual * 0.95
|
|
210
|
+
font = NSFont.monospacedDigitSystemFont(ofSize: size, weight: .medium)
|
|
211
|
+
}
|
|
212
|
+
return font
|
|
205
213
|
}
|
|
206
214
|
|
|
207
215
|
func clockState(at date: Date, zone: TimeZone) -> RingState {
|
|
@@ -222,12 +230,14 @@ final class ClockView: RingView {
|
|
|
222
230
|
style.alignment = .center
|
|
223
231
|
let now = Date()
|
|
224
232
|
let time = clockText(at: now, zone: zone)
|
|
233
|
+
let timeFont = fittedClockFont(for: time, width: bounds.width, baseSize: 20)
|
|
234
|
+
let timeWidth = (time as NSString).size(withAttributes: [.font: timeFont]).width
|
|
225
235
|
(time as NSString).draw(in: CGRect(x: 0, y: 17, width: bounds.width, height: 25),
|
|
226
|
-
withAttributes: [.font:
|
|
236
|
+
withAttributes: [.font: timeFont,
|
|
227
237
|
.foregroundColor: clockState(at: now, zone: zone).color, .paragraphStyle: style])
|
|
228
238
|
let city = cityName
|
|
229
239
|
(city as NSString).draw(in: CGRect(x: 0, y: 1, width: bounds.width, height: 15),
|
|
230
|
-
withAttributes: [.font:
|
|
240
|
+
withAttributes: [.font: fittedClockFont(for: city, width: timeWidth, baseSize: 10),
|
|
231
241
|
.foregroundColor: NSColor.secondaryLabelColor, .paragraphStyle: style])
|
|
232
242
|
}
|
|
233
243
|
}
|
|
@@ -292,6 +302,7 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
292
302
|
var clockEnabled = true
|
|
293
303
|
var followIPTimeZone = UserDefaults.standard.bool(forKey: "followIPTimeZone")
|
|
294
304
|
var ipClock = IPClockState()
|
|
305
|
+
var ipClockCity: String?
|
|
295
306
|
var manualClockZone = TimeZone(identifier: "America/Los_Angeles")!
|
|
296
307
|
var manualClockCity = "硅谷"
|
|
297
308
|
var status: NSStatusItem?
|
|
@@ -466,11 +477,12 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
466
477
|
}
|
|
467
478
|
func applyClockTimeZone() {
|
|
468
479
|
clock.zone = ipClock.resolved(manual: manualClockZone, following: followIPTimeZone)
|
|
469
|
-
clock.cityName = followIPTimeZone && ipClock.zone != nil ? "
|
|
480
|
+
clock.cityName = followIPTimeZone && ipClock.zone != nil ? (ipClockCity ?? "城市未知") : manualClockCity
|
|
470
481
|
clock.needsDisplay = true
|
|
471
482
|
}
|
|
472
|
-
func receiveIPTimeZone(_ identifier: String?) {
|
|
483
|
+
func receiveIPTimeZone(_ identifier: String?, city: String? = nil) {
|
|
473
484
|
_ = ipClock.update(identifier)
|
|
485
|
+
ipClockCity = ipClock.zone == nil ? nil : city
|
|
474
486
|
applyClockTimeZone()
|
|
475
487
|
}
|
|
476
488
|
@objc func toggleFollowIPTimeZone() {
|
|
@@ -495,10 +507,11 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
495
507
|
let value = try? JSONDecoder().decode(PublicIP.self, from: data)
|
|
496
508
|
let text = publicIPText(ip: process.terminationStatus == 0 ? value?.ip : nil, city: value?.city)
|
|
497
509
|
let timezone = process.terminationStatus == 0 ? value?.timezone : nil
|
|
510
|
+
let city = process.terminationStatus == 0 ? value?.city : nil
|
|
498
511
|
Task { @MainActor in
|
|
499
512
|
guard let self else { return }
|
|
500
513
|
self.ipQuery = nil; self.ipText = text
|
|
501
|
-
self.receiveIPTimeZone(timezone)
|
|
514
|
+
self.receiveIPTimeZone(timezone, city: city)
|
|
502
515
|
}
|
|
503
516
|
}
|
|
504
517
|
ipQuery = process
|
|
@@ -869,13 +882,26 @@ struct Main {
|
|
|
869
882
|
precondition(ipClockTest.update("Asia/Singapore"))
|
|
870
883
|
precondition(ipClockTest.resolved(manual: manualIPTest, following: true).identifier == "Asia/Singapore")
|
|
871
884
|
_ = NSApplication.shared
|
|
885
|
+
for time in ["8:52", "12:59", "上午8:52"] {
|
|
886
|
+
let font = fittedClockFont(for: time, width: 96, baseSize: 20)
|
|
887
|
+
let width = (time as NSString).size(withAttributes: [.font: font]).width
|
|
888
|
+
for city in ["Los Angeles", "上海", String(repeating: "W", count: 60)] {
|
|
889
|
+
let cityFont = fittedClockFont(for: city, width: width, baseSize: 10)
|
|
890
|
+
precondition((city as NSString).size(withAttributes: [.font: cityFont]).width <= width + 0.01)
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
872
894
|
let clockMenuTest = Overlay()
|
|
873
895
|
clockMenuTest.manualClockZone = manualIPTest
|
|
874
896
|
clockMenuTest.manualClockCity = "上海"
|
|
875
897
|
clockMenuTest.followIPTimeZone = true
|
|
876
|
-
|
|
898
|
+
clockMenuTest.receiveIPTimeZone("America/Los_Angeles", city: "Los Angeles")
|
|
877
899
|
clockMenuTest.applyClockTimeZone()
|
|
878
900
|
precondition(clockMenuTest.clock.zone.identifier == "America/Los_Angeles")
|
|
901
|
+
precondition(clockMenuTest.clock.cityName == "Los Angeles")
|
|
902
|
+
clockMenuTest.receiveIPTimeZone("America/Los_Angeles")
|
|
903
|
+
precondition(clockMenuTest.clock.cityName == "城市未知")
|
|
904
|
+
clockMenuTest.receiveIPTimeZone("America/Los_Angeles", city: "Los Angeles")
|
|
879
905
|
precondition(!clockMenuTest.makeMenu().items.contains { $0.submenu != nil })
|
|
880
906
|
clockMenuTest.receiveIPTimeZone(nil)
|
|
881
907
|
precondition(clockMenuTest.clock.zone == manualIPTest && clockMenuTest.clock.cityName == "上海")
|
|
@@ -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.
|
|
8
|
+
<key>CFBundleShortVersionString</key><string>0.3.3</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
|
}
|