File size: 18,713 Bytes
4612595
eba28ca
007003e
4612595
007003e
 
eba28ca
007003e
eba28ca
 
 
007003e
 
eba28ca
007003e
 
 
 
eba28ca
 
 
 
6c57d81
 
eba28ca
 
6c57d81
 
eba28ca
 
 
 
 
 
 
 
 
 
6c57d81
 
eba28ca
 
 
 
 
 
 
 
 
 
6c57d81
 
eba28ca
 
 
 
6c57d81
 
eba28ca
 
 
6c57d81
 
eba28ca
 
 
6c57d81
eba28ca
6c57d81
 
eba28ca
6c57d81
eba28ca
 
 
 
 
 
 
6c57d81
eba28ca
6c57d81
 
eba28ca
 
6c57d81
 
eba28ca
 
 
 
6c57d81
 
eba28ca
 
 
 
 
6c57d81
 
eba28ca
 
 
6c57d81
 
eba28ca
 
 
 
 
 
 
 
 
 
 
 
6c57d81
 
eba28ca
6c57d81
eba28ca
6c57d81
eba28ca
 
 
 
 
6c57d81
 
eba28ca
6c57d81
 
eba28ca
 
 
 
6c57d81
 
eba28ca
 
 
 
 
 
60f6973
 
eba28ca
 
6c57d81
 
eba28ca
 
 
6c57d81
eba28ca
 
6c57d81
 
eba28ca
 
 
 
007003e
 
eba28ca
 
 
6c57d81
 
eba28ca
 
 
 
 
 
 
6c57d81
 
eba28ca
 
007003e
 
 
eba28ca
 
007003e
eba28ca
 
 
007003e
eba28ca
 
 
 
007003e
 
eba28ca
 
 
007003e
 
eba28ca
 
 
007003e
 
eba28ca
 
 
 
 
 
 
 
 
007003e
eba28ca
 
 
007003e
 
eba28ca
 
 
007003e
 
eba28ca
 
 
 
007003e
 
 
eba28ca
 
 
 
 
 
 
007003e
 
 
eba28ca
 
 
007003e
 
eba28ca
007003e
 
eba28ca
007003e
 
eba28ca
 
 
 
 
007003e
eba28ca
 
 
 
 
 
 
 
 
 
 
007003e
 
4612595
 
007003e
eba28ca
 
 
 
 
 
 
 
6c57d81
eba28ca
 
 
6c57d81
eba28ca
 
6c57d81
eba28ca
 
6c57d81
 
eba28ca
 
6c57d81
007003e
eba28ca
 
 
 
 
 
 
 
 
 
c4569bc
6c57d81
eba28ca
007003e
eba28ca
 
6c57d81
 
 
 
 
 
eba28ca
6c57d81
 
 
 
eba28ca
 
 
 
c4569bc
 
 
 
007003e
eba28ca
 
 
 
 
 
 
 
4612595
 
007003e
eba28ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c57d81
eba28ca
6c57d81
eba28ca
 
 
 
 
6c57d81
eba28ca
60f6973
eba28ca
 
 
 
 
 
 
 
 
 
 
 
 
6c57d81
 
eba28ca
 
 
 
 
 
 
 
 
6c57d81
 
eba28ca
 
 
 
6c57d81
 
eba28ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c57d81
eba28ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c57d81
 
eba28ca
 
 
 
 
 
 
 
 
 
 
 
007003e
 
eba28ca
 
 
 
 
 
 
6c57d81
eba28ca
6c57d81
eba28ca
 
 
 
 
 
 
 
6c57d81
eba28ca
 
 
60f6973
eba28ca
 
 
 
 
6c57d81
eba28ca
 
 
 
 
 
 
 
 
 
 
 
007003e
4612595
 
007003e
4612595
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
<!DOCTYPE html>
<html lang="zh-Hant">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PKM_RAG 系統登入</title>
    <style>
        /* --- 基本與通用樣式 --- */
        body,
        html {
            margin: 0;
            padding: 0;
            font-family: 'Poppins', sans-serif, 'Microsoft JhengHei', sans-serif;
            height: 100vh;
            overflow: hidden;
        }

        /* --- 登入頁面 (來自 HTML02) --- */
        #login-section {
            background: url("https://images.unsplash.com/photo-1503264116251-35a269479413") no-repeat center center/cover;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: opacity 0.6s ease-out;
        }

        .login-container {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(15px);
            border-radius: 20px;
            padding: 40px;
            width: 380px;
            text-align: center;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
            animation: fadeIn 1.5s ease;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(-50px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .login-container h2 {
            color: white;
            margin-bottom: 25px;
            font-size: 2em;
        }

        .input-box {
            margin-bottom: 20px;
            text-align: left;
        }

        .input-box label {
            color: white;
            font-weight: bold;
            display: block;
            margin-bottom: 8px;
        }

        .input-box input {
            width: 100%;
            padding: 12px;
            border: 1px solid transparent;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.2);
            color: white;
            font-size: 16px;
            outline: none;
            transition: all 0.3s ease;
            box-sizing: border-box;
        }

        .input-box input::placeholder {
            color: rgba(255, 255, 255, 0.7);
        }

        .input-box input:focus {
            background: rgba(255, 255, 255, 0.3);
            box-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
            border-color: rgba(0, 242, 254, 0.7);
        }

        .captcha-container {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-top: 5px;
        }

        #captcha-input {
            width: 55%;
            margin: 0;
        }

        #captcha-display {
            font-size: 24px;
            font-weight: bold;
            padding: 5px 15px;
            border-radius: 10px;
            background: rgba(0, 0, 0, 0.3);
            color: #fff;
            letter-spacing: 4px;
            user-select: none;
            cursor: pointer;
            text-decoration: line-through;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .btn {
            width: 100%;
            padding: 12px;
            border: none;
            border-radius: 10px;
            background: linear-gradient(135deg, #4facfe, #00f2fe);
            color: white;
            font-size: 18px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-top: 15px;
        }

        .btn:hover {
            transform: scale(1.05);
            box-shadow: 0 0 15px rgba(0, 242, 254, 0.6);
            background: linear-gradient(135deg, #00f2fe, #4facfe);
        }

        .msg {
            margin-top: 15px;
            font-size: 14px;
            color: #ffc107;
            font-weight: bold;
            min-height: 20px;
        }

        .msg.error {
            color: #ff4d4d;
        }

        /* --- 主系統頁面 --- */
        #main-app-section {
            display: flex;
            height: 100vh;
            opacity: 0;
            transition: opacity 0.6s ease-in;
        }

        .sidebar {
            width: 260px;
            background-color: #1c2833;
            color: white;
            display: flex;
            flex-direction: column;
            padding: 20px;
            box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
            box-sizing: border-box;
        }

        .sidebar h1 {
            font-size: 24px;
            text-align: center;
            color: #ecf0f1;
            margin: 0 0 30px 0;
            border-bottom: 1px solid #2c3e50;
            padding-bottom: 15px;
        }

        .tabs {
            flex-grow: 1;
        }

        .tab-button {
            width: 100%;
            padding: 15px 20px;
            border: none;
            border-radius: 8px;
            margin-bottom: 10px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 16px;
            text-align: left;
            background-color: #2c3e50;
            color: white;
        }

        .tab-button.active {
            background-color: #3498db;
            transform: translateX(5px);
        }

        .tab-button:not(.active):hover {
            background-color: #34495e;
            transform: translateX(2px);
        }

        #logout-button {
            padding: 12px;
            border: none;
            border-radius: 10px;
            background-color: #e74c3c;
            color: white;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        #logout-button:hover {
            background-color: #c0392b;
            transform: translateY(-2px);
        }

        .content-area {
            flex-grow: 1;
            background-color: #ecf0f1;
            position: relative;
        }

        .tab-content {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            opacity: 0;
            transition: opacity 0.3s ease;
            display: none;
        }

        .tab-content.active {
            opacity: 1;
            display: block;
        }

        .content-area iframe {
            width: 100%;
            height: 100%;
            border: none;
        }

        /* --- 顯示/隱藏控制 --- */
        .hidden {
            display: none !important;
            opacity: 0 !important;
        }

        /* 添加測試帳號顯示區域 */
        .test-info {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 15px;
            border-radius: 10px;
            font-size: 12px;
            z-index: 1000;
        }
    </style>
</head>

<body>

    <section id="login-section">
        <div class="login-container">
            <h2>PKM_RAG System</h2>
            <form id="login-form" autocomplete="off">
                <div class="input-box">
                    <label for="username">帳號 (Username)</label>
                    <input type="text" id="username" placeholder="請輸入帳號" required>
                </div>
                <div class="input-box">
                    <label for="password">密碼 (Password)</label>
                    <input type="password" id="password" placeholder="請輸入密碼" required>
                </div>
                <div class="input-box">
                    <label for="captcha-input">驗證碼 (Captcha)</label>
                    <div class="captcha-container">
                        <input type="text" id="captcha-input" placeholder="輸入右側文字" required>
                        <span id="captcha-display" title="點擊更換驗證碼"></span>
                    </div>
                </div>
                <button class="btn" type="submit">登入 (Login)</button>
                <p class="msg" id="msg"></p>
            </form>
        </div>
    </section>

    <section id="main-app-section" class="hidden">
        <div class="sidebar">
            <h1>主選單</h1>
            <div class="tabs">
                <button class="tab-button active" onclick="openTab(event, 'iframe01')">ESG爬蟲</button>
                <button class="tab-button" onclick="openTab(event, 'iframe02')">多模態API 應用</button>
                <button class="tab-button" onclick="openTab(event, 'iframe03')">Grop+Linebot+Webcam</button>
                <button class="tab-button" onclick="openTab(event, 'iframe04')">RAG知識庫</button>
                <button class="tab-button" onclick="openTab(event, 'iframe05')">Gemini比對+Resend</button>
            </div>
            <button id="logout-button">回到登入頁面</button>
        </div>
        <div class="content-area">
            <div id="iframe01" class="tab-content active">
                <iframe src="https://z9760405-steamlit.hf.space" frameborder="0"></iframe>
            </div>

            <div id="iframe02" class="tab-content">
                <iframe src="https://cjian2025-groq-api-gradio.hf.space" frameborder="0"></iframe>
            </div>

            <div id="iframe03" class="tab-content">
                <iframe src="https://z9760405-webcam-groq-linebot-application.hf.space" frameborder="0"
                    allow="camera; microphone"></iframe>
            </div>

            <div id="iframe04" class="tab-content">
                <iframe src="https://z9760405-resendlangchain.hf.space" frameborder="0"></iframe>
            </div>

            <div id="iframe05" class="tab-content">
                <iframe src="https://z9760405-gemini-ocr-resend0914.hf.space" frameborder="0"></iframe>
            </div>
        </div>
    </section>

    <!-- 測試用帳號密碼顯示 -->
    <div class="test-info">
        <strong>測試帳號:</strong><br>
        帳號: ROOT2025 (不區分大小寫)<br>
        密碼: 123456<br>
        驗證碼: 點擊右側文字更換
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            console.log('頁面載入完成,開始初始化...');

            // --- DOM 元素 ---
            const loginSection = document.getElementById('login-section');
            const mainAppSection = document.getElementById('main-app-section');
            const loginForm = document.getElementById('login-form');
            const usernameInput = document.getElementById('username');
            const passwordInput = document.getElementById('password');
            const captchaInput = document.getElementById('captcha-input');
            const captchaDisplay = document.getElementById('captcha-display');
            const msg = document.getElementById('msg');
            const logoutButton = document.getElementById('logout-button');

            // 檢查所有 DOM 元素是否正確載入
            const elements = {
                loginSection, mainAppSection, loginForm, usernameInput,
                passwordInput, captchaInput, captchaDisplay, msg, logoutButton
            };

            for (const [name, element] of Object.entries(elements)) {
                if (!element) {
                    console.error(`錯誤: 找不到元素 ${name}`);
                    return;
                }
            }
            console.log('所有 DOM 元素載入成功');

            // --- 預先計算好的 SHA-256 HASH 值 ---
            // 正確帳號: ROOT2025 -> sha256 -> d7113846e19051e6d5752f60dcb53329e9563b2c7655452fb9aea5f27969cc4f
            const correctUserHash = 'd7113846e19051e6d5752f60dcb53329e9563b2c7655452fb9aea5f27969cc4f';
            // 正確密碼: 123456 -> sha256 -> 8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92
            const correctPassHash = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92';

            let currentCaptcha = '';

            // --- 功能函式 ---
            async function sha256(str) {
                try {
                    const textBuffer = new TextEncoder().encode(str);
                    const hashBuffer = await crypto.subtle.digest('SHA-256', textBuffer);
                    const hashArray = Array.from(new Uint8Array(hashBuffer));
                    const hash = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
                    console.log(`SHA256("${str}") = ${hash}`);
                    return hash;
                } catch (error) {
                    console.error('SHA256 計算錯誤:', error);
                    throw error;
                }
            }

            function generateCaptcha() {
                const chars = 'AbCdEfGhIjKlMnOpQrStUvWxYz0123456789';
                let captcha = '';
                for (let i = 0; i < 5; i++) {
                    captcha += chars.charAt(Math.floor(Math.random() * chars.length));
                }
                currentCaptcha = captcha;
                captchaDisplay.textContent = currentCaptcha;
                console.log('新驗證碼生成:', currentCaptcha);
            }

            function showMessage(message, isError = true) {
                msg.textContent = message;
                msg.className = isError ? 'msg error' : 'msg';
                console.log('顯示訊息:', message, '錯誤狀態:', isError);
            }

            async function handleLogin(e) {
                e.preventDefault();
                console.log('開始處理登入...');
                showMessage('', false);

                const username = usernameInput.value.trim();
                const password = passwordInput.value;
                const captcha = captchaInput.value.trim();

                console.log('輸入資訊:');
                console.log('- 帳號:', username);
                console.log('- 密碼長度:', password.length);
                console.log('- 驗證碼:', captcha);
                console.log('- 當前驗證碼:', currentCaptcha);

                // 步驟 1: 優先檢查驗證碼
                if (captcha.toLowerCase() !== currentCaptcha.toLowerCase()) {
                    console.log('驗證碼錯誤');
                    showMessage('❌ 驗證碼錯誤!請重新輸入。');
                    generateCaptcha();
                    captchaInput.value = '';
                    return;
                }

                try {
                    // 步驟 2: 雜湊使用者輸入
                    const enteredUserHash = await sha256(username.toUpperCase());
                    const enteredPassHash = await sha256(password);

                    console.log('Hash 比對:');
                    console.log('- 輸入帳號 Hash:', enteredUserHash);
                    console.log('- 正確帳號 Hash:', correctUserHash);
                    console.log('- 輸入密碼 Hash:', enteredPassHash);
                    console.log('- 正確密碼 Hash:', correctPassHash);

                    // 步驟 3: 比對 HASH 值
                    if (enteredUserHash === correctUserHash && enteredPassHash === correctPassHash) {
                        // 登入成功
                        console.log('登入成功!');
                        showMessage('✅ 登入成功!正在載入系統...', false);
                        loginSection.style.opacity = '0';
                        setTimeout(() => {
                            loginSection.classList.add('hidden');
                            mainAppSection.classList.remove('hidden');
                            mainAppSection.style.opacity = '1';
                            console.log('切換到主頁面完成');
                        }, 600);
                    } else {
                        // 登入失敗
                        console.log('帳號或密碼錯誤');
                        showMessage('❌ 帳號或密碼錯誤!');
                        generateCaptcha();
                        passwordInput.value = '';
                        captchaInput.value = '';
                    }
                } catch (error) {
                    console.error('登入處理錯誤:', error);
                    showMessage('❌ 系統錯誤,請重試!');
                }
            }

            function handleLogout() {
                console.log('處理登出...');
                mainAppSection.style.opacity = '0';
                setTimeout(() => {
                    mainAppSection.classList.add('hidden');
                    loginSection.classList.remove('hidden');
                    loginSection.style.opacity = '1';
                    loginForm.reset();
                    showMessage('');
                    generateCaptcha();
                    console.log('登出完成');
                }, 600);
            }

            // --- 事件監聽 ---
            loginForm.addEventListener('submit', handleLogin);
            logoutButton.addEventListener('click', handleLogout);
            captchaDisplay.addEventListener('click', generateCaptcha);

            // --- 初始化 ---
            console.log('開始初始化驗證碼...');
            generateCaptcha();
            console.log('系統初始化完成');

            // 測試用途:10秒後隱藏測試資訊
            setTimeout(() => {
                const testInfo = document.querySelector('.test-info');
                if (testInfo) {
                    testInfo.style.display = 'none';
                }
            }, 10000);
        });

        // --- 選單切換功能 ---
        function openTab(evt, tabName) {
            console.log('切換到頁籤:', tabName);

            // 隱藏所有內容
            var tabContents = document.getElementsByClassName("tab-content");
            for (var i = 0; i < tabContents.length; i++) {
                tabContents[i].classList.remove("active");
            }

            // 移除所有按鈕的 active 類別
            var tabButtons = document.getElementsByClassName("tab-button");
            for (var i = 0; i < tabButtons.length; i++) {
                tabButtons[i].classList.remove("active");
            }

            // 顯示選中的內容並激活按鈕
            document.getElementById(tabName).classList.add("active");
            evt.currentTarget.classList.add("active");

            console.log('頁籤切換完成:', tabName);
        }
    </script>

</body>

</html>