dsh-gufa-code 1.3.1 → 1.3.2
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/client.js +3 -2
- package/desktop/float/GufaFloat.m +17 -7
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +16 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/_CodeSignature/CodeResources +115 -0
- package/host/dev.js +117 -71
- package/package.json +1 -1
- package/scripts/build-float-macos.sh +30 -2
- package/src/client/90-app.js +3 -2
package/client.js
CHANGED
|
@@ -11521,11 +11521,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11521
11521
|
'div',
|
|
11522
11522
|
{ className: 'gufa-float-permission' },
|
|
11523
11523
|
h('div', { className: 'gufa-float-permission-title' }, '需要「屏幕录制」权限'),
|
|
11524
|
-
h('div', { className: 'gufa-hint' }, '摸鱼列表需要读取其他 App
|
|
11524
|
+
h('div', { className: 'gufa-hint' }, '摸鱼列表需要读取其他 App 的窗口尺寸(只读尺寸,不录屏)。系统只认悬浮层 App 自己的授权:请在「系统设置 → 隐私与安全性 → 屏幕录制」里点左下角「+」,添加「古法编程悬浮层.app」并打开开关(DeepSeek Harness 的开关也保持打开)。加好后点「重试」。'),
|
|
11525
11525
|
h(
|
|
11526
11526
|
'div',
|
|
11527
|
-
{ className: 'gufa-row', style: { gap: 8, marginTop: 12 } },
|
|
11527
|
+
{ className: 'gufa-row', style: { gap: 8, marginTop: 12, flexWrap: 'wrap' } },
|
|
11528
11528
|
h(G.Button, { primary: true, onClick: () => void G.api('float.openPrivacy').catch(() => {}) }, '打开系统设置'),
|
|
11529
|
+
h(G.Button, { onClick: () => void G.api('float.revealHelper').catch(() => {}) }, '在 Finder 中显示悬浮层 App'),
|
|
11529
11530
|
h(G.Button, { onClick: () => void openFloatPicker() }, '重试'),
|
|
11530
11531
|
),
|
|
11531
11532
|
)
|
|
@@ -530,13 +530,23 @@ static NSArray<NSDictionary *> *GufaEnumerateWindows(void) {
|
|
|
530
530
|
return rows;
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
-
static
|
|
534
|
-
|
|
533
|
+
static NSString *GufaOutputPath = nil;
|
|
534
|
+
|
|
535
|
+
static void GufaEmitJSON(NSDictionary *out) {
|
|
535
536
|
NSData *json = [NSJSONSerialization dataWithJSONObject:out options:0 error:NULL];
|
|
536
|
-
if (json
|
|
537
|
+
if (json == nil) return;
|
|
538
|
+
if (GufaOutputPath.length > 0) {
|
|
539
|
+
[json writeToFile:GufaOutputPath atomically:YES];
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
fwrite(json.bytes, 1, json.length, stdout);
|
|
537
543
|
fputc('\n', stdout);
|
|
538
544
|
}
|
|
539
545
|
|
|
546
|
+
static void GufaPrintPermissionResult(void) {
|
|
547
|
+
GufaEmitJSON(@{@"ok": @NO, @"permission": @"screen-recording"});
|
|
548
|
+
}
|
|
549
|
+
|
|
540
550
|
/** 没权限时 CGWindowList 只返回「自己这个 App」的窗口;据此判断权限,而不是信 CGPreflight。 */
|
|
541
551
|
static BOOL GufaRowsHaveForeignWindows(NSArray<NSDictionary *> *rows) {
|
|
542
552
|
NSString *own = NSProcessInfo.processInfo.processName;
|
|
@@ -558,16 +568,16 @@ static int GufaListWindowsMode(void) {
|
|
|
558
568
|
GufaPrintPermissionResult();
|
|
559
569
|
return 2;
|
|
560
570
|
}
|
|
561
|
-
|
|
562
|
-
NSData *json = [NSJSONSerialization dataWithJSONObject:out options:0 error:NULL];
|
|
563
|
-
fwrite(json.bytes, 1, json.length, stdout);
|
|
564
|
-
fputc('\n', stdout);
|
|
571
|
+
GufaEmitJSON(@{@"ok": @YES, @"windows": rows});
|
|
565
572
|
return 0;
|
|
566
573
|
}
|
|
567
574
|
|
|
568
575
|
int main(int argc, const char *argv[]) {
|
|
569
576
|
if (argc > 1 && strcmp(argv[1], "--list-windows") == 0) {
|
|
570
577
|
@autoreleasepool {
|
|
578
|
+
for (int i = 2; i + 1 < argc; i++) {
|
|
579
|
+
if (strcmp(argv[i], "--out") == 0) GufaOutputPath = [NSString stringWithUTF8String:argv[i + 1]];
|
|
580
|
+
}
|
|
571
581
|
return GufaListWindowsMode();
|
|
572
582
|
}
|
|
573
583
|
}
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleIdentifier</key><string>com.gufa.float</string>
|
|
6
|
+
<key>CFBundleName</key><string>古法编程悬浮层</string>
|
|
7
|
+
<key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
|
|
8
|
+
<key>CFBundleExecutable</key><string>gufa-float</string>
|
|
9
|
+
<key>CFBundlePackageType</key><string>APPL</string>
|
|
10
|
+
<key>CFBundleShortVersionString</key><string>1.3.1</string>
|
|
11
|
+
<key>CFBundleVersion</key><string>1.3.1</string>
|
|
12
|
+
<key>LSUIElement</key><true/>
|
|
13
|
+
<key>NSHighResolutionCapable</key><true/>
|
|
14
|
+
<key>NSPrincipalClass</key><string>NSApplication</string>
|
|
15
|
+
</dict>
|
|
16
|
+
</plist>
|
|
Binary file
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>files</key>
|
|
6
|
+
<dict/>
|
|
7
|
+
<key>files2</key>
|
|
8
|
+
<dict/>
|
|
9
|
+
<key>rules</key>
|
|
10
|
+
<dict>
|
|
11
|
+
<key>^Resources/</key>
|
|
12
|
+
<true/>
|
|
13
|
+
<key>^Resources/.*\.lproj/</key>
|
|
14
|
+
<dict>
|
|
15
|
+
<key>optional</key>
|
|
16
|
+
<true/>
|
|
17
|
+
<key>weight</key>
|
|
18
|
+
<real>1000</real>
|
|
19
|
+
</dict>
|
|
20
|
+
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
|
21
|
+
<dict>
|
|
22
|
+
<key>omit</key>
|
|
23
|
+
<true/>
|
|
24
|
+
<key>weight</key>
|
|
25
|
+
<real>1100</real>
|
|
26
|
+
</dict>
|
|
27
|
+
<key>^Resources/Base\.lproj/</key>
|
|
28
|
+
<dict>
|
|
29
|
+
<key>weight</key>
|
|
30
|
+
<real>1010</real>
|
|
31
|
+
</dict>
|
|
32
|
+
<key>^version.plist$</key>
|
|
33
|
+
<true/>
|
|
34
|
+
</dict>
|
|
35
|
+
<key>rules2</key>
|
|
36
|
+
<dict>
|
|
37
|
+
<key>.*\.dSYM($|/)</key>
|
|
38
|
+
<dict>
|
|
39
|
+
<key>weight</key>
|
|
40
|
+
<real>11</real>
|
|
41
|
+
</dict>
|
|
42
|
+
<key>^(.*/)?\.DS_Store$</key>
|
|
43
|
+
<dict>
|
|
44
|
+
<key>omit</key>
|
|
45
|
+
<true/>
|
|
46
|
+
<key>weight</key>
|
|
47
|
+
<real>2000</real>
|
|
48
|
+
</dict>
|
|
49
|
+
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
|
|
50
|
+
<dict>
|
|
51
|
+
<key>nested</key>
|
|
52
|
+
<true/>
|
|
53
|
+
<key>weight</key>
|
|
54
|
+
<real>10</real>
|
|
55
|
+
</dict>
|
|
56
|
+
<key>^.*</key>
|
|
57
|
+
<true/>
|
|
58
|
+
<key>^Info\.plist$</key>
|
|
59
|
+
<dict>
|
|
60
|
+
<key>omit</key>
|
|
61
|
+
<true/>
|
|
62
|
+
<key>weight</key>
|
|
63
|
+
<real>20</real>
|
|
64
|
+
</dict>
|
|
65
|
+
<key>^PkgInfo$</key>
|
|
66
|
+
<dict>
|
|
67
|
+
<key>omit</key>
|
|
68
|
+
<true/>
|
|
69
|
+
<key>weight</key>
|
|
70
|
+
<real>20</real>
|
|
71
|
+
</dict>
|
|
72
|
+
<key>^Resources/</key>
|
|
73
|
+
<dict>
|
|
74
|
+
<key>weight</key>
|
|
75
|
+
<real>20</real>
|
|
76
|
+
</dict>
|
|
77
|
+
<key>^Resources/.*\.lproj/</key>
|
|
78
|
+
<dict>
|
|
79
|
+
<key>optional</key>
|
|
80
|
+
<true/>
|
|
81
|
+
<key>weight</key>
|
|
82
|
+
<real>1000</real>
|
|
83
|
+
</dict>
|
|
84
|
+
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
|
85
|
+
<dict>
|
|
86
|
+
<key>omit</key>
|
|
87
|
+
<true/>
|
|
88
|
+
<key>weight</key>
|
|
89
|
+
<real>1100</real>
|
|
90
|
+
</dict>
|
|
91
|
+
<key>^Resources/Base\.lproj/</key>
|
|
92
|
+
<dict>
|
|
93
|
+
<key>weight</key>
|
|
94
|
+
<real>1010</real>
|
|
95
|
+
</dict>
|
|
96
|
+
<key>^[^/]+$</key>
|
|
97
|
+
<dict>
|
|
98
|
+
<key>nested</key>
|
|
99
|
+
<true/>
|
|
100
|
+
<key>weight</key>
|
|
101
|
+
<real>10</real>
|
|
102
|
+
</dict>
|
|
103
|
+
<key>^embedded\.provisionprofile$</key>
|
|
104
|
+
<dict>
|
|
105
|
+
<key>weight</key>
|
|
106
|
+
<real>20</real>
|
|
107
|
+
</dict>
|
|
108
|
+
<key>^version\.plist$</key>
|
|
109
|
+
<dict>
|
|
110
|
+
<key>weight</key>
|
|
111
|
+
<real>20</real>
|
|
112
|
+
</dict>
|
|
113
|
+
</dict>
|
|
114
|
+
</dict>
|
|
115
|
+
</plist>
|
package/host/dev.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* 旧版本 Host(没有本方法)会让 api('dev.version') 返回 not-found,客户端据此提示重启 Harness。
|
|
4
4
|
*/
|
|
5
5
|
import { appendFileSync, existsSync } from 'node:fs'
|
|
6
|
+
import { readFile, rm } from 'node:fs/promises'
|
|
7
|
+
import { tmpdir } from 'node:os'
|
|
6
8
|
import { execFile, spawn } from 'node:child_process'
|
|
7
9
|
import { promisify } from 'node:util'
|
|
8
10
|
import { dirname, join } from 'node:path'
|
|
@@ -43,36 +45,115 @@ export function register(router, env) {
|
|
|
43
45
|
const startedAt = new Date().toISOString()
|
|
44
46
|
const ctx = env?.ctx ?? router.ctx
|
|
45
47
|
|
|
46
|
-
/* ──
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
/* ── 桌面悬浮层 / 摸鱼模式(macOS) ────────────────────────────────
|
|
49
|
+
* 通过 .app bundle 启动 helper:TCC(屏幕录制)按 bundle 身份授权,
|
|
50
|
+
* 用户在「系统设置 → 隐私与安全性 → 屏幕录制」里添加「古法编程悬浮层.app」即可。
|
|
51
|
+
*/
|
|
52
|
+
const appBundlePath = () => {
|
|
53
|
+
const candidates = [
|
|
54
|
+
join(PLUGIN_ROOT, 'desktop', 'float', '古法编程悬浮层.app'),
|
|
55
|
+
join(PLUGIN_ROOT, 'desktop', 'float', 'GufaFloat.app'),
|
|
56
|
+
]
|
|
57
|
+
for (const candidate of candidates) {
|
|
58
|
+
if (existsSync(candidate)) return candidate
|
|
59
|
+
}
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
const floatProcessPattern = '古法编程悬浮层.app/Contents/MacOS/gufa-float'
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
router.method('float.windows', async () => {
|
|
57
|
-
if (process.platform !== 'darwin') throw new ApiError('unsupported', '摸鱼模式目前只支持 macOS', 400)
|
|
58
|
-
const binary = floatBinaryPath()
|
|
59
|
-
if (binary === null) throw new ApiError('missing-helper', '悬浮层程序未构建,请先运行 scripts/build-float-macos.sh', 500)
|
|
60
|
-
let stdout = ''
|
|
64
|
+
const listFloatPids = async () => {
|
|
61
65
|
try {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
} catch
|
|
65
|
-
|
|
66
|
+
const { stdout } = await runFile('pgrep', ['-f', floatProcessPattern], { timeout: 3000 })
|
|
67
|
+
return String(stdout ?? '').split('\n').map((line) => Number(line.trim())).filter((pid) => Number.isFinite(pid) && pid > 0)
|
|
68
|
+
} catch {
|
|
69
|
+
return []
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const floatRunningAsync = async () => (await listFloatPids()).length > 0
|
|
73
|
+
|
|
74
|
+
const openApp = (args) => new Promise((resolve, reject) => {
|
|
75
|
+
const app = appBundlePath()
|
|
76
|
+
if (app === null) {
|
|
77
|
+
reject(new ApiError('missing-helper', '悬浮层 App 未构建,请先运行 scripts/build-float-macos.sh', 500))
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
const child = spawn('open', ['-n', app, '--args', ...args], { detached: true, stdio: 'ignore' })
|
|
81
|
+
child.once('error', reject)
|
|
82
|
+
child.once('exit', (code) => {
|
|
83
|
+
if (code === 0) resolve()
|
|
84
|
+
else reject(new ApiError('open-failed', `悬浮层启动失败(open exit ${code})`, 500))
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const killFloat = async () => {
|
|
89
|
+
const pids = await listFloatPids()
|
|
90
|
+
for (const pid of pids) {
|
|
91
|
+
try {
|
|
92
|
+
process.kill(pid, 'SIGTERM')
|
|
93
|
+
} catch {
|
|
94
|
+
/* ignore */
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (pids.length > 0) await new Promise((resolve) => setTimeout(resolve, 400))
|
|
98
|
+
floatState.child = null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
router.method('float.status', async () => {
|
|
102
|
+
const running = await floatRunningAsync()
|
|
103
|
+
return {
|
|
104
|
+
supported: process.platform === 'darwin' && appBundlePath() !== null,
|
|
105
|
+
platform: process.platform,
|
|
106
|
+
running,
|
|
107
|
+
pid: running ? (await listFloatPids())[0] ?? null : null,
|
|
108
|
+
app: appBundlePath(),
|
|
66
109
|
}
|
|
67
|
-
|
|
68
|
-
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
/** 在 Finder 里显示悬浮层 App,便于用户在「屏幕录制」里手动添加。 */
|
|
113
|
+
router.method('float.revealHelper', async () => {
|
|
114
|
+
const app = appBundlePath()
|
|
115
|
+
if (app === null) throw new ApiError('missing-helper', '悬浮层 App 未构建', 500)
|
|
69
116
|
try {
|
|
70
|
-
|
|
117
|
+
spawn('open', ['-R', app], { detached: true, stdio: 'ignore' }).unref()
|
|
118
|
+
return { ok: true, app }
|
|
71
119
|
} catch {
|
|
72
|
-
|
|
120
|
+
return { ok: false, app }
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
/** 列出可吸附的 App 窗口(通过 .app 身份启动 helper,输出到临时文件)。 */
|
|
125
|
+
router.method('float.windows', async () => {
|
|
126
|
+
if (process.platform !== 'darwin') throw new ApiError('unsupported', '摸鱼模式目前只支持 macOS', 400)
|
|
127
|
+
if (appBundlePath() === null) throw new ApiError('missing-helper', '悬浮层 App 未构建,请先运行 scripts/build-float-macos.sh', 500)
|
|
128
|
+
const outPath = join(tmpdir(), `gufa-float-windows-${process.pid}-${Date.now()}.json`)
|
|
129
|
+
try {
|
|
130
|
+
await openApp(['--list-windows', '--out', outPath])
|
|
131
|
+
const deadline = Date.now() + 10_000
|
|
132
|
+
let raw = ''
|
|
133
|
+
while (Date.now() < deadline) {
|
|
134
|
+
try {
|
|
135
|
+
raw = await readFile(outPath, 'utf8')
|
|
136
|
+
if (raw.trim() !== '') break
|
|
137
|
+
} catch {
|
|
138
|
+
/* 还没写出来 */
|
|
139
|
+
}
|
|
140
|
+
await new Promise((resolve) => setTimeout(resolve, 120))
|
|
141
|
+
}
|
|
142
|
+
let parsed = null
|
|
143
|
+
try {
|
|
144
|
+
parsed = JSON.parse(raw.trim())
|
|
145
|
+
} catch {
|
|
146
|
+
parsed = null
|
|
147
|
+
}
|
|
148
|
+
if (parsed === null) throw new ApiError('list-failed', '读取窗口列表失败(helper 无输出)', 500)
|
|
149
|
+
return parsed
|
|
150
|
+
} finally {
|
|
151
|
+
try {
|
|
152
|
+
await rm(outPath, { force: true })
|
|
153
|
+
} catch {
|
|
154
|
+
/* ignore */
|
|
155
|
+
}
|
|
73
156
|
}
|
|
74
|
-
if (parsed === null) throw new ApiError('list-failed', '读取窗口列表失败(helper 无输出)', 500)
|
|
75
|
-
return parsed
|
|
76
157
|
})
|
|
77
158
|
|
|
78
159
|
router.method('float.openPrivacy', async () => {
|
|
@@ -86,71 +167,36 @@ export function register(router, env) {
|
|
|
86
167
|
})
|
|
87
168
|
|
|
88
169
|
router.method('float.start', async (body) => {
|
|
89
|
-
if (process.platform !== 'darwin') throw new ApiError('unsupported', '
|
|
90
|
-
|
|
91
|
-
if (binary === null) throw new ApiError('missing-helper', '悬浮层程序未构建,请先运行 scripts/build-float-macos.sh', 500)
|
|
170
|
+
if (process.platform !== 'darwin') throw new ApiError('unsupported', '摸鱼模式目前只支持 macOS', 400)
|
|
171
|
+
if (appBundlePath() === null) throw new ApiError('missing-helper', '悬浮层 App 未构建,请先运行 scripts/build-float-macos.sh', 500)
|
|
92
172
|
const follow = body !== null && typeof body === 'object' && body.follow !== null && typeof body.follow === 'object'
|
|
93
173
|
? { windowNumber: Number(body.follow.windowNumber) || 0, pid: Number(body.follow.pid) || 0 }
|
|
94
174
|
: null
|
|
95
175
|
if (follow !== null && follow.windowNumber > 0) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
floatState.child.kill('SIGTERM')
|
|
100
|
-
} catch {
|
|
101
|
-
/* ignore */
|
|
102
|
-
}
|
|
103
|
-
await new Promise((resolve) => setTimeout(resolve, 500))
|
|
104
|
-
}
|
|
105
|
-
} else if (floatRunning()) {
|
|
106
|
-
return { running: true, pid: floatState.child.pid }
|
|
107
|
-
}
|
|
108
|
-
let webServer
|
|
109
|
-
let connection
|
|
110
|
-
try {
|
|
111
|
-
webServer = ctx.get('webServer')
|
|
112
|
-
connection = ctx.get('connection')
|
|
113
|
-
} catch {
|
|
114
|
-
/* ignore */
|
|
176
|
+
await killFloat()
|
|
177
|
+
} else if (await floatRunningAsync()) {
|
|
178
|
+
return { running: true, pid: (await listFloatPids())[0] ?? null }
|
|
115
179
|
}
|
|
180
|
+
const webServer = ctx.get('webServer')
|
|
181
|
+
const connection = ctx.get('connection')
|
|
116
182
|
if (webServer === undefined || webServer === null || connection === undefined || connection === null || typeof connection.authenticatedUrl !== 'function') {
|
|
117
183
|
throw new ApiError('unavailable', '当前 Host 不提供 Web 服务地址,无法启动悬浮层', 500)
|
|
118
184
|
}
|
|
119
185
|
const base = `${webServer.protocol}//127.0.0.1:${String(webServer.port)}`
|
|
120
186
|
const authUrl = connection.authenticatedUrl(`${base}/`)
|
|
121
187
|
const payload = JSON.stringify({ authUrl, appUrl: `${base}/`, follow: follow !== null && follow.windowNumber > 0 ? follow : undefined })
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
} catch (error) {
|
|
126
|
-
throw new ApiError('spawn-failed', `悬浮层启动失败:${String(error && error.message || error)}`, 500)
|
|
127
|
-
}
|
|
128
|
-
child.unref()
|
|
129
|
-
floatState.child = child
|
|
188
|
+
await openApp([payload])
|
|
189
|
+
await new Promise((resolve) => setTimeout(resolve, 300))
|
|
190
|
+
const pids = await listFloatPids()
|
|
130
191
|
floatState.startedAt = Date.now()
|
|
131
|
-
|
|
132
|
-
if (floatState.child === child) floatState.child = null
|
|
133
|
-
})
|
|
134
|
-
return { running: true, pid: child.pid ?? null }
|
|
192
|
+
return { running: pids.length > 0, pid: pids[0] ?? null }
|
|
135
193
|
})
|
|
136
194
|
|
|
137
195
|
router.method('float.stop', async () => {
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
floatState.child.kill('SIGTERM')
|
|
141
|
-
} catch {
|
|
142
|
-
/* ignore */
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
floatState.child = null
|
|
196
|
+
await killFloat()
|
|
146
197
|
return { running: false }
|
|
147
198
|
})
|
|
148
199
|
|
|
149
|
-
router.method('dev.log', async (body) => {
|
|
150
|
-
const message = body !== null && typeof body === 'object' && typeof body.message === 'string' ? body.message : ''
|
|
151
|
-
if (message !== '') debugLog(message)
|
|
152
|
-
return { ok: true }
|
|
153
|
-
})
|
|
154
200
|
router.method('dev.version', async () => ({
|
|
155
201
|
name: 'dsh-gufa-code',
|
|
156
202
|
version: '1.0.0',
|
package/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# 构建 macOS 悬浮层 helper(P0):Objective-C + AppKit + WebKit
|
|
2
|
+
# 构建 macOS 悬浮层 helper(P0/P1):Objective-C + AppKit + WebKit。
|
|
3
|
+
# 产物 1:可直接启动的二进制(Host spawn 用)
|
|
4
|
+
# 产物 2:.app bundle(方便用户在「屏幕录制」隐私列表里手动添加)
|
|
3
5
|
set -euo pipefail
|
|
4
6
|
cd "$(dirname "$0")/.."
|
|
5
7
|
mkdir -p desktop/float/bin
|
|
@@ -7,5 +9,31 @@ ARCH="$(uname -m)"
|
|
|
7
9
|
OUT="desktop/float/bin/gufa-float-macos-${ARCH}"
|
|
8
10
|
clang -fobjc-arc -O2 -framework AppKit -framework WebKit -framework Carbon -o "$OUT" desktop/float/GufaFloat.m
|
|
9
11
|
chmod +x "$OUT"
|
|
10
|
-
|
|
12
|
+
# 带稳定的 code identifier 签名(TCC 按它识别,避免每次构建都换身份字符串)
|
|
13
|
+
codesign --force --sign - -i com.gufa.float "$OUT" >/dev/null 2>&1 || true
|
|
14
|
+
|
|
15
|
+
APP="desktop/float/古法编程悬浮层.app"
|
|
16
|
+
rm -rf "$APP"
|
|
17
|
+
mkdir -p "$APP/Contents/MacOS"
|
|
18
|
+
cp "$OUT" "$APP/Contents/MacOS/gufa-float"
|
|
19
|
+
cat > "$APP/Contents/Info.plist" <<'PLIST'
|
|
20
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
21
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
22
|
+
<plist version="1.0">
|
|
23
|
+
<dict>
|
|
24
|
+
<key>CFBundleIdentifier</key><string>com.gufa.float</string>
|
|
25
|
+
<key>CFBundleName</key><string>古法编程悬浮层</string>
|
|
26
|
+
<key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
|
|
27
|
+
<key>CFBundleExecutable</key><string>gufa-float</string>
|
|
28
|
+
<key>CFBundlePackageType</key><string>APPL</string>
|
|
29
|
+
<key>CFBundleShortVersionString</key><string>1.3.1</string>
|
|
30
|
+
<key>CFBundleVersion</key><string>1.3.1</string>
|
|
31
|
+
<key>LSUIElement</key><true/>
|
|
32
|
+
<key>NSHighResolutionCapable</key><true/>
|
|
33
|
+
<key>NSPrincipalClass</key><string>NSApplication</string>
|
|
34
|
+
</dict>
|
|
35
|
+
</plist>
|
|
36
|
+
PLIST
|
|
37
|
+
codesign --force --deep --sign - "$APP" >/dev/null 2>&1 || true
|
|
11
38
|
echo "built: $OUT"
|
|
39
|
+
echo "built: $APP"
|
package/src/client/90-app.js
CHANGED
|
@@ -2164,11 +2164,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2164
2164
|
'div',
|
|
2165
2165
|
{ className: 'gufa-float-permission' },
|
|
2166
2166
|
h('div', { className: 'gufa-float-permission-title' }, '需要「屏幕录制」权限'),
|
|
2167
|
-
h('div', { className: 'gufa-hint' }, '摸鱼列表需要读取其他 App
|
|
2167
|
+
h('div', { className: 'gufa-hint' }, '摸鱼列表需要读取其他 App 的窗口尺寸(只读尺寸,不录屏)。系统只认悬浮层 App 自己的授权:请在「系统设置 → 隐私与安全性 → 屏幕录制」里点左下角「+」,添加「古法编程悬浮层.app」并打开开关(DeepSeek Harness 的开关也保持打开)。加好后点「重试」。'),
|
|
2168
2168
|
h(
|
|
2169
2169
|
'div',
|
|
2170
|
-
{ className: 'gufa-row', style: { gap: 8, marginTop: 12 } },
|
|
2170
|
+
{ className: 'gufa-row', style: { gap: 8, marginTop: 12, flexWrap: 'wrap' } },
|
|
2171
2171
|
h(G.Button, { primary: true, onClick: () => void G.api('float.openPrivacy').catch(() => {}) }, '打开系统设置'),
|
|
2172
|
+
h(G.Button, { onClick: () => void G.api('float.revealHelper').catch(() => {}) }, '在 Finder 中显示悬浮层 App'),
|
|
2172
2173
|
h(G.Button, { onClick: () => void openFloatPicker() }, '重试'),
|
|
2173
2174
|
),
|
|
2174
2175
|
)
|