feat: DevTools 仪表盘新增自重启功能
- 新增 POST /api/devtools/restart 端点(spawn 新进程 + exit 旧进程) - 仪表盘服务状态卡片新增「🔁 重启 DevTools」按钮 - 重启流程:确认 → API 调用 → 2s 后自动刷新页面 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1213,6 +1213,7 @@ async function renderDashboard() {
|
||||
'<button class="btn btn-sm btn-accent" onclick="svcAction(\'start-all\')">▶ 一键启动</button>' +
|
||||
'<button class="btn btn-sm" onclick="svcAction(\'start-all-fresh\')">🔄 强制重启全部</button>' +
|
||||
'<button class="btn btn-sm btn-red" onclick="svcAction(\'stop-all\')">⏹ 全部停止</button>' +
|
||||
'<button class="btn btn-sm" onclick="restartDevTools()" style="margin-left:8px;border-color:var(--accent);color:var(--accent)" title="重启 DevTools 自身以应用更新">🔁 重启 DevTools</button>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="cards-grid cards-4" id="dashboard-svc-cards"></div>' +
|
||||
@@ -2341,6 +2342,20 @@ async function clearSvcLogs() {
|
||||
renderServiceLog();
|
||||
}
|
||||
|
||||
// ---- DevTools 自重启 ----
|
||||
async function restartDevTools() {
|
||||
if (!confirm('确定要重启 DevTools 吗?\n\n页面将在几秒后自动刷新。')) return;
|
||||
try {
|
||||
await api('/api/devtools/restart', { method: 'POST' });
|
||||
} catch (e) {
|
||||
// 请求可能在收到响应前就中断(因为服务已退出),这是正常的
|
||||
}
|
||||
// 等待新进程就绪后刷新
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// ---- 服务操作 ----
|
||||
async function svcAction(cmd, serviceId) {
|
||||
var actionLabels = { start: "启动", stop: "停止", restart: "重启", build: "编译", "start-all": "一键启动", "start-all-fresh": "强制重启全部", "stop-all": "全部停止" };
|
||||
|
||||
Reference in New Issue
Block a user