claude-opencode-viewer 2.6.8 → 2.6.10
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/bin/cov.js +1 -0
- package/index-pc.html +2 -1
- package/index.html +2 -1
- package/package.json +1 -1
- package/server.js +33 -8
package/bin/cov.js
CHANGED
|
@@ -87,6 +87,7 @@ const port = getPort();
|
|
|
87
87
|
const serverArgs = [SERVER_PATH, String(port)];
|
|
88
88
|
if (args.includes('--pc')) serverArgs.push('--pc');
|
|
89
89
|
if (args.includes('--https')) serverArgs.push('--https');
|
|
90
|
+
if (args.includes('--json')) serverArgs.push('--json');
|
|
90
91
|
const server = spawn(process.execPath, serverArgs, {
|
|
91
92
|
stdio: 'inherit',
|
|
92
93
|
cwd: process.cwd(),
|
package/index-pc.html
CHANGED
|
@@ -1036,7 +1036,8 @@
|
|
|
1036
1036
|
if (!b64 || b64 === '?') return false;
|
|
1037
1037
|
if (isBufferReplay) return true;
|
|
1038
1038
|
try {
|
|
1039
|
-
var
|
|
1039
|
+
var bytes = Uint8Array.from(atob(b64), function(c) { return c.charCodeAt(0); });
|
|
1040
|
+
var text = new TextDecoder().decode(bytes);
|
|
1040
1041
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
1041
1042
|
navigator.clipboard.writeText(text).then(function() {
|
|
1042
1043
|
showCopyToast();
|
package/index.html
CHANGED
|
@@ -1026,7 +1026,8 @@
|
|
|
1026
1026
|
var b64 = data.substring(idx + 1);
|
|
1027
1027
|
if (!b64 || b64 === '?') return false;
|
|
1028
1028
|
try {
|
|
1029
|
-
var
|
|
1029
|
+
var bytes = Uint8Array.from(atob(b64), function(c) { return c.charCodeAt(0); });
|
|
1030
|
+
var text = new TextDecoder().decode(bytes);
|
|
1030
1031
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
1031
1032
|
navigator.clipboard.writeText(text).then(function() {
|
|
1032
1033
|
showCopyToast();
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -18,6 +18,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
18
18
|
const PORT = parseInt(process.argv[2]) || 7008;
|
|
19
19
|
const IS_PC = process.argv.includes('--pc');
|
|
20
20
|
const USE_HTTPS = process.argv.includes('--https');
|
|
21
|
+
const JSON_OUTPUT = process.argv.includes('--json');
|
|
21
22
|
|
|
22
23
|
// 自签名证书生成(使用 selfsigned 库,不依赖 openssl)
|
|
23
24
|
async function getOrCreateCert() {
|
|
@@ -452,6 +453,21 @@ const requestHandler = async (req, res) => {
|
|
|
452
453
|
return;
|
|
453
454
|
}
|
|
454
455
|
|
|
456
|
+
// API: 获取服务端口信息
|
|
457
|
+
if (req.url === '/api/port') {
|
|
458
|
+
res.writeHead(200, {
|
|
459
|
+
'Content-Type': 'application/json',
|
|
460
|
+
'Access-Control-Allow-Origin': '*',
|
|
461
|
+
});
|
|
462
|
+
res.end(JSON.stringify({
|
|
463
|
+
port: PORT,
|
|
464
|
+
pc: IS_PC,
|
|
465
|
+
https: USE_HTTPS,
|
|
466
|
+
proto: USE_HTTPS ? 'https' : 'http',
|
|
467
|
+
}));
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
|
|
455
471
|
// API: 获取会话列表
|
|
456
472
|
if (req.url === '/api/sessions') {
|
|
457
473
|
res.writeHead(200, {
|
|
@@ -776,17 +792,26 @@ wss.on('connection', (ws, req) => {
|
|
|
776
792
|
});
|
|
777
793
|
});
|
|
778
794
|
|
|
795
|
+
process.on('SIGINT', () => process.exit(0));
|
|
796
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
797
|
+
|
|
779
798
|
server.listen(PORT, '0.0.0.0', async () => {
|
|
780
799
|
const ip = getLocalIp();
|
|
781
800
|
const proto = USE_HTTPS ? 'https' : 'http';
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
801
|
+
|
|
802
|
+
if (JSON_OUTPUT) {
|
|
803
|
+
// 输出一行 JSON 供外部程序解析,然后继续运行
|
|
804
|
+
console.log(JSON.stringify({ port: PORT, url: `${proto}://127.0.0.1:${PORT}`, ip, proto, pid: process.pid }));
|
|
805
|
+
} else {
|
|
806
|
+
console.log('\n' + '='.repeat(50));
|
|
807
|
+
console.log('✅ Claude OpenCode Viewer 已启动');
|
|
808
|
+
console.log('='.repeat(50));
|
|
809
|
+
console.log(`🖥️ 本地访问:${proto}://127.0.0.1:${PORT}`);
|
|
810
|
+
console.log(`📱 手机访问:${proto}://${ip}:${PORT}`);
|
|
811
|
+
if (USE_HTTPS) console.log('🔐 HTTPS 模式(首次访问需信任自签名证书)');
|
|
812
|
+
console.log('='.repeat(50));
|
|
813
|
+
console.log('\n按 Ctrl+C 停止服务\n');
|
|
814
|
+
}
|
|
790
815
|
|
|
791
816
|
await spawnProcess('opencode');
|
|
792
817
|
});
|