easy-claude 0.2.11 → 0.2.12
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 +5 -0
- package/README.md +9 -4
- package/native/Overlay.swift +44 -0
- 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/overlay-ip.js +3 -0
- package/src/public-ip.js +31 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## v0.2.12(2026-10-21)
|
|
4
|
+
|
|
5
|
+
- 菜单新增公网IP和城市,固定从ip.sb获取IP,再查询该IP的出口城市;启动及每5分钟刷新,点击地址可立即刷新。
|
|
6
|
+
- 获取不到IP时显示“IP异常”;仅城市查询失败时保留IP并显示“城市未知”。支持IPv4/IPv6和现有环境/系统HTTPS代理,不保存IP历史。
|
|
7
|
+
|
|
3
8
|
## v0.2.11(2026-10-21)
|
|
4
9
|
|
|
5
10
|
- 新增一次性“额度可用提醒”:同时受5小时和周额度限制时,等待较晚的恢复时间,在线确认全部可用后发送系统通知和提示音,随后自动关闭。
|
package/README.md
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
需要 Node.js 22+ 与 Claude Code 订阅登录;不支持把 API Key 账单余额当作订阅额度。
|
|
6
6
|
|
|
7
|
-
## v0.2.
|
|
7
|
+
## v0.2.12 更新说明
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- 更新锁改为系统内核锁,异常强退后自动释放;安装仍在运行时保持排他,旧锁目录无需手动清理。
|
|
9
|
+
- 菜单新增公网IP和城市,固定从ip.sb获取IP,再查询该IP的出口城市;启动及每5分钟刷新,点击地址可立即刷新。
|
|
10
|
+
- 获取不到IP时显示“IP异常”;仅城市查询失败时保留IP并显示“城市未知”。支持IPv4/IPv6和现有环境/系统HTTPS代理,不保存IP历史。
|
|
12
11
|
|
|
13
12
|
历史版本更新记录见 [CHANGELOG](CHANGELOG.md)。
|
|
14
13
|
|
|
@@ -90,3 +89,9 @@ npm run build:overlay
|
|
|
90
89
|
只有5小时或只有周额度时等待对应恢复;两项都耗尽时等待较晚时间,仍有剩余的窗口不参与等待。到点后约每分钟查询,确认所有已知窗口均有剩余,才发送一次系统通知和提示音,然后自动关闭开关。若等待期间再次耗尽,会继续等到有效恢复。
|
|
91
90
|
|
|
92
91
|
开启状态跨更新/重启保存;关闭可取消。浮窗运行时即使目标应用不在前台也能检查,断网则保留提醒并重试。休眠会延后至唤醒,工具完全退出期间不能提醒,重新启动后补查;系统通知权限、专注模式和声音设置可能影响通知展示或声音。不调用模型、不消耗对话额度。
|
|
92
|
+
|
|
93
|
+
## 公网IP与城市
|
|
94
|
+
|
|
95
|
+
菜单显示“公网IP·地址·城市”,由 `https://ip.sb/ip` 获取IP,再通过 `https://api.ip.sb/geoip/<IP>` 获取对应城市;城市名称按接口返回显示。启动和每5分钟刷新,点击该菜单项可立即重查。IP取不到显示“IP异常”;城市取不到显示“城市未知”。
|
|
96
|
+
|
|
97
|
+
查询遵循已有HTTPS/ALL代理环境或macOS系统HTTPS代理。这里显示查询服务看到的网络出口;Clash分流时可能与AI请求不同,城市不代表电脑所在地,也不改变时钟时区。不主动保存IP历史,不发送账号凭据。
|
package/native/Overlay.swift
CHANGED
|
@@ -232,6 +232,15 @@ final class ClockView: RingView {
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
struct PublicIP: Decodable {
|
|
236
|
+
let ip: String?
|
|
237
|
+
let city: String?
|
|
238
|
+
}
|
|
239
|
+
func publicIPText(ip: String?, city: String?) -> String {
|
|
240
|
+
guard let ip, !ip.isEmpty else { return "IP异常" }
|
|
241
|
+
return "公网IP·\(ip)·\(city ?? "城市未知")"
|
|
242
|
+
}
|
|
243
|
+
|
|
235
244
|
// 只等待耗尽窗口,但确认恢复时必须同时检查所有已知窗口,缺失或未知不能报可用。
|
|
236
245
|
struct AvailabilityReminder: Codable {
|
|
237
246
|
var ids: [String]
|
|
@@ -272,6 +281,9 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
272
281
|
var clockEnabled = true
|
|
273
282
|
var status: NSStatusItem?
|
|
274
283
|
var timer: Timer?
|
|
284
|
+
var ipQuery: Process?
|
|
285
|
+
var ipLastAttempt = Date.distantPast
|
|
286
|
+
var ipText = "正在获取IP…"
|
|
275
287
|
var query: Process?
|
|
276
288
|
var updater: Process?
|
|
277
289
|
var versionCheck: Process?
|
|
@@ -358,6 +370,7 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
358
370
|
@objc func hide() { panel.orderOut(nil); clockPanel.orderOut(nil) }
|
|
359
371
|
@objc func tick() {
|
|
360
372
|
checkVersionIfNeeded()
|
|
373
|
+
if Date().timeIntervalSince(ipLastAttempt) >= 300 { refreshIP() }
|
|
361
374
|
if let reminder, Date().timeIntervalSince(lastAttempt) >= (Date().timeIntervalSince1970 >= reminder.due ? 60 : 300) { refresh() }
|
|
362
375
|
guard let rect = targetWindow() else { hide(); lastRect = nil; return }
|
|
363
376
|
lastRect = rect
|
|
@@ -434,6 +447,30 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
434
447
|
do { try process.run() }
|
|
435
448
|
catch { query = nil; self.error = "无法启动额度查询,请重新运行 easy-claude show"; updateRing() }
|
|
436
449
|
}
|
|
450
|
+
@objc func refreshIP() {
|
|
451
|
+
guard ipQuery == nil else { return }
|
|
452
|
+
ipLastAttempt = Date()
|
|
453
|
+
let process = Process(), pipe = Pipe()
|
|
454
|
+
process.executableURL = URL(fileURLWithPath: node)
|
|
455
|
+
process.arguments = [URL(fileURLWithPath: script).deletingLastPathComponent().appendingPathComponent("overlay-ip.js").path]
|
|
456
|
+
var env = ProcessInfo.processInfo.environment
|
|
457
|
+
env["PATH"] = searchPath
|
|
458
|
+
process.environment = env
|
|
459
|
+
process.standardOutput = pipe
|
|
460
|
+
process.standardError = FileHandle.nullDevice
|
|
461
|
+
process.terminationHandler = { [weak self] process in
|
|
462
|
+
let data = pipe.fileHandleForReading.readDataToEndOfFile()
|
|
463
|
+
let value = try? JSONDecoder().decode(PublicIP.self, from: data)
|
|
464
|
+
let text = publicIPText(ip: process.terminationStatus == 0 ? value?.ip : nil, city: value?.city)
|
|
465
|
+
Task { @MainActor in
|
|
466
|
+
guard let self else { return }
|
|
467
|
+
self.ipQuery = nil; self.ipText = text
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
ipQuery = process
|
|
471
|
+
do { try process.run() }
|
|
472
|
+
catch { ipQuery = nil; ipText = "IP异常" }
|
|
473
|
+
}
|
|
437
474
|
func saveReminder() {
|
|
438
475
|
if let reminder, let data = try? JSONEncoder().encode(reminder) {
|
|
439
476
|
UserDefaults.standard.set(data, forKey: "availabilityReminder")
|
|
@@ -516,6 +553,9 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
516
553
|
menu.addItem(item(lastRect == nil ? "等待 Claude 前台窗口" : "拖动圆环可调整位置", nil))
|
|
517
554
|
if let error { menu.addItem(item(error, nil)) }
|
|
518
555
|
if snapshot?.restricted == true { menu.addItem(item("服务端提示:当前使用受限", nil)) }
|
|
556
|
+
let address = item(ipText, ipQuery == nil ? #selector(refreshIP) : nil)
|
|
557
|
+
address.toolTip = "点击刷新公网IP;城市为网络出口位置"
|
|
558
|
+
menu.addItem(address)
|
|
519
559
|
menu.addItem(.separator())
|
|
520
560
|
for (id, label) in [("five_hour:primary", "5小时"), ("seven_day:primary", "周")] {
|
|
521
561
|
guard let window = snapshot?.windows.first(where: { $0.id == id }) else { continue }
|
|
@@ -745,6 +785,7 @@ final class Overlay: NSObject, NSApplicationDelegate, NSMenuDelegate, UNUserNoti
|
|
|
745
785
|
}
|
|
746
786
|
@objc func quit() { NSApp.terminate(nil) }
|
|
747
787
|
func applicationWillTerminate(_ notification: Notification) {
|
|
788
|
+
ipQuery?.terminate()
|
|
748
789
|
timer?.invalidate()
|
|
749
790
|
query?.terminate()
|
|
750
791
|
versionCheck?.terminate()
|
|
@@ -772,6 +813,9 @@ struct Main {
|
|
|
772
813
|
}
|
|
773
814
|
|
|
774
815
|
if CommandLine.arguments.contains("--self-test") {
|
|
816
|
+
precondition(publicIPText(ip: nil, city: "City") == "IP异常")
|
|
817
|
+
precondition(publicIPText(ip: "203.0.113.1", city: nil) == "公网IP·203.0.113.1·城市未知")
|
|
818
|
+
precondition(publicIPText(ip: "203.0.113.1", city: "City") == "公网IP·203.0.113.1·City")
|
|
775
819
|
func quota(_ id: String, _ remaining: Double?, _ reset: Double?) -> UsageWindow {
|
|
776
820
|
UsageWindow(id: id, label: id, name: id, remaining: remaining, resetsAt: reset)
|
|
777
821
|
}
|
|
@@ -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.
|
|
8
|
+
<key>CFBundleShortVersionString</key><string>0.2.12</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
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { isIP } from 'node:net';
|
|
4
|
+
import { systemProxy } from './transport.js';
|
|
5
|
+
|
|
6
|
+
export async function readPublicIP({ run = promisify(execFile), env = process.env, platform = process.platform } = {}) {
|
|
7
|
+
let proxy = env.https_proxy || env.HTTPS_PROXY || env.all_proxy || env.ALL_PROXY;
|
|
8
|
+
if (!proxy && platform === 'darwin') {
|
|
9
|
+
const { stdout } = await run('/usr/sbin/scutil', ['--proxy'], { timeout: 2000, maxBuffer: 65536 });
|
|
10
|
+
proxy = systemProxy(stdout);
|
|
11
|
+
}
|
|
12
|
+
const request = async url => {
|
|
13
|
+
const { stdout } = await run('/usr/bin/curl', ['-q', '--silent', '--show-error', '--fail', '--proto', '=https',
|
|
14
|
+
'--connect-timeout', '5', '--max-time', '12', '--max-redirs', '0', url], {
|
|
15
|
+
timeout: 15000, maxBuffer: 8192, env: proxy ? { ...env, https_proxy: proxy } : env
|
|
16
|
+
});
|
|
17
|
+
return stdout;
|
|
18
|
+
};
|
|
19
|
+
let ip;
|
|
20
|
+
try { ip = (await request('https://ip.sb/ip')).trim(); }
|
|
21
|
+
catch { throw new Error('IP异常'); }
|
|
22
|
+
if (!isIP(ip)) throw new Error('IP异常');
|
|
23
|
+
let city = null;
|
|
24
|
+
try {
|
|
25
|
+
const data = JSON.parse(await request('https://api.ip.sb/geoip/' + ip));
|
|
26
|
+
if (data.ip === ip && typeof data.city === 'string') {
|
|
27
|
+
city = data.city.replace(/[\x00-\x1f\x7f-\x9f]/g, ' ').trim().slice(0, 60) || null;
|
|
28
|
+
}
|
|
29
|
+
} catch { /* 城市查询失败仍保留已确认的IP。 */ }
|
|
30
|
+
return { ip, city };
|
|
31
|
+
}
|