z9760405 commited on
Commit
eba28ca
·
verified ·
1 Parent(s): a65eb27

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +388 -398
index.html CHANGED
@@ -1,540 +1,530 @@
1
  <!DOCTYPE html>
2
- <html lang="zh-TW">
3
 
4
  <head>
5
- <title>LLM+ 系統登入</title>
6
  <meta charset="UTF-8">
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
- <link rel="preconnect" href="https://fonts.googleapis.com">
9
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
- <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet">
11
  <style>
12
- :root {
13
- --sidebar-width: 240px;
14
- --accent-color: #00aaff;
15
- --background-color: #1a202c;
16
- --sidebar-bg-color: rgba(45, 55, 72, 0.7);
17
- --content-bg-color: #2d3748;
18
- --text-color: #e2e8f0;
19
- --text-muted-color: #a0aec0;
20
- --border-color: rgba(255, 255, 255, 0.1);
21
- --hover-bg-color: rgba(0, 170, 255, 0.1);
22
- --border-radius: 12px;
23
- --error-color: #f56565;
24
- --success-color: #48bb78;
25
- }
26
-
27
- * {
28
- box-sizing: border-box;
29
  margin: 0;
30
  padding: 0;
31
- }
32
-
33
- body {
34
- font-family: 'Poppins', 'Noto Sans TC', sans-serif;
35
- background-color: var(--background-color);
36
- color: var(--text-color);
37
  height: 100vh;
38
  overflow: hidden;
39
  }
40
 
41
- /* 登入頁面樣式 */
42
- .login-container {
 
 
43
  display: flex;
44
- align-items: center;
45
  justify-content: center;
46
- height: 100vh;
47
- background: linear-gradient(135deg, var(--background-color) 0%, #2a3441 100%);
48
  }
49
 
50
- .login-card {
51
- background: var(--sidebar-bg-color);
52
- backdrop-filter: blur(12px);
53
- -webkit-backdrop-filter: blur(12px);
54
- border: 1px solid var(--border-color);
55
- border-radius: var(--border-radius);
56
- padding: 3rem;
57
- width: 100%;
58
- max-width: 400px;
59
- box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
60
  }
61
 
62
- .login-title {
63
- font-size: 2rem;
64
- font-weight: 600;
65
- text-align: center;
66
- margin-bottom: 0.5rem;
67
- background: linear-gradient(45deg, var(--accent-color), #fff);
68
- -webkit-background-clip: text;
69
- -webkit-text-fill-color: transparent;
 
 
70
  }
71
 
72
- .login-subtitle {
73
- text-align: center;
74
- color: var(--text-muted-color);
75
- margin-bottom: 2rem;
76
- font-size: 0.9rem;
77
  }
78
 
79
- .form-group {
80
- margin-bottom: 1.5rem;
 
81
  }
82
 
83
- label {
 
 
84
  display: block;
85
- margin-bottom: 0.5rem;
86
- color: var(--text-color);
87
- font-weight: 500;
88
  }
89
 
90
- input[type="text"], input[type="password"] {
91
  width: 100%;
92
- padding: 0.8rem 1rem;
93
- border: 1px solid var(--border-color);
94
- border-radius: 8px;
95
- background-color: var(--content-bg-color);
96
- color: var(--text-color);
97
- font-size: 1rem;
 
98
  transition: all 0.3s ease;
 
99
  }
100
 
101
- input[type="text"]:focus, input[type="password"]:focus {
102
- outline: none;
103
- border-color: var(--accent-color);
104
- box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.1);
105
  }
106
 
107
- .captcha-container {
108
- display: flex;
109
- gap: 1rem;
110
- align-items: flex-end;
111
  }
112
 
113
- .captcha-display {
114
- background: var(--content-bg-color);
115
- border: 1px solid var(--border-color);
116
- border-radius: 8px;
117
- padding: 1rem;
118
- text-align: center;
119
- font-size: 1.2rem;
120
- font-weight: 600;
121
- letter-spacing: 2px;
122
- color: var(--accent-color);
123
- min-width: 100px;
124
- cursor: pointer;
125
- transition: all 0.3s ease;
126
  }
127
 
128
- .captcha-display:hover {
129
- background-color: var(--hover-bg-color);
 
130
  }
131
 
132
- .captcha-input {
133
- flex: 1;
 
 
 
 
 
 
 
 
 
 
134
  }
135
 
136
- .login-button {
137
  width: 100%;
138
- padding: 0.8rem 1rem;
139
- background: linear-gradient(45deg, var(--accent-color), #0099dd);
140
- color: white;
141
  border: none;
142
- border-radius: 8px;
143
- font-size: 1rem;
144
- font-weight: 500;
 
 
145
  cursor: pointer;
146
  transition: all 0.3s ease;
 
147
  }
148
 
149
- .login-button:hover:not(:disabled) {
150
- transform: translateY(-2px);
151
- box-shadow: 0 10px 25px -5px rgba(0, 170, 255, 0.3);
 
152
  }
153
 
154
- .login-button:disabled {
155
- opacity: 0.7;
156
- cursor: not-allowed;
157
- transform: none;
 
 
158
  }
159
 
160
- .error-message {
161
- color: var(--error-color);
162
- font-size: 0.85rem;
163
- margin-top: 0.5rem;
164
- text-align: center;
165
  }
166
 
167
- /* 系統主頁面樣式 */
168
- .main-system {
169
- display: none;
170
- grid-template-columns: var(--sidebar-width) 1fr;
171
  height: 100vh;
 
 
172
  }
173
 
174
- .tabs {
175
- background: var(--sidebar-bg-color);
176
- backdrop-filter: blur(12px);
177
- -webkit-backdrop-filter: blur(12px);
178
- border-right: 1px solid var(--border-color);
179
  display: flex;
180
  flex-direction: column;
181
- padding: 2rem 0;
182
- gap: 0.5rem;
183
- width: var(--sidebar-width);
184
- }
185
-
186
- .logout-section {
187
- margin-top: auto;
188
- padding: 1.5rem;
189
- border-top: 1px solid var(--border-color);
190
  }
191
 
192
- .logout-button {
193
- width: 100%;
194
- padding: 0.8rem 1rem;
195
- background: transparent;
196
- color: var(--error-color);
197
- border: 1px solid var(--error-color);
198
- border-radius: 8px;
199
- font-size: 0.9rem;
200
- font-weight: 500;
201
- cursor: pointer;
202
- transition: all 0.3s ease;
203
  }
204
 
205
- .logout-button:hover {
206
- background-color: var(--error-color);
207
- color: white;
208
  }
209
 
210
  .tab-button {
211
- padding: 1rem 1.5rem;
212
- cursor: pointer;
213
  border: none;
214
- background-color: transparent;
215
- color: var(--text-muted-color);
216
- text-align: left;
217
- outline: none;
218
  transition: all 0.3s ease;
219
- font-size: 1rem;
220
- font-weight: 500;
221
- border-left: 4px solid transparent;
 
222
  }
223
 
224
- .tab-button:hover {
225
- background-color: var(--hover-bg-color);
226
- color: var(--text-color);
227
  }
228
 
229
- .tab-button.active {
230
- background-color: var(--hover-bg-color);
231
- color: var(--accent-color);
232
- border-left: 4px solid var(--accent-color);
233
  }
234
 
235
- .content {
236
- padding: 2.5rem;
237
- flex-grow: 1;
 
 
 
 
 
 
238
  display: flex;
239
- flex-direction: column;
240
- overflow-y: auto;
 
241
  }
242
 
243
- h1 {
244
- font-size: 2.5rem;
245
- font-weight: 600;
246
- margin-bottom: 0.5rem;
247
- background: linear-gradient(45deg, var(--accent-color), #fff);
248
- -webkit-background-clip: text;
249
- -webkit-text-fill-color: transparent;
250
  }
251
 
252
- h2 {
253
- font-size: 1rem;
254
- font-weight: 300;
255
- color: var(--text-muted-color);
256
- margin-bottom: 2rem;
257
- border-bottom: 1px solid var(--border-color);
258
- padding-bottom: 1.5rem;
259
  }
260
 
261
  .tab-content {
 
 
 
 
 
 
 
262
  display: none;
263
- flex-grow: 1;
264
- animation: fadeIn 0.5s ease;
265
  }
266
 
267
- @keyframes fadeIn {
268
- from {
269
- opacity: 0;
270
- transform: translateY(10px);
271
- }
272
- to {
273
- opacity: 1;
274
- transform: translateY(0);
275
- }
276
  }
277
 
278
- iframe {
279
  width: 100%;
280
  height: 100%;
281
- border: 1px solid var(--border-color);
282
- border-radius: var(--border-radius);
283
- background-color: #fff;
284
  }
285
 
286
- /* 響應式設計 */
287
- @media (max-width: 768px) {
288
- .login-card {
289
- margin: 1rem;
290
- padding: 2rem;
291
- }
292
-
293
- .main-system {
294
- grid-template-columns: 1fr;
295
- grid-template-rows: auto 1fr;
296
- height: 100%;
297
- }
298
-
299
- .tabs {
300
- width: 100%;
301
- flex-direction: row;
302
- justify-content: space-around;
303
- padding: 0.5rem 0;
304
- border-right: none;
305
- border-bottom: 1px solid var(--border-color);
306
- }
307
-
308
- .logout-section {
309
- margin-top: 0;
310
- padding: 0.5rem;
311
- border-top: none;
312
- border-left: 1px solid var(--border-color);
313
- }
314
-
315
- .tab-button {
316
- border-left: none;
317
- border-bottom: 4px solid transparent;
318
- padding: 1rem;
319
- flex-grow: 1;
320
- text-align: center;
321
- }
322
-
323
- .tab-button.active {
324
- border-left: none;
325
- border-bottom: 4px solid var(--accent-color);
326
- }
327
-
328
- .content {
329
- padding: 1.5rem;
330
- }
331
-
332
- h1 {
333
- font-size: 1.8rem;
334
- }
335
 
336
- h2 {
337
- margin-bottom: 1.5rem;
338
- }
 
 
 
 
 
 
 
 
339
  }
340
  </style>
341
  </head>
342
 
343
  <body>
344
- <!-- 登入頁面 -->
345
- <div id="loginPage" class="login-container">
346
- <div class="login-card">
347
- <h1 class="login-title">LLM+ 系統</h1>
348
- <p class="login-subtitle">請輸入您的登入資訊</p>
349
-
350
- <form id="loginForm">
351
- <div class="form-group">
352
- <label for="username">帳號</label>
353
- <input type="text" id="username" name="username" required>
354
  </div>
355
-
356
- <div class="form-group">
357
- <label for="password">密碼</label>
358
- <input type="password" id="password" name="password" required>
359
  </div>
360
-
361
- <div class="form-group">
362
- <label>驗證碼</label>
363
  <div class="captcha-container">
364
- <div class="captcha-display" id="captchaDisplay" onclick="generateCaptcha()"></div>
365
- <input type="text" class="captcha-input" id="captchaInput" placeholder="請輸入驗證碼" required>
366
  </div>
367
  </div>
368
-
369
- <button type="submit" class="login-button">登入系統</button>
370
- <div id="errorMessage" class="error-message"></div>
371
  </form>
372
  </div>
373
- </div>
374
-
375
- <!-- 系統主頁面 -->
376
- <div id="mainSystem" class="main-system">
377
- <div class="tabs">
378
- <button class="tab-button" onclick="openTab(event, 'iframe01')">ESG爬蟲</button>
379
- <button class="tab-button" onclick="openTab(event, 'iframe02')">多模態API 應用</button>
380
- <button class="tab-button" onclick="openTab(event, 'iframe03')">Grop+Linebot+Webcam</button>
381
-
382
- <div class="logout-section">
383
- <button class="logout-button" onclick="logout()">登出系統</button>
384
  </div>
 
385
  </div>
386
-
387
- <div class="content">
388
- <h1>LLM+ Web scraping Application</h1>
389
- <h2>elliot hsu@2025copyright</h2>
390
-
391
- <div id="iframe01" class="tab-content">
392
  <iframe src="https://z9760405-steamlit.hf.space" frameborder="0"></iframe>
393
  </div>
394
 
395
  <div id="iframe02" class="tab-content">
396
  <iframe src="https://cjian2025-groq-api-gradio.hf.space" frameborder="0"></iframe>
397
  </div>
398
-
399
  <div id="iframe03" class="tab-content">
400
  <iframe src="https://z9760405-webcam-groq-linebot-application.hf.space" frameborder="0"
401
  allow="camera; microphone"></iframe>
402
  </div>
 
 
 
 
403
  </div>
 
 
 
 
 
 
 
 
404
  </div>
405
 
406
  <script>
407
- // 全域變數
408
- let currentCaptcha = '';
409
- const CORRECT_USERNAME_HASH = 'd7113846e19051e6d5752f60dcb53329e9563b2c7655452fb9aea5f27969cc4f';
410
- const CORRECT_PASSWORD_HASH = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92';
411
-
412
- // SHA-256 雜湊函數
413
- async function sha256(text) {
414
- const encoder = new TextEncoder();
415
- const data = encoder.encode(text);
416
- const hashBuffer = await crypto.subtle.digest('SHA-256', data);
417
- const hashArray = Array.from(new Uint8Array(hashBuffer));
418
- const hashHex = hashArray.map(byte => byte.toString(16).padStart(2, '0')).join('');
419
- return hashHex;
420
- }
421
-
422
- // 生成驗證碼
423
- function generateCaptcha() {
424
- const characters = 'ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789';
425
- currentCaptcha = '';
426
- for (let i = 0; i < 5; i++) {
427
- currentCaptcha += characters.charAt(Math.floor(Math.random() * characters.length));
 
 
 
 
428
  }
429
- document.getElementById('captchaDisplay').textContent = currentCaptcha;
430
- }
431
 
432
- // 驗證登入 (使用非同步函數處理 HASH)
433
- async function validateLogin(username, password, captcha) {
434
- const errorElement = document.getElementById('errorMessage');
435
- errorElement.textContent = '';
 
436
 
437
- // 計算輸入的帳號和密碼的 HASH
438
- const usernameHash = await sha256(username);
439
- const passwordHash = await sha256(password);
440
 
441
- if (usernameHash !== CORRECT_USERNAME_HASH) {
442
- errorElement.textContent = '帳號錯誤!';
443
- return false;
 
 
 
 
 
 
 
 
 
 
444
  }
445
 
446
- if (passwordHash !== CORRECT_PASSWORD_HASH) {
447
- errorElement.textContent = '密碼錯誤!';
448
- return false;
 
 
 
 
 
 
449
  }
450
 
451
- if (captcha.toLowerCase() !== currentCaptcha.toLowerCase()) {
452
- errorElement.textContent = '驗證碼錯誤!';
453
- generateCaptcha(); // 重新生成驗證碼
454
- document.getElementById('captchaInput').value = '';
455
- return false;
456
  }
457
 
458
- return true;
459
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
 
461
- // 登入成功,切換到系統頁面
462
- function showMainSystem() {
463
- document.getElementById('loginPage').style.display = 'none';
464
- document.getElementById('mainSystem').style.display = 'grid';
465
-
466
- // 自動點擊第一個 tab
467
- if (document.getElementsByClassName("tab-button")[0]) {
468
- document.getElementsByClassName("tab-button")[0].click();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
  }
470
- }
471
-
472
- // 登出,返回登入頁面
473
- function logout() {
474
- document.getElementById('mainSystem').style.display = 'none';
475
- document.getElementById('loginPage').style.display = 'flex';
476
-
477
- // 清空登入表單
478
- document.getElementById('loginForm').reset();
479
- document.getElementById('errorMessage').textContent = '';
480
- generateCaptcha();
481
- }
482
 
483
- // Tab 切換功能
484
- function openTab(evt, tabName) {
485
- var i, tabcontent, tabbuttons;
486
- tabcontent = document.getElementsByClassName("tab-content");
487
- for (i = 0; i < tabcontent.length; i++) {
488
- tabcontent[i].style.display = "none";
489
- }
490
- tabbuttons = document.getElementsByClassName("tab-button");
491
- for (i = 0; i < tabbuttons.length; i++) {
492
- tabbuttons[i].className = tabbuttons[i].className.replace(" active", "");
 
 
493
  }
494
- document.getElementById(tabName).style.display = "block";
495
- evt.currentTarget.className += " active";
496
- }
497
 
498
- // 初始化
499
- document.addEventListener('DOMContentLoaded', function() {
500
- // 生成初始驗證碼
 
 
 
 
501
  generateCaptcha();
 
502
 
503
- // 登入表單提交事件 (使用非同步處理)
504
- document.getElementById('loginForm').addEventListener('submit', async function(e) {
505
- e.preventDefault();
506
-
507
- const username = document.getElementById('username').value;
508
- const password = document.getElementById('password').value;
509
- const captcha = document.getElementById('captchaInput').value;
 
510
 
511
- // 顯示載入狀態
512
- const loginButton = document.querySelector('.login-button');
513
- const originalText = loginButton.textContent;
514
- loginButton.textContent = '驗證中...';
515
- loginButton.disabled = true;
516
 
517
- try {
518
- const isValid = await validateLogin(username, password, captcha);
519
- if (isValid) {
520
- showMainSystem();
521
- }
522
- } catch (error) {
523
- document.getElementById('errorMessage').textContent = '登入驗證失敗,請重試';
524
- } finally {
525
- // 恢復按鈕狀態
526
- loginButton.textContent = originalText;
527
- loginButton.disabled = false;
528
- }
529
- });
530
 
531
- // Enter 鍵也可以登入
532
- document.addEventListener('keypress', function(e) {
533
- if (e.key === 'Enter' && document.getElementById('loginPage').style.display !== 'none') {
534
- document.getElementById('loginForm').dispatchEvent(new Event('submit'));
535
- }
536
- });
537
- });
 
 
 
 
 
538
  </script>
539
 
540
  </body>
 
1
  <!DOCTYPE html>
2
+ <html lang="zh-Hant">
3
 
4
  <head>
 
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>PKM_RAG 系統登入</title>
 
 
8
  <style>
9
+ /* --- 基本與通用樣式 --- */
10
+ body,
11
+ html {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  margin: 0;
13
  padding: 0;
14
+ font-family: 'Poppins', sans-serif, 'Microsoft JhengHei', sans-serif;
 
 
 
 
 
15
  height: 100vh;
16
  overflow: hidden;
17
  }
18
 
19
+ /* --- 登入頁面 (來自 HTML02) --- */
20
+ #login-section {
21
+ background: url("https://images.unsplash.com/photo-1503264116251-35a269479413") no-repeat center center/cover;
22
+ height: 100vh;
23
  display: flex;
 
24
  justify-content: center;
25
+ align-items: center;
26
+ transition: opacity 0.6s ease-out;
27
  }
28
 
29
+ .login-container {
30
+ background: rgba(255, 255, 255, 0.1);
31
+ backdrop-filter: blur(15px);
32
+ border-radius: 20px;
33
+ padding: 40px;
34
+ width: 380px;
35
+ text-align: center;
36
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
37
+ animation: fadeIn 1.5s ease;
38
+ border: 1px solid rgba(255, 255, 255, 0.2);
39
  }
40
 
41
+ @keyframes fadeIn {
42
+ from {
43
+ opacity: 0;
44
+ transform: translateY(-50px);
45
+ }
46
+
47
+ to {
48
+ opacity: 1;
49
+ transform: translateY(0);
50
+ }
51
  }
52
 
53
+ .login-container h2 {
54
+ color: white;
55
+ margin-bottom: 25px;
56
+ font-size: 2em;
 
57
  }
58
 
59
+ .input-box {
60
+ margin-bottom: 20px;
61
+ text-align: left;
62
  }
63
 
64
+ .input-box label {
65
+ color: white;
66
+ font-weight: bold;
67
  display: block;
68
+ margin-bottom: 8px;
 
 
69
  }
70
 
71
+ .input-box input {
72
  width: 100%;
73
+ padding: 12px;
74
+ border: 1px solid transparent;
75
+ border-radius: 10px;
76
+ background: rgba(255, 255, 255, 0.2);
77
+ color: white;
78
+ font-size: 16px;
79
+ outline: none;
80
  transition: all 0.3s ease;
81
+ box-sizing: border-box;
82
  }
83
 
84
+ .input-box input::placeholder {
85
+ color: rgba(255, 255, 255, 0.7);
 
 
86
  }
87
 
88
+ .input-box input:focus {
89
+ background: rgba(255, 255, 255, 0.3);
90
+ box-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
91
+ border-color: rgba(0, 242, 254, 0.7);
92
  }
93
 
94
+ .captcha-container {
95
+ display: flex;
96
+ align-items: center;
97
+ justify-content: space-between;
98
+ margin-top: 5px;
 
 
 
 
 
 
 
 
99
  }
100
 
101
+ #captcha-input {
102
+ width: 55%;
103
+ margin: 0;
104
  }
105
 
106
+ #captcha-display {
107
+ font-size: 24px;
108
+ font-weight: bold;
109
+ padding: 5px 15px;
110
+ border-radius: 10px;
111
+ background: rgba(0, 0, 0, 0.3);
112
+ color: #fff;
113
+ letter-spacing: 4px;
114
+ user-select: none;
115
+ cursor: pointer;
116
+ text-decoration: line-through;
117
+ border: 1px solid rgba(255, 255, 255, 0.2);
118
  }
119
 
120
+ .btn {
121
  width: 100%;
122
+ padding: 12px;
 
 
123
  border: none;
124
+ border-radius: 10px;
125
+ background: linear-gradient(135deg, #4facfe, #00f2fe);
126
+ color: white;
127
+ font-size: 18px;
128
+ font-weight: bold;
129
  cursor: pointer;
130
  transition: all 0.3s ease;
131
+ margin-top: 15px;
132
  }
133
 
134
+ .btn:hover {
135
+ transform: scale(1.05);
136
+ box-shadow: 0 0 15px rgba(0, 242, 254, 0.6);
137
+ background: linear-gradient(135deg, #00f2fe, #4facfe);
138
  }
139
 
140
+ .msg {
141
+ margin-top: 15px;
142
+ font-size: 14px;
143
+ color: #ffc107;
144
+ font-weight: bold;
145
+ min-height: 20px;
146
  }
147
 
148
+ .msg.error {
149
+ color: #ff4d4d;
 
 
 
150
  }
151
 
152
+ /* --- 主系統頁面 --- */
153
+ #main-app-section {
154
+ display: flex;
 
155
  height: 100vh;
156
+ opacity: 0;
157
+ transition: opacity 0.6s ease-in;
158
  }
159
 
160
+ .sidebar {
161
+ width: 260px;
162
+ background-color: #1c2833;
163
+ color: white;
 
164
  display: flex;
165
  flex-direction: column;
166
+ padding: 20px;
167
+ box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
168
+ box-sizing: border-box;
 
 
 
 
 
 
169
  }
170
 
171
+ .sidebar h1 {
172
+ font-size: 24px;
173
+ text-align: center;
174
+ color: #ecf0f1;
175
+ margin: 0 0 30px 0;
176
+ border-bottom: 1px solid #2c3e50;
177
+ padding-bottom: 15px;
 
 
 
 
178
  }
179
 
180
+ .tabs {
181
+ flex-grow: 1;
 
182
  }
183
 
184
  .tab-button {
185
+ width: 100%;
186
+ padding: 15px 20px;
187
  border: none;
188
+ border-radius: 8px;
189
+ margin-bottom: 10px;
190
+ cursor: pointer;
 
191
  transition: all 0.3s ease;
192
+ font-size: 16px;
193
+ text-align: left;
194
+ background-color: #2c3e50;
195
+ color: white;
196
  }
197
 
198
+ .tab-button.active {
199
+ background-color: #3498db;
200
+ transform: translateX(5px);
201
  }
202
 
203
+ .tab-button:not(.active):hover {
204
+ background-color: #34495e;
205
+ transform: translateX(2px);
 
206
  }
207
 
208
+ #logout-button {
209
+ padding: 12px;
210
+ border: none;
211
+ border-radius: 10px;
212
+ background-color: #e74c3c;
213
+ color: white;
214
+ font-size: 16px;
215
+ cursor: pointer;
216
+ transition: all 0.3s ease;
217
  display: flex;
218
+ align-items: center;
219
+ justify-content: center;
220
+ gap: 8px;
221
  }
222
 
223
+ #logout-button:hover {
224
+ background-color: #c0392b;
225
+ transform: translateY(-2px);
 
 
 
 
226
  }
227
 
228
+ .content-area {
229
+ flex-grow: 1;
230
+ background-color: #ecf0f1;
231
+ position: relative;
 
 
 
232
  }
233
 
234
  .tab-content {
235
+ width: 100%;
236
+ height: 100%;
237
+ position: absolute;
238
+ top: 0;
239
+ left: 0;
240
+ opacity: 0;
241
+ transition: opacity 0.3s ease;
242
  display: none;
 
 
243
  }
244
 
245
+ .tab-content.active {
246
+ opacity: 1;
247
+ display: block;
 
 
 
 
 
 
248
  }
249
 
250
+ .content-area iframe {
251
  width: 100%;
252
  height: 100%;
253
+ border: none;
 
 
254
  }
255
 
256
+ /* --- 顯示/隱藏控制 --- */
257
+ .hidden {
258
+ display: none !important;
259
+ opacity: 0 !important;
260
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
 
262
+ /* 添加測試帳號顯示區域 */
263
+ .test-info {
264
+ position: fixed;
265
+ bottom: 20px;
266
+ right: 20px;
267
+ background: rgba(0, 0, 0, 0.8);
268
+ color: white;
269
+ padding: 15px;
270
+ border-radius: 10px;
271
+ font-size: 12px;
272
+ z-index: 1000;
273
  }
274
  </style>
275
  </head>
276
 
277
  <body>
278
+
279
+ <section id="login-section">
280
+ <div class="login-container">
281
+ <h2>PKM_RAG System</h2>
282
+ <form id="login-form" autocomplete="off">
283
+ <div class="input-box">
284
+ <label for="username">帳號 (Username)</label>
285
+ <input type="text" id="username" placeholder="請輸入帳號" required>
 
 
286
  </div>
287
+ <div class="input-box">
288
+ <label for="password">密碼 (Password)</label>
289
+ <input type="password" id="password" placeholder="請輸入密碼" required>
 
290
  </div>
291
+ <div class="input-box">
292
+ <label for="captcha-input">驗證碼 (Captcha)</label>
 
293
  <div class="captcha-container">
294
+ <input type="text" id="captcha-input" placeholder="輸入右側文字" required>
295
+ <span id="captcha-display" title="點擊更換驗證碼"></span>
296
  </div>
297
  </div>
298
+ <button class="btn" type="submit">登入 (Login)</button>
299
+ <p class="msg" id="msg"></p>
 
300
  </form>
301
  </div>
302
+ </section>
303
+
304
+ <section id="main-app-section" class="hidden">
305
+ <div class="sidebar">
306
+ <h1>主選單</h1>
307
+ <div class="tabs">
308
+ <button class="tab-button active" onclick="openTab(event, 'iframe01')">ESG爬蟲</button>
309
+ <button class="tab-button" onclick="openTab(event, 'iframe02')">多模態API 應用</button>
310
+ <button class="tab-button" onclick="openTab(event, 'iframe03')">Grop+Linebot+Webcam</button>
311
+ <button class="tab-button" onclick="openTab(event, 'iframe04')">RAG知識庫</button>
 
312
  </div>
313
+ <button id="logout-button">回到登入頁面</button>
314
  </div>
315
+ <div class="content-area">
316
+ <div id="iframe01" class="tab-content active">
 
 
 
 
317
  <iframe src="https://z9760405-steamlit.hf.space" frameborder="0"></iframe>
318
  </div>
319
 
320
  <div id="iframe02" class="tab-content">
321
  <iframe src="https://cjian2025-groq-api-gradio.hf.space" frameborder="0"></iframe>
322
  </div>
323
+
324
  <div id="iframe03" class="tab-content">
325
  <iframe src="https://z9760405-webcam-groq-linebot-application.hf.space" frameborder="0"
326
  allow="camera; microphone"></iframe>
327
  </div>
328
+
329
+ <div id="iframe04" class="tab-content">
330
+ <iframe src="https://z9760405-resendlangchain.hf.space" frameborder="0"></iframe>
331
+ </div>
332
  </div>
333
+ </section>
334
+
335
+ <!-- 測試用帳號密碼顯示 -->
336
+ <div class="test-info">
337
+ <strong>測試帳號:</strong><br>
338
+ 帳號: ROOT2025 (不區分大小寫)<br>
339
+ 密碼: 123456<br>
340
+ 驗證碼: 點擊右側文字更換
341
  </div>
342
 
343
  <script>
344
+ document.addEventListener('DOMContentLoaded', () => {
345
+ console.log('頁面載入完成,開始初始化...');
346
+
347
+ // --- DOM 元素 ---
348
+ const loginSection = document.getElementById('login-section');
349
+ const mainAppSection = document.getElementById('main-app-section');
350
+ const loginForm = document.getElementById('login-form');
351
+ const usernameInput = document.getElementById('username');
352
+ const passwordInput = document.getElementById('password');
353
+ const captchaInput = document.getElementById('captcha-input');
354
+ const captchaDisplay = document.getElementById('captcha-display');
355
+ const msg = document.getElementById('msg');
356
+ const logoutButton = document.getElementById('logout-button');
357
+
358
+ // 檢查所有 DOM 元素是否正確載入
359
+ const elements = {
360
+ loginSection, mainAppSection, loginForm, usernameInput,
361
+ passwordInput, captchaInput, captchaDisplay, msg, logoutButton
362
+ };
363
+
364
+ for (const [name, element] of Object.entries(elements)) {
365
+ if (!element) {
366
+ console.error(`錯誤: 找不到元素 ${name}`);
367
+ return;
368
+ }
369
  }
370
+ console.log('所有 DOM 元素載入成功');
 
371
 
372
+ // --- 預先計算好的 SHA-256 HASH 值 ---
373
+ // 正確帳號: ROOT2025 -> sha256 -> d7113846e19051e6d5752f60dcb53329e9563b2c7655452fb9aea5f27969cc4f
374
+ const correctUserHash = 'd7113846e19051e6d5752f60dcb53329e9563b2c7655452fb9aea5f27969cc4f';
375
+ // 正確密碼: 123456 -> sha256 -> 8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92
376
+ const correctPassHash = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92';
377
 
378
+ let currentCaptcha = '';
 
 
379
 
380
+ // --- 功能函式 ---
381
+ async function sha256(str) {
382
+ try {
383
+ const textBuffer = new TextEncoder().encode(str);
384
+ const hashBuffer = await crypto.subtle.digest('SHA-256', textBuffer);
385
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
386
+ const hash = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
387
+ console.log(`SHA256("${str}") = ${hash}`);
388
+ return hash;
389
+ } catch (error) {
390
+ console.error('SHA256 計算錯誤:', error);
391
+ throw error;
392
+ }
393
  }
394
 
395
+ function generateCaptcha() {
396
+ const chars = 'AbCdEfGhIjKlMnOpQrStUvWxYz0123456789';
397
+ let captcha = '';
398
+ for (let i = 0; i < 5; i++) {
399
+ captcha += chars.charAt(Math.floor(Math.random() * chars.length));
400
+ }
401
+ currentCaptcha = captcha;
402
+ captchaDisplay.textContent = currentCaptcha;
403
+ console.log('新驗證碼生成:', currentCaptcha);
404
  }
405
 
406
+ function showMessage(message, isError = true) {
407
+ msg.textContent = message;
408
+ msg.className = isError ? 'msg error' : 'msg';
409
+ console.log('顯示訊息:', message, '錯誤狀態:', isError);
 
410
  }
411
 
412
+ async function handleLogin(e) {
413
+ e.preventDefault();
414
+ console.log('開始處理登入...');
415
+ showMessage('', false);
416
+
417
+ const username = usernameInput.value.trim();
418
+ const password = passwordInput.value;
419
+ const captcha = captchaInput.value.trim();
420
+
421
+ console.log('輸入資訊:');
422
+ console.log('- 帳號:', username);
423
+ console.log('- 密碼長度:', password.length);
424
+ console.log('- 驗證碼:', captcha);
425
+ console.log('- 當前驗證碼:', currentCaptcha);
426
+
427
+ // 步驟 1: 優先檢查驗證碼
428
+ if (captcha.toLowerCase() !== currentCaptcha.toLowerCase()) {
429
+ console.log('驗證碼錯誤');
430
+ showMessage('❌ 驗證碼錯誤!請重新輸入。');
431
+ generateCaptcha();
432
+ captchaInput.value = '';
433
+ return;
434
+ }
435
 
436
+ try {
437
+ // 步驟 2: 雜湊使用者輸入
438
+ const enteredUserHash = await sha256(username.toUpperCase());
439
+ const enteredPassHash = await sha256(password);
440
+
441
+ console.log('Hash 比對:');
442
+ console.log('- 輸入帳號 Hash:', enteredUserHash);
443
+ console.log('- 正確帳號 Hash:', correctUserHash);
444
+ console.log('- 輸入密碼 Hash:', enteredPassHash);
445
+ console.log('- 正確密碼 Hash:', correctPassHash);
446
+
447
+ // 步驟 3: 比對 HASH 值
448
+ if (enteredUserHash === correctUserHash && enteredPassHash === correctPassHash) {
449
+ // 登入成功
450
+ console.log('登入成功!');
451
+ showMessage('✅ 登入成功!正在載入系統...', false);
452
+ loginSection.style.opacity = '0';
453
+ setTimeout(() => {
454
+ loginSection.classList.add('hidden');
455
+ mainAppSection.classList.remove('hidden');
456
+ mainAppSection.style.opacity = '1';
457
+ console.log('切換到主頁面完成');
458
+ }, 600);
459
+ } else {
460
+ // 登入失敗
461
+ console.log('帳號或密碼錯誤');
462
+ showMessage('❌ 帳號或密碼錯誤!');
463
+ generateCaptcha();
464
+ passwordInput.value = '';
465
+ captchaInput.value = '';
466
+ }
467
+ } catch (error) {
468
+ console.error('登入處理錯誤:', error);
469
+ showMessage('❌ 系統錯誤,請重試!');
470
+ }
471
  }
 
 
 
 
 
 
 
 
 
 
 
 
472
 
473
+ function handleLogout() {
474
+ console.log('處理登出...');
475
+ mainAppSection.style.opacity = '0';
476
+ setTimeout(() => {
477
+ mainAppSection.classList.add('hidden');
478
+ loginSection.classList.remove('hidden');
479
+ loginSection.style.opacity = '1';
480
+ loginForm.reset();
481
+ showMessage('');
482
+ generateCaptcha();
483
+ console.log('登出完成');
484
+ }, 600);
485
  }
 
 
 
486
 
487
+ // --- 事件監聽 ---
488
+ loginForm.addEventListener('submit', handleLogin);
489
+ logoutButton.addEventListener('click', handleLogout);
490
+ captchaDisplay.addEventListener('click', generateCaptcha);
491
+
492
+ // --- 初始化 ---
493
+ console.log('開始初始化驗證碼...');
494
  generateCaptcha();
495
+ console.log('系統初始化完成');
496
 
497
+ // 測試用途:10秒後隱藏測試資訊
498
+ setTimeout(() => {
499
+ const testInfo = document.querySelector('.test-info');
500
+ if (testInfo) {
501
+ testInfo.style.display = 'none';
502
+ }
503
+ }, 10000);
504
+ });
505
 
506
+ // --- 選單切換功能 ---
507
+ function openTab(evt, tabName) {
508
+ console.log('切換到頁籤:', tabName);
 
 
509
 
510
+ // 隱藏所有內容
511
+ var tabContents = document.getElementsByClassName("tab-content");
512
+ for (var i = 0; i < tabContents.length; i++) {
513
+ tabContents[i].classList.remove("active");
514
+ }
 
 
 
 
 
 
 
 
515
 
516
+ // 移除所有按鈕的 active 類別
517
+ var tabButtons = document.getElementsByClassName("tab-button");
518
+ for (var i = 0; i < tabButtons.length; i++) {
519
+ tabButtons[i].classList.remove("active");
520
+ }
521
+
522
+ // 顯示選中的內容並激活按鈕
523
+ document.getElementById(tabName).classList.add("active");
524
+ evt.currentTarget.classList.add("active");
525
+
526
+ console.log('頁籤切換完成:', tabName);
527
+ }
528
  </script>
529
 
530
  </body>