Roberta2024 commited on
Commit
8511651
·
verified ·
1 Parent(s): 97abdd9

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +57 -14
index.html CHANGED
@@ -20,7 +20,6 @@
20
  margin: 0;
21
  padding: 0;
22
  background-color: var(--light-bg);
23
- /* 使用 Flexbox 讓內容垂直和水平居中 */
24
  display: flex;
25
  justify-content: center;
26
  align-items: center;
@@ -71,6 +70,30 @@
71
  border-color: var(--primary-color);
72
  }
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  #error-message {
75
  color: var(--red-color);
76
  margin-top: -10px;
@@ -100,9 +123,9 @@
100
 
101
  /* 主系統容器 */
102
  #main-content {
103
- display: none; /* 預設隱藏主畫面 */
104
  width: 100%;
105
- max-width: 1200px; /* 保持與 container 一致的最大寬度 */
106
  flex-direction: column;
107
  align-items: center;
108
  }
@@ -210,7 +233,6 @@
210
  border: none;
211
  }
212
 
213
- /* 回到登入頁面按鈕樣式 */
214
  .tab-button-logout {
215
  background-color: #6c757d;
216
  color: white;
@@ -234,7 +256,14 @@
234
  <label for="password">密碼</label>
235
  <input type="password" id="password" name="password" placeholder="請輸入密碼" required>
236
  </div>
237
- <p id="error-message">帳號或密碼錯誤,請重新輸入。</p>
 
 
 
 
 
 
 
238
  <button type="submit" id="login-btn">登入</button>
239
  </form>
240
  </div>
@@ -272,6 +301,16 @@
272
  </div>
273
 
274
  <script>
 
 
 
 
 
 
 
 
 
 
275
  // 頁籤切換邏輯
276
  function showTab(tabId) {
277
  const allIframes = document.querySelectorAll('.iframe-wrapper');
@@ -292,8 +331,9 @@
292
  document.getElementById('loginForm').addEventListener('submit', function(event) {
293
  event.preventDefault();
294
 
295
- const usernameInput = document.getElementById('username');
296
- const passwordInput = document.getElementById('password');
 
297
  const errorMessage = document.getElementById('error-message');
298
  const loginContainer = document.getElementById('login-container');
299
  const mainContent = document.getElementById('main-content');
@@ -301,17 +341,18 @@
301
  const correctUsername = 'ROOT2025';
302
  const correctPassword = '123456';
303
 
304
- if (usernameInput.value === correctUsername && passwordInput.value === correctPassword) {
 
305
  errorMessage.style.visibility = 'hidden';
306
  errorMessage.style.opacity = '0';
307
 
308
- // 隱藏登入區塊
309
  loginContainer.style.display = 'none';
310
- // 顯示主系統畫面
311
- mainContent.style.display = 'flex';
312
  } else {
 
313
  errorMessage.style.visibility = 'visible';
314
  errorMessage.style.opacity = '1';
 
315
  }
316
  });
317
 
@@ -322,15 +363,17 @@
322
  const usernameInput = document.getElementById('username');
323
  const passwordInput = document.getElementById('password');
324
 
325
- // 隱藏主畫面
326
  mainContent.style.display = 'none';
327
- // 顯示登入區塊
328
  loginContainer.style.display = 'block';
329
 
330
- // 清空輸入欄位
331
  usernameInput.value = '';
332
  passwordInput.value = '';
 
 
333
  }
 
 
 
334
  </script>
335
 
336
  </body>
 
20
  margin: 0;
21
  padding: 0;
22
  background-color: var(--light-bg);
 
23
  display: flex;
24
  justify-content: center;
25
  align-items: center;
 
70
  border-color: var(--primary-color);
71
  }
72
 
73
+ /* 驗證碼輸入組 */
74
+ .captcha-group {
75
+ display: flex;
76
+ align-items: center;
77
+ justify-content: space-between;
78
+ gap: 10px;
79
+ }
80
+
81
+ .captcha-group input {
82
+ flex: 1;
83
+ }
84
+
85
+ #captcha-code {
86
+ width: 100px;
87
+ padding: 10px;
88
+ font-size: 1.2rem;
89
+ font-weight: bold;
90
+ text-align: center;
91
+ color: var(--primary-color);
92
+ border: 1px dashed #ced4da;
93
+ border-radius: 8px;
94
+ background-color: #e9ecef;
95
+ }
96
+
97
  #error-message {
98
  color: var(--red-color);
99
  margin-top: -10px;
 
123
 
124
  /* 主系統容器 */
125
  #main-content {
126
+ display: none;
127
  width: 100%;
128
+ max-width: 1200px;
129
  flex-direction: column;
130
  align-items: center;
131
  }
 
233
  border: none;
234
  }
235
 
 
236
  .tab-button-logout {
237
  background-color: #6c757d;
238
  color: white;
 
256
  <label for="password">密碼</label>
257
  <input type="password" id="password" name="password" placeholder="請輸入密碼" required>
258
  </div>
259
+ <div class="input-group">
260
+ <label for="captcha">驗證碼</label>
261
+ <div class="captcha-group">
262
+ <input type="text" id="captcha" name="captcha" placeholder="請輸入驗證碼" required>
263
+ <span id="captcha-code"></span>
264
+ </div>
265
+ </div>
266
+ <p id="error-message">帳號、密碼或驗證碼錯誤,請重新輸入。</p>
267
  <button type="submit" id="login-btn">登入</button>
268
  </form>
269
  </div>
 
301
  </div>
302
 
303
  <script>
304
+ // 驗證碼相關變數
305
+ let currentCaptcha = '';
306
+
307
+ // 生成並顯示驗證碼
308
+ function generateCaptcha() {
309
+ const captchaCode = Math.floor(1000 + Math.random() * 9000).toString(); // 4位數
310
+ currentCaptcha = captchaCode;
311
+ document.getElementById('captcha-code').textContent = captchaCode;
312
+ }
313
+
314
  // 頁籤切換邏輯
315
  function showTab(tabId) {
316
  const allIframes = document.querySelectorAll('.iframe-wrapper');
 
331
  document.getElementById('loginForm').addEventListener('submit', function(event) {
332
  event.preventDefault();
333
 
334
+ const usernameInput = document.getElementById('username').value;
335
+ const passwordInput = document.getElementById('password').value;
336
+ const captchaInput = document.getElementById('captcha').value;
337
  const errorMessage = document.getElementById('error-message');
338
  const loginContainer = document.getElementById('login-container');
339
  const mainContent = document.getElementById('main-content');
 
341
  const correctUsername = 'ROOT2025';
342
  const correctPassword = '123456';
343
 
344
+ if (usernameInput === correctUsername && passwordInput === correctPassword && captchaInput === currentCaptcha) {
345
+ // 登入成功
346
  errorMessage.style.visibility = 'hidden';
347
  errorMessage.style.opacity = '0';
348
 
 
349
  loginContainer.style.display = 'none';
350
+ mainContent.style.display = 'block';
 
351
  } else {
352
+ // 登入失敗
353
  errorMessage.style.visibility = 'visible';
354
  errorMessage.style.opacity = '1';
355
+ generateCaptcha(); // 重新生成驗證碼
356
  }
357
  });
358
 
 
363
  const usernameInput = document.getElementById('username');
364
  const passwordInput = document.getElementById('password');
365
 
 
366
  mainContent.style.display = 'none';
 
367
  loginContainer.style.display = 'block';
368
 
 
369
  usernameInput.value = '';
370
  passwordInput.value = '';
371
+
372
+ generateCaptcha(); // 重新生成驗證碼
373
  }
374
+
375
+ // 網頁加載時,立即生成驗證碼
376
+ document.addEventListener('DOMContentLoaded', generateCaptcha);
377
  </script>
378
 
379
  </body>