From f931c0f397f2f1645e19df62307204c87ab46f84 Mon Sep 17 00:00:00 2001 From: swpa Date: Thu, 30 Apr 2026 10:36:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E6=B1=BA=E8=BC=89=E5=85=A5=E4=BB=BB?= =?UTF-8?q?=E5=8B=99=E6=8C=89=E9=88=95=E7=9A=84=E8=A1=8C=E7=82=BA=E8=88=87?= =?UTF-8?q?=E6=99=82=E6=A9=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot --- index.html | 2 +- static/.app.js.swp | Bin 0 -> 1024 bytes static/app.js | 23 +++++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 static/.app.js.swp diff --git a/index.html b/index.html index 6269a18..693ebd5 100644 --- a/index.html +++ b/index.html @@ -163,7 +163,7 @@ - + diff --git a/static/.app.js.swp b/static/.app.js.swp new file mode 100644 index 0000000000000000000000000000000000000000..bd9a0b45f096e219eddf07aeba6c59c2208dc09f GIT binary patch literal 1024 zcmYc?$V<%2S1{KzVn6{+Zmll2n|3iPsy Q;i99A(GVC7fq@DE0H~A>NB{r; literal 0 HcmV?d00001 diff --git a/static/app.js b/static/app.js index 3fdff82..e1ce818 100644 --- a/static/app.js +++ b/static/app.js @@ -5,6 +5,7 @@ // ========================================== let term, fitAddon, ws; let currentMacDomainData = null; +let isConnected = false; // 💡 新增:用來追蹤目前的連線狀態 window.onload = initTerminal; window.onresize = () => { if (fitAddon) fitAddon.fit(); }; @@ -45,6 +46,12 @@ function switchConfigTask() { // 💡 新增的函數:由「🚀 載入任務」按鈕手動觸發 function startConfigTask() { + // 💡 新增防呆:雙重檢查是否已連線 + if (!isConnected) { + alert("請先成功連線至 CMTS 設備後,再執行載入任務!"); + return; + } + // 1. 先確保對應的表單有顯示出來 switchConfigTask(); @@ -214,6 +221,14 @@ function connectWebSocket() { ws = new WebSocket(wsUrl); ws.onopen = () => { + isConnected = true; // 💡 標記為已連線 + const btnLoadTask = document.getElementById('btn-load-task'); + if (btnLoadTask) { + btnLoadTask.disabled = false; // 解鎖按鈕功能 + btnLoadTask.style.backgroundColor = '#c0392b'; // 恢復原本的紅色 + btnLoadTask.style.cursor = 'pointer'; // 恢復正常滑鼠游標 + } + document.getElementById('wsStatus').textContent = `狀態:已連線`; document.getElementById('wsStatus').style.color = '#27ae60'; document.getElementById('btnConnect').style.display = 'none'; @@ -229,6 +244,14 @@ function connectWebSocket() { }; ws.onclose = () => { + isConnected = false; // 💡 標記為已斷線 + const btnLoadTask = document.getElementById('btn-load-task'); + if (btnLoadTask) { + btnLoadTask.disabled = true; // 鎖定按鈕功能 + btnLoadTask.style.backgroundColor = '#95a5a6'; // 變回反灰色 + btnLoadTask.style.cursor = 'not-allowed'; // 變回禁止游標 + } + document.getElementById('wsStatus').textContent = '狀態:已斷線'; document.getElementById('wsStatus').style.color = '#c0392b'; document.getElementById('btnConnect').style.display = 'inline-block';