File size: 19,984 Bytes
9026b7c
 
 
 
 
c5edfec
9026b7c
5ff3aaa
9026b7c
5ff3aaa
 
 
 
 
c5edfec
 
 
 
06b6e54
 
c5edfec
 
06b6e54
 
 
 
 
c5edfec
 
 
 
 
 
5ff3aaa
 
c5edfec
 
 
9026b7c
 
c5edfec
 
 
 
 
 
9026b7c
c5edfec
 
9026b7c
 
c5edfec
 
 
9026b7c
 
c5edfec
 
 
 
06b6e54
 
c5edfec
 
 
9026b7c
 
c5edfec
 
 
 
 
06b6e54
 
c5edfec
06b6e54
c5edfec
 
 
 
 
 
 
 
06b6e54
 
c5edfec
 
 
9026b7c
 
c5edfec
 
9026b7c
 
c5edfec
06b6e54
 
c5edfec
 
06b6e54
 
c5edfec
 
 
 
 
 
 
 
 
5ff3aaa
06b6e54
 
c5edfec
 
5ff3aaa
 
c5edfec
 
9026b7c
c5edfec
 
 
 
 
5ff3aaa
 
c5edfec
 
5ff3aaa
 
c5edfec
06b6e54
c5edfec
 
 
 
 
 
 
 
 
 
06b6e54
 
c5edfec
 
 
06b6e54
 
c5edfec
 
 
 
 
06b6e54
 
c5edfec
 
 
 
 
06b6e54
 
c5edfec
 
5ff3aaa
3b6aa17
c5edfec
 
 
 
3b6aa17
c5edfec
3b6aa17
c5edfec
3b6aa17
 
c5edfec
 
3b6aa17
 
c5edfec
 
 
 
 
 
 
 
3b6aa17
 
c5edfec
 
3b6aa17
 
c5edfec
 
 
3b6aa17
 
c5edfec
 
 
 
 
3b6aa17
 
c5edfec
3b6aa17
 
c5edfec
 
 
 
 
 
 
 
3b6aa17
 
c5edfec
 
 
3b6aa17
 
c5edfec
 
 
 
3b6aa17
 
c5edfec
 
 
 
3b6aa17
 
c5edfec
 
3b6aa17
 
c5edfec
 
3b6aa17
 
c5edfec
3b6aa17
c5edfec
3b6aa17
c5edfec
 
3b6aa17
 
c5edfec
 
 
 
3b6aa17
 
c5edfec
 
 
3b6aa17
 
c5edfec
 
 
3b6aa17
 
c5edfec
 
 
 
 
3b6aa17
 
c5edfec
 
 
 
 
 
3b6aa17
 
c5edfec
 
 
3b6aa17
 
c5edfec
 
 
3b6aa17
c5edfec
3b6aa17
9026b7c
 
 
3b6aa17
 
 
c5edfec
 
 
 
 
 
 
 
 
 
3b6aa17
c5edfec
 
 
 
 
 
 
 
3b6aa17
c5edfec
3b6aa17
 
 
c5edfec
 
5ff3aaa
c5edfec
 
9026b7c
5ff3aaa
c5edfec
5ff3aaa
c5edfec
 
 
 
 
 
 
 
 
9026b7c
5ff3aaa
c5edfec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ff3aaa
 
 
c5edfec
 
 
 
 
 
 
 
 
 
 
 
5ff3aaa
 
507b93e
c5edfec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
507b93e
 
9026b7c
 
 
 
 
3b6aa17
 
 
 
c5edfec
3b6aa17
 
c5edfec
3b6aa17
 
c5edfec
 
 
 
3b6aa17
c5edfec
 
 
3b6aa17
c5edfec
 
 
3b6aa17
 
c5edfec
 
 
 
3b6aa17
 
 
17abbb1
c5edfec
17abbb1
 
3b6aa17
c5edfec
 
 
 
 
 
 
17abbb1
 
c5edfec
 
 
 
 
 
 
 
17abbb1
c5edfec
 
3b6aa17
 
 
 
c5edfec
 
 
 
 
 
 
9026b7c
5ff3aaa
c5edfec
 
 
 
 
 
 
 
 
 
 
 
 
5ff3aaa
 
c5edfec
 
 
 
 
 
 
 
 
 
 
 
17abbb1
c5edfec
 
17abbb1
 
c5edfec
 
 
 
 
5ff3aaa
9026b7c
 
c5edfec
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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<!DOCTYPE html>
<html lang="zh-TW">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PKM_RAG 系統</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Poppins', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            height: 100vh;
            overflow: hidden;
        }

        /* 登入頁面樣式 */
        .login-container {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: url("https://images.unsplash.com/photo-1503264116251-35a269479413") no-repeat center center/cover;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            transition: opacity 0.5s ease;
        }

        .login-container.hidden {
            opacity: 0;
            pointer-events: none;
        }

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

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

        .login-box h2 {
            color: white;
            margin-bottom: 30px;
            font-size: 28px;
        }

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

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

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

        .input-group input:focus {
            background: rgba(255, 255, 255, 0.3);
            box-shadow: 0 0 10px #00f2fe;
        }

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

        .captcha-container {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 20px;
        }

        .captcha-code {
            background: rgba(255, 255, 255, 0.2);
            color: white;
            padding: 10px 15px;
            border-radius: 8px;
            font-weight: bold;
            font-size: 18px;
            letter-spacing: 3px;
            user-select: none;
            flex: 1;
        }

        .captcha-input {
            flex: 1;
        }

        .refresh-captcha {
            background: rgba(255, 255, 255, 0.2);
            border: none;
            color: white;
            padding: 10px;
            border-radius: 8px;
            cursor: pointer;
            transition: 0.3s;
        }

        .refresh-captcha:hover {
            background: rgba(255, 255, 255, 0.3);
        }

        .login-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: 0.3s;
            margin-bottom: 15px;
        }

        .login-btn:hover {
            transform: scale(1.05);
            background: linear-gradient(135deg, #00f2fe, #4facfe);
        }

        .message {
            margin-top: 15px;
            font-size: 14px;
            font-weight: bold;
            min-height: 20px;
        }

        /* 主系統樣式 */
        .main-system {
            display: none;
            height: 100vh;
            background: #f5f5f5;
        }

        .main-system.active {
            display: block;
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 15px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .header h1 {
            font-size: 24px;
        }

        .logout-btn {
            background: rgba(255, 255, 255, 0.2);
            border: none;
            color: white;
            padding: 10px 20px;
            border-radius: 8px;
            cursor: pointer;
            transition: 0.3s;
        }

        .logout-btn:hover {
            background: rgba(255, 255, 255, 0.3);
        }

        .content-container {
            display: flex;
            height: calc(100vh - 70px);
        }

        .sidebar {
            width: 250px;
            background: white;
            box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
            padding: 20px 0;
        }

        .tab-button {
            width: 100%;
            padding: 15px 20px;
            border: none;
            background: none;
            text-align: left;
            cursor: pointer;
            transition: 0.3s;
            font-size: 16px;
            color: #666;
            border-left: 4px solid transparent;
        }

        .tab-button:hover {
            background: #f0f0f0;
            color: #333;
        }

        .tab-button.active {
            background: #e3f2fd;
            color: #1976d2;
            border-left-color: #1976d2;
        }

        .main-content {
            flex: 1;
            padding: 10px;
            overflow-y: auto;
        }

        .tab-content {
            display: none;
        }

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

        .iframe-container {
            width: 100%;
            height: calc(100vh - 120px);
            border: none;
            border-radius: 10px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        }

        .welcome-message {
            text-align: center;
            padding: 50px;
            color: #666;
        }

        .welcome-message h2 {
            margin-bottom: 20px;
            color: #333;
        }

        .welcome-message p {
            font-size: 16px;
            line-height: 1.6;
        }

        .iframe-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }

        .iframe-item {
            background: white;
            border-radius: 10px;
            padding: 10px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            height: calc(100vh - 150px);
        }

        .iframe-item h3 {
            margin-bottom: 10px;
            color: #333;
        }

        .iframe-item iframe {
            width: 100%;
            height: calc(100vh - 180px);
            border: none;
            border-radius: 8px;
        }
    </style>
</head>
<body>
    <!-- 登入頁面 -->
    <div class="login-container" id="loginContainer">
        <div class="login-box">
            <h2>PKM_RAG 系統登入</h2>
            
            <div class="input-group">
                <label for="username">使用者名稱</label>
                <input type="text" id="username" placeholder="請輸入使用者名稱">
            </div>

            <div class="input-group">
                <label for="password">密碼</label>
                <input type="password" id="password" placeholder="請輸入密碼">
            </div>

            <div class="captcha-container">
                <div class="captcha-code" id="captchaCode"></div>
                <input type="text" class="captcha-input" id="captchaInput" placeholder="驗證碼">
                <button class="refresh-captcha" onclick="generateCaptcha()">🔄</button>
            </div>

            <button class="login-btn" onclick="login()">登入系統</button>
            
            <div class="message" id="message"></div>
        </div>
    </div>

    <!-- 主系統 -->
    <div class="main-system" id="mainSystem">
        <div class="header">
            <h1>PKM_RAG 知識管理系統</h1>
            <button class="logout-btn" onclick="logout()">回到登入頁面</button>
        </div>

        <div class="content-container">
            <div class="sidebar">
                <button class="tab-button active" onclick="showTab('welcome')">🏠 系統首頁</button>
                <button class="tab-button" onclick="showTab('chatbot')">🤖 PDF 聊天機器人</button>
                <button class="tab-button" onclick="showTab('longchain')">🔗 LongChain Resend</button>
                <button class="tab-button" onclick="showTab('groq')">⚡ Groq API</button>
                <button class="tab-button" onclick="showTab('webcam')">📹 Webcam Groq</button>
                <button class="tab-button" onclick="showTab('analysis')">📊 多圖分析</button>
                <button class="tab-button" onclick="showTab('twilio')">📱 Twilio 訊息</button>
                <button class="tab-button" onclick="showTab('settings')">⚙️ 系統設定</button>
                <button class="tab-button" onclick="showTab('help')">❓ 使用說明</button>
            </div>

            <div class="main-content">
                <div class="tab-content active" id="welcome">
                    <div class="welcome-message">
                        <h2>歡迎使用 PKM_RAG 系統</h2>
                        <p>這是一個整合的知識管理和問答系統,提供以下功能:</p>
                        <br>
                        <p>📄 <strong>PDF 文件處理</strong> - 上傳並分析 PDF 文件內容</p>
                        <p>💬 <strong>智能問答</strong> - 基於文件內容進行問答對話</p>
                        <p>📧 <strong>郵件分享</strong> - 將問答記錄發送郵件</p>
                        <p>🔗 <strong>LongChain 整合</strong> - 鏈式處理和 Resend 郵件服務</p>
                        <p><strong>Groq API</strong> - 高速 AI 推理服務</p>
                        <p>📹 <strong>Webcam 功能</strong> - 即時影像處理</p>
                        <p>📊 <strong>多圖分析</strong> - 批量圖像分析處理</p>
                        <p>📱 <strong>Twilio 訊息</strong> - 簡訊發送服務</p>
                        <br>
                        <p>請點擊左側選單開始使用各項功能。</p>
                    </div>
                </div>

                <div class="tab-content" id="chatbot">
                    <iframe 
                        src="http://127.0.0.1:7860" 
                        class="iframe-container"
                        frameborder="0">
                    </iframe>
                </div>

                <div class="tab-content" id="longchain">
                    <div class="iframe-item">
                        <h3>LongChain Resend 服務</h3>
                        <iframe src="https://mikao007-longchain-resend.hf.space" frameborder="0"></iframe>
                    </div>
                </div>

                <div class="tab-content" id="groq">
                    <div class="iframe-item">
                        <h3>Groq API Gradio 服務</h3>
                        <iframe src="https://mikao007-groq-api-gradio.hf.space" frameborder="0"></iframe>
                    </div>
                </div>

                <div class="tab-content" id="webcam">
                    <div class="iframe-item">
                        <h3>Webcam Groq LineBot 服務</h3>
                        <iframe src="https://mikao007-webcam-groq-linebot.hf.space" frameborder="0"></iframe>
                    </div>
                </div>

                <div class="tab-content" id="analysis">
                    <div class="iframe-item">
                        <h3>多圖分析服務</h3>
                        <iframe src="https://mikao007-anliz-muti-pic.hf.space" frameborder="0"></iframe>
                    </div>
                </div>

                <div class="tab-content" id="twilio">
                    <div class="iframe-item">
                        <h3>Twilio 訊息發送服務</h3>
                        <iframe src="https://mikao007-twilio-messagesend.hf.space" frameborder="0"></iframe>
                    </div>
                </div>

                <div class="tab-content" id="settings">
                    <div class="welcome-message">
                        <h2>系統設定</h2>
                        <p>這裡可以進行系統相關的設定調整。</p>
                        <br>
                        <p>🔧 <strong>API 設定</strong> - 配置 Google Gemini 和 Resend API</p>
                        <p>📁 <strong>文件管理</strong> - 管理已上傳的文件</p>
                        <p>🎨 <strong>界面設定</strong> - 自訂系統外觀</p>
                        <p>🔒 <strong>安全設定</strong> - 修改登入密碼</p>
                        <br>
                        <h3>📋 系統資訊</h3>
                        <p>• 系統版本:PKM_RAG v1.0</p>
                        <p>• 支援格式:PDF, DOCX, TXT</p>
                        <p>• AI 模型:Gemini 2.0 Flash</p>
                        <p>• 郵件服務:Resend</p>
                    </div>
                </div>

                <div class="tab-content" id="help">
                    <div class="welcome-message">
                        <h2>使用說明</h2>
                        <p>PKM_RAG 系統使用指南:</p>
                        <br>
                        <h3>📋 基本操作流程</h3>
                        <p>1. 點擊「PDF 聊天機器人」進入主要功能</p>
                        <p>2. 上傳您的 PDF 文件進行處理</p>
                        <p>3. 開始與文件內容進行問答對話</p>
                        <p>4. 可將問答記錄下載或發送郵件</p>
                        <br>
                        <h3>🔗 整合服務</h3>
                        <p><strong>LongChain Resend</strong> - 鏈式處理和郵件服務</p>
                        <p><strong>Groq API</strong> - 高速 AI 推理</p>
                        <p><strong>Webcam Groq</strong> - 即時影像處理</p>
                        <p><strong>多圖分析</strong> - 批量圖像分析</p>
                        <p><strong>Twilio 訊息</strong> - 簡訊發送</p>
                        <br>
                        <h3>💡 使用技巧</h3>
                        <p>• 支援多個 PDF 文件同時處理</p>
                        <p>• 問答支援中文和英文</p>
                        <p>• 可下載 DOCX 格式的問答記錄</p>
                        <p>• 郵件發送支援 HTML 格式</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 生成驗證碼
        function generateCaptcha() {
            const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
            let result = '';
            for (let i = 0; i < 6; i++) {
                result += chars.charAt(Math.floor(Math.random() * chars.length));
            }
            document.getElementById('captchaCode').textContent = result;
        }

        // 頁面載入時生成驗證碼
        window.onload = function() {
            generateCaptcha();
        };

        // 登入功能
        async function login() {
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            const captchaInput = document.getElementById('captchaInput').value;
            const captchaCode = document.getElementById('captchaCode').textContent;
            const message = document.getElementById('message');

            // 驗證驗證碼
            if (captchaInput.toUpperCase() !== captchaCode) {
                message.style.color = 'red';
                message.textContent = '❌ 驗證碼錯誤!';
                generateCaptcha();
                return;
            }

            try {
                // 使用 HASH 驗證帳號密碼
                const usernameHash = await sha256(username);
                const passwordHash = await sha256(password);
                
                // 預設帳號密碼的 HASH 值
                const correctUsernameHash = 'd7113846e19051e6d5752f60dcb53329e9563b2c7655452fb9aea5f27969cc4f'; // "ROOT2025" 的 SHA-256
                const correctPasswordHash = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92'; // "123456" 的 SHA-256

                if (usernameHash === correctUsernameHash && passwordHash === correctPasswordHash) {
                    message.style.color = 'lightgreen';
                    message.textContent = '✅ 登入成功!正在進入系統...';
                    
                    setTimeout(() => {
                        document.getElementById('loginContainer').classList.add('hidden');
                        document.getElementById('mainSystem').classList.add('active');
                    }, 1000);
                } else {
                    message.style.color = 'red';
                    message.textContent = '❌ 使用者名稱或密碼錯誤!';
                    generateCaptcha();
                }
            } catch (error) {
                message.style.color = 'red';
                message.textContent = '❌ 登入驗證時發生錯誤!';
                generateCaptcha();
            }
        }

        // SHA-256 雜湊函數
        async function sha256(message) {
            const msgBuffer = new TextEncoder().encode(message);
            const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
            const hashArray = Array.from(new Uint8Array(hashBuffer));
            const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
            return hashHex;
        }

        // 登出功能
        function logout() {
            document.getElementById('mainSystem').classList.remove('active');
            document.getElementById('loginContainer').classList.remove('hidden');
            
            // 清空輸入欄位
            document.getElementById('username').value = '';
            document.getElementById('password').value = '';
            document.getElementById('captchaInput').value = '';
            document.getElementById('message').textContent = '';
            
            // 重新生成驗證碼
            generateCaptcha();
        }

        // 頁籤切換功能
        function showTab(tabName) {
            // 隱藏所有頁籤內容
            const tabContents = document.querySelectorAll('.tab-content');
            tabContents.forEach(content => content.classList.remove('active'));
            
            // 移除所有按鈕的 active 狀態
            const tabButtons = document.querySelectorAll('.tab-button');
            tabButtons.forEach(button => button.classList.remove('active'));
            
            // 顯示選中的頁籤內容
            document.getElementById(tabName).classList.add('active');
            
            // 設定對應按鈕為 active
            event.target.classList.add('active');
        }

        // Enter 鍵登入
        document.addEventListener('keypress', function(e) {
            if (e.key === 'Enter') {
                login();
            }
        });
    </script>
</body>
</html>