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 0000000..bd9a0b4
Binary files /dev/null and b/static/.app.js.swp differ
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';