diff --git a/dashboard/dist/index.js b/dashboard/dist/index.js index 2c611ef..403a28a 100644 --- a/dashboard/dist/index.js +++ b/dashboard/dist/index.js @@ -28,6 +28,7 @@ const [status, setStatus] = React.useState("idle"); const [msg, setMsg] = React.useState(null); const [triedAuto, setTriedAuto] = React.useState(false); + const [autoRestarted, setAutoRestarted] = React.useState(false); const check = React.useCallback(async function(){ try { @@ -69,12 +70,25 @@ }, [status, triedAuto, doStart]); const restartDashboard = React.useCallback(async function(){ - setMsg("Đang gửi lệnh restart Gateway/Dashboard..."); - try { await fetchJSONAllowError("/api/gateway/restart", {method:"POST"}); } catch(_){} + if (autoRestarted) return; + setAutoRestarted(true); + setMsg("Đang gửi lệnh restart Gateway/Dashboard (tự động khi cài)..."); + const endpoints = ["/api/gateway/restart","/api/dashboard/restart","/api/hermes/restart","/api/ops/restart","/api/gateway/stop","/api/gateway/start"]; + for (const ep of endpoints) { + try { await fetchJSONAllowError(ep, {method:"POST"}); setMsg("Đã gửi "+ep+", đợi 7s..."); break; } catch(_){} + } try { await fetchJSONAllowError("/api/dashboard/plugins/rescan"); } catch(_){} - setMsg("Đã gửi restart, đợi 7s rồi reload..."); + setMsg("Đã gửi restart, đợi 7s rồi reload để hiện link (auto-start bằng nohup)..."); setTimeout(function(){ window.location.reload(); }, 7000); - }, []); + }, [autoRestarted]); + + // auto-restart when backend not mounted (like after fresh install, same as ntfy version) + React.useEffect(function(){ + if (status === "needs_restart" && !autoRestarted) { + const t = setTimeout(restartDashboard, 1500); + return function(){ clearTimeout(t); }; + } + }, [status, autoRestarted, restartDashboard]); if (status === "needs_restart") { return React.createElement(Card, null, diff --git a/dashboard/manifest.json b/dashboard/manifest.json index a1bcdac..6ad63b0 100644 --- a/dashboard/manifest.json +++ b/dashboard/manifest.json @@ -3,7 +3,7 @@ "label": "sshx.io Terminal", "description": "Chỉ hiện link hiện tại — auto-start nohup (fallback), tự gọi /start nếu chưa có link", "icon": "Terminal", - "version": "2.3.2", + "version": "2.3.3", "tab": { "path": "/sshx", "position": "end" diff --git a/plugin.yaml b/plugin.yaml index 5c3a6ca..701cf52 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ name: sshx-link -version: 2.3.2 +version: 2.3.3 description: Tạo shell ở sshx.io và trả link chia sẻ — auto arch detection, không cần restart dashboard author: sisyphus provides_tools: