@simonyea/holysheep-cli 1.7.65 → 1.7.66
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/package.json +1 -1
- package/src/webui/index.html +10 -0
- package/src/webui/server.js +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.66",
|
|
4
4
|
"description": "Claude Code/Cursor/Cline API relay for China — ¥1=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openai-china",
|
package/src/webui/index.html
CHANGED
|
@@ -479,16 +479,26 @@ async function doUpgradeTool(id, name) {
|
|
|
479
479
|
openConsole(`${t('upgradeOne')}: ${name}`)
|
|
480
480
|
document.getElementById('console-section').classList.add('busy')
|
|
481
481
|
|
|
482
|
+
let upgraded = false
|
|
482
483
|
await streamSSE('/api/tool/upgrade', { toolId: id }, (ev) => {
|
|
483
484
|
if (ev.type === 'progress') appendLog(ev.message, 'info')
|
|
484
485
|
else if (ev.type === 'output') appendLogRaw(ev.text)
|
|
485
486
|
else if (ev.type === 'done') {
|
|
487
|
+
upgraded = ev.success
|
|
486
488
|
appendLog(ev.success ? `\n✓ ${t('configSuccess')}` : `\n✗ ${t('configFailed')}`, ev.success ? 'ok' : 'err')
|
|
487
489
|
}
|
|
488
490
|
})
|
|
489
491
|
|
|
490
492
|
document.getElementById('console-section').classList.remove('busy')
|
|
491
493
|
busy = false
|
|
494
|
+
|
|
495
|
+
if (upgraded && id === 'holysheep') {
|
|
496
|
+
appendLog(`\n${lang === 'zh' ? '⚠ HolySheep CLI 已升级,需要重启 WebUI 服务。正在重启...' : '⚠ HolySheep CLI upgraded. Restarting WebUI...'}`, 'warn')
|
|
497
|
+
// 调用后端重启,3 秒后刷新页面
|
|
498
|
+
try { await fetch('/api/restart', { method: 'POST' }) } catch {}
|
|
499
|
+
setTimeout(() => location.reload(), 4000)
|
|
500
|
+
return
|
|
501
|
+
}
|
|
492
502
|
loadTools()
|
|
493
503
|
}
|
|
494
504
|
|
package/src/webui/server.js
CHANGED
|
@@ -698,6 +698,17 @@ async function handleRequest(req, res) {
|
|
|
698
698
|
if (route === '/api/tool/upgrade' && req.method === 'POST') return await handleToolUpgrade(req, res)
|
|
699
699
|
if (route === '/api/env' && req.method === 'GET') return handleEnv(req, res)
|
|
700
700
|
if (route === '/api/env/clean' && req.method === 'POST') return handleEnvClean(req, res)
|
|
701
|
+
if (route === '/api/restart' && req.method === 'POST') {
|
|
702
|
+
json(res, { ok: true })
|
|
703
|
+
// 升级后用新版 hs web 重启自身
|
|
704
|
+
const port = req.headers.host?.split(':')[1] || '9876'
|
|
705
|
+
setTimeout(() => {
|
|
706
|
+
const child = spawn(process.execPath, [path.join(__dirname, '..', 'index.js'), 'web', '--port', port, '--no-open'], { detached: true, stdio: 'ignore' })
|
|
707
|
+
child.unref()
|
|
708
|
+
process.exit(0)
|
|
709
|
+
}, 500)
|
|
710
|
+
return
|
|
711
|
+
}
|
|
701
712
|
|
|
702
713
|
res.writeHead(404)
|
|
703
714
|
res.end('Not Found')
|