raineye commited on
Commit
c4fe9cb
·
verified ·
1 Parent(s): ef9f8f9

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +558 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Ds
3
- emoji: 🔥
4
- colorFrom: green
5
- colorTo: green
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: ds
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: pink
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,558 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>DeepSeek Chat</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ /* 自定义滚动条 */
11
+ ::-webkit-scrollbar {
12
+ width: 6px;
13
+ }
14
+ ::-webkit-scrollbar-track {
15
+ background: #1a1a1a;
16
+ }
17
+ ::-webkit-scrollbar-thumb {
18
+ background: #4b5563;
19
+ border-radius: 3px;
20
+ }
21
+ ::-webkit-scrollbar-thumb:hover {
22
+ background: #6b7280;
23
+ }
24
+
25
+ /* 打字动画 */
26
+ @keyframes typing {
27
+ from { width: 0 }
28
+ to { width: 100% }
29
+ }
30
+
31
+ .typing-animation {
32
+ overflow: hidden;
33
+ white-space: nowrap;
34
+ animation: typing 1s steps(40, end);
35
+ }
36
+
37
+ /* 消息气泡动画 */
38
+ @keyframes fadeIn {
39
+ from { opacity: 0; transform: translateY(10px); }
40
+ to { opacity: 1; transform: translateY(0); }
41
+ }
42
+
43
+ .message-fade-in {
44
+ animation: fadeIn 0.3s ease-out forwards;
45
+ }
46
+
47
+ /* 输入框聚焦效果 */
48
+ .input-focus-effect:focus {
49
+ box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
50
+ }
51
+
52
+ /* 语音录制动画 */
53
+ @keyframes pulse {
54
+ 0% { opacity: 1; }
55
+ 50% { opacity: 0.5; }
56
+ 100% { opacity: 1; }
57
+ }
58
+
59
+ .recording-animation {
60
+ animation: pulse 1.5s infinite;
61
+ }
62
+ </style>
63
+ </head>
64
+ <body class="bg-gray-900 text-gray-100 h-screen flex flex-col overflow-hidden">
65
+ <!-- 顶部导航栏 -->
66
+ <header class="bg-gray-800 border-b border-gray-700 py-3 px-4 flex items-center justify-between">
67
+ <div class="flex items-center space-x-2">
68
+ <div class="w-8 h-8 bg-blue-600 rounded-full flex items-center justify-center">
69
+ <i class="fas fa-robot text-white"></i>
70
+ </div>
71
+ <h1 class="text-xl font-bold text-white">DeepSeek Chat</h1>
72
+ </div>
73
+ <div class="flex items-center space-x-4">
74
+ <button id="theme-toggle" class="text-gray-400 hover:text-white transition-colors">
75
+ <i class="fas fa-moon"></i>
76
+ </button>
77
+ <button class="text-gray-400 hover:text-white transition-colors">
78
+ <i class="fas fa-cog"></i>
79
+ </button>
80
+ <button class="text-gray-400 hover:text-white transition-colors">
81
+ <i class="fas fa-user"></i>
82
+ </button>
83
+ </div>
84
+ </header>
85
+
86
+ <!-- 主聊天区域 -->
87
+ <main class="flex-1 overflow-y-auto p-4 space-y-6" id="chat-container">
88
+ <!-- 欢迎消息 -->
89
+ <div class="max-w-3xl mx-auto message-fade-in">
90
+ <div class="flex space-x-3">
91
+ <div class="flex-shrink-0">
92
+ <div class="w-8 h-8 bg-blue-600 rounded-full flex items-center justify-center">
93
+ <i class="fas fa-robot text-white"></i>
94
+ </div>
95
+ </div>
96
+ <div class="flex-1 min-w-0">
97
+ <div class="bg-gray-800 rounded-lg p-4">
98
+ <p class="text-white font-medium">DeepSeek Chat</p>
99
+ <div class="mt-2 text-gray-300">
100
+ <p>你好!我是DeepSeek Chat,一个强大的AI助手。我可以帮助你解答问题、提供建议、分析数据等等。</p>
101
+ <p class="mt-2">你可以问我任何问题,我会尽力提供最准确和有用的回答。</p>
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </div>
106
+ </div>
107
+
108
+ <!-- 示例问题 -->
109
+ <div class="max-w-3xl mx-auto grid grid-cols-1 md:grid-cols-2 gap-3">
110
+ <button class="bg-gray-800 hover:bg-gray-700 rounded-lg p-3 text-left transition-colors message-fade-in" onclick="insertExample(this)">
111
+ <p class="text-sm text-gray-400">示例问题</p>
112
+ <p class="mt-1 text-white">如何提高我的Python编程技能?</p>
113
+ </button>
114
+ <button class="bg-gray-800 hover:bg-gray-700 rounded-lg p-3 text-left transition-colors message-fade-in" onclick="insertExample(this)">
115
+ <p class="text-sm text-gray-400">示例问题</p>
116
+ <p class="mt-1 text-white">解释量子计算的基本概念</p>
117
+ </button>
118
+ <button class="bg-gray-800 hover:bg-gray-700 rounded-lg p-3 text-left transition-colors message-fade-in" onclick="insertExample(this)">
119
+ <p class="text-sm text-gray-400">示例问题</p>
120
+ <p class="mt-1 text-white">写一封专业的求职信</p>
121
+ </button>
122
+ <button class="bg-gray-800 hover:bg-gray-700 rounded-lg p-3 text-left transition-colors message-fade-in" onclick="insertExample(this)">
123
+ <p class="text-sm text-gray-400">示例问题</p>
124
+ <p class="mt-1 text-white">如何制定一个有效的学习计划?</p>
125
+ </button>
126
+ </div>
127
+ </main>
128
+
129
+ <!-- 输入区域 -->
130
+ <div class="bg-gray-800 border-t border-gray-700 p-4">
131
+ <div class="max-w-3xl mx-auto">
132
+ <form id="chat-form" class="relative">
133
+ <div class="flex items-end space-x-2">
134
+ <div class="flex-1 relative">
135
+ <textarea
136
+ id="message-input"
137
+ rows="1"
138
+ class="w-full bg-gray-700 border border-gray-600 rounded-lg py-3 px-4 pr-12 text-white placeholder-gray-400 focus:outline-none input-focus-effect resize-none"
139
+ placeholder="输入消息..."
140
+ oninput="autoResize(this)"
141
+ ></textarea>
142
+ <div class="absolute right-2 bottom-2 flex space-x-1">
143
+ <button type="button" id="attach-button" class="text-gray-400 hover:text-white p-1 rounded-full transition-colors">
144
+ <i class="fas fa-paperclip"></i>
145
+ </button>
146
+ <button type="button" id="voice-button" class="text-gray-400 hover:text-white p-1 rounded-full transition-colors">
147
+ <i class="fas fa-microphone"></i>
148
+ </button>
149
+ </div>
150
+ </div>
151
+ <button
152
+ type="submit"
153
+ id="send-button"
154
+ class="bg-blue-600 hover:bg-blue-700 text-white rounded-lg p-3 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
155
+ disabled
156
+ >
157
+ <i class="fas fa-paper-plane"></i>
158
+ </button>
159
+ </div>
160
+ </form>
161
+ <p class="text-xs text-gray-500 mt-2 text-center">DeepSeek Chat 可能会产生不准确的信息,请验证重要信息。</p>
162
+ </div>
163
+ </div>
164
+
165
+ <!-- 文件选择模态框 -->
166
+ <div id="file-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
167
+ <div class="bg-gray-800 rounded-lg p-6 w-full max-w-md">
168
+ <div class="flex justify-between items-center mb-4">
169
+ <h3 class="text-lg font-medium text-white">选择文件</h3>
170
+ <button id="close-file-modal" class="text-gray-400 hover:text-white">
171
+ <i class="fas fa-times"></i>
172
+ </button>
173
+ </div>
174
+ <div class="border-2 border-dashed border-gray-600 rounded-lg p-8 text-center mb-4">
175
+ <i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-3"></i>
176
+ <p class="text-gray-300 mb-2">拖放文件到这里或点击选择</p>
177
+ <input type="file" id="file-input" class="hidden" multiple>
178
+ <button id="select-file-button" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg">
179
+ 选择文件
180
+ </button>
181
+ </div>
182
+ <div id="selected-files" class="hidden">
183
+ <p class="text-gray-300 mb-2">已选择文件:</p>
184
+ <ul id="file-list" class="text-gray-400 text-sm"></ul>
185
+ </div>
186
+ <div class="flex justify-end space-x-3 mt-4">
187
+ <button id="cancel-upload" class="px-4 py-2 rounded-lg border border-gray-600 text-gray-300 hover:bg-gray-700">
188
+ 取消
189
+ </button>
190
+ <button id="confirm-upload" class="px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700">
191
+ 上传
192
+ </button>
193
+ </div>
194
+ </div>
195
+ </div>
196
+
197
+ <!-- 语音录制模态框 -->
198
+ <div id="voice-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
199
+ <div class="bg-gray-800 rounded-lg p-6 w-full max-w-md">
200
+ <div class="flex justify-between items-center mb-4">
201
+ <h3 class="text-lg font-medium text-white">语音输入</h3>
202
+ <button id="close-voice-modal" class="text-gray-400 hover:text-white">
203
+ <i class="fas fa-times"></i>
204
+ </button>
205
+ </div>
206
+ <div class="text-center mb-6">
207
+ <div class="w-20 h-20 bg-gray-700 rounded-full flex items-center justify-center mx-auto mb-4">
208
+ <i id="voice-icon" class="fas fa-microphone text-3xl text-blue-500"></i>
209
+ </div>
210
+ <p id="voice-status" class="text-gray-300">点击下方按钮开始录音</p>
211
+ <div class="mt-2 flex justify-center space-x-4">
212
+ <div class="w-2 h-2 bg-gray-500 rounded-full"></div>
213
+ <div class="w-2 h-2 bg-gray-500 rounded-full"></div>
214
+ <div class="w-2 h-2 bg-gray-500 rounded-full"></div>
215
+ </div>
216
+ </div>
217
+ <div class="flex justify-center">
218
+ <button id="start-recording" class="px-6 py-3 rounded-full bg-red-600 text-white hover:bg-red-700 flex items-center">
219
+ <i class="fas fa-microphone mr-2"></i>
220
+ <span>开始录音</span>
221
+ </button>
222
+ <button id="stop-recording" class="px-6 py-3 rounded-full bg-gray-700 text-white hover:bg-gray-600 flex items-center hidden">
223
+ <i class="fas fa-stop mr-2"></i>
224
+ <span>停止</span>
225
+ </button>
226
+ </div>
227
+ <div id="recording-timer" class="text-center mt-4 text-gray-400 hidden">
228
+ <i class="fas fa-circle text-red-500 mr-2 recording-animation"></i>
229
+ <span>00:00</span>
230
+ </div>
231
+ </div>
232
+ </div>
233
+
234
+ <script>
235
+ // 自动调整输入框高度
236
+ function autoResize(textarea) {
237
+ textarea.style.height = 'auto';
238
+ textarea.style.height = textarea.scrollHeight + 'px';
239
+
240
+ // 启用/禁用发送按钮
241
+ document.getElementById('send-button').disabled = textarea.value.trim() === '';
242
+ }
243
+
244
+ // 插入示例问题
245
+ function insertExample(button) {
246
+ const question = button.querySelector('p:not(.text-sm)').textContent;
247
+ const input = document.getElementById('message-input');
248
+ input.value = question;
249
+ autoResize(input);
250
+ input.focus();
251
+ }
252
+
253
+ // 处理表单提交
254
+ document.getElementById('chat-form').addEventListener('submit', function(e) {
255
+ e.preventDefault();
256
+ const input = document.getElementById('message-input');
257
+ const message = input.value.trim();
258
+
259
+ if (message) {
260
+ sendMessage(message);
261
+ input.value = '';
262
+ autoResize(input);
263
+ }
264
+ });
265
+
266
+ // 发送消息
267
+ function sendMessage(message) {
268
+ const chatContainer = document.getElementById('chat-container');
269
+
270
+ // 添加用户消息
271
+ const userMessageDiv = document.createElement('div');
272
+ userMessageDiv.className = 'max-w-3xl mx-auto message-fade-in';
273
+ userMessageDiv.innerHTML = `
274
+ <div class="flex space-x-3 justify-end">
275
+ <div class="flex-1 min-w-0 flex justify-end">
276
+ <div class="bg-blue-600 rounded-lg p-4 max-w-[80%]">
277
+ <p class="text-white">${message}</p>
278
+ </div>
279
+ </div>
280
+ <div class="flex-shrink-0">
281
+ <div class="w-8 h-8 bg-gray-700 rounded-full flex items-center justify-center">
282
+ <i class="fas fa-user text-gray-300"></i>
283
+ </div>
284
+ </div>
285
+ </div>
286
+ `;
287
+ chatContainer.appendChild(userMessageDiv);
288
+
289
+ // 滚动到底部
290
+ chatContainer.scrollTop = chatContainer.scrollHeight;
291
+
292
+ // 显示AI正在输入
293
+ const aiTypingDiv = document.createElement('div');
294
+ aiTypingDiv.className = 'max-w-3xl mx-auto message-fade-in';
295
+ aiTypingDiv.innerHTML = `
296
+ <div class="flex space-x-3">
297
+ <div class="flex-shrink-0">
298
+ <div class="w-8 h-8 bg-blue-600 rounded-full flex items-center justify-center">
299
+ <i class="fas fa-robot text-white"></i>
300
+ </div>
301
+ </div>
302
+ <div class="flex-1 min-w-0">
303
+ <div class="bg-gray-800 rounded-lg p-4">
304
+ <div class="flex space-x-2 items-center">
305
+ <div class="w-2 h-2 bg-gray-500 rounded-full animate-bounce" style="animation-delay: 0s"></div>
306
+ <div class="w-2 h-2 bg-gray-500 rounded-full animate-bounce" style="animation-delay: 0.2s"></div>
307
+ <div class="w-2 h-2 bg-gray-500 rounded-full animate-bounce" style="animation-delay: 0.4s"></div>
308
+ </div>
309
+ </div>
310
+ </div>
311
+ </div>
312
+ `;
313
+ chatContainer.appendChild(aiTypingDiv);
314
+ chatContainer.scrollTop = chatContainer.scrollHeight;
315
+
316
+ // 模拟AI回复(实际应用中这里应该是API调用)
317
+ setTimeout(() => {
318
+ // 移除"正在输入"状态
319
+ chatContainer.removeChild(aiTypingDiv);
320
+
321
+ // 添加AI回复
322
+ const aiResponseDiv = document.createElement('div');
323
+ aiResponseDiv.className = 'max-w-3xl mx-auto message-fade-in';
324
+
325
+ // 模拟不同类型的回复
326
+ const responses = [
327
+ `我理解你想了解"${message}"。这是一个很好的问题。让我为你详细解释...`,
328
+ `关于"${message}",有几个关键点需要考虑...`,
329
+ `"${message}"是一个复杂的话题。简而言之...`,
330
+ `我可以从几个角度回答"${message}"这个问题...`
331
+ ];
332
+
333
+ const randomResponse = responses[Math.floor(Math.random() * responses.length)];
334
+
335
+ aiResponseDiv.innerHTML = `
336
+ <div class="flex space-x-3">
337
+ <div class="flex-shrink-0">
338
+ <div class="w-8 h-8 bg-blue-600 rounded-full flex items-center justify-center">
339
+ <i class="fas fa-robot text-white"></i>
340
+ </div>
341
+ </div>
342
+ <div class="flex-1 min-w-0">
343
+ <div class="bg-gray-800 rounded-lg p-4">
344
+ <p class="text-white font-medium">DeepSeek Chat</p>
345
+ <div class="mt-2 text-gray-300">
346
+ <p>${randomResponse}</p>
347
+ <p class="mt-2">如果你需要更详细的信息或有其他问题,请随时告诉我。</p>
348
+ </div>
349
+ </div>
350
+ </div>
351
+ </div>
352
+ `;
353
+
354
+ chatContainer.appendChild(aiResponseDiv);
355
+ chatContainer.scrollTop = chatContainer.scrollHeight;
356
+ }, 1500);
357
+ }
358
+
359
+ // 主题切换
360
+ document.getElementById('theme-toggle').addEventListener('click', function() {
361
+ const html = document.documentElement;
362
+ const isDark = html.classList.contains('dark');
363
+
364
+ if (isDark) {
365
+ html.classList.remove('dark');
366
+ html.classList.add('light');
367
+ this.innerHTML = '<i class="fas fa-sun"></i>';
368
+ document.body.className = 'bg-gray-100 text-gray-900 h-screen flex flex-col overflow-hidden';
369
+ } else {
370
+ html.classList.remove('light');
371
+ html.classList.add('dark');
372
+ this.innerHTML = '<i class="fas fa-moon"></i>';
373
+ document.body.className = 'bg-gray-900 text-gray-100 h-screen flex flex-col overflow-hidden';
374
+ }
375
+ });
376
+
377
+ // 文件上传功能
378
+ const fileModal = document.getElementById('file-modal');
379
+ const attachButton = document.getElementById('attach-button');
380
+ const closeFileModal = document.getElementById('close-file-modal');
381
+ const selectFileButton = document.getElementById('select-file-button');
382
+ const fileInput = document.getElementById('file-input');
383
+ const cancelUpload = document.getElementById('cancel-upload');
384
+ const confirmUpload = document.getElementById('confirm-upload');
385
+ const selectedFiles = document.getElementById('selected-files');
386
+ const fileList = document.getElementById('file-list');
387
+
388
+ attachButton.addEventListener('click', () => {
389
+ fileModal.classList.remove('hidden');
390
+ });
391
+
392
+ closeFileModal.addEventListener('click', () => {
393
+ fileModal.classList.add('hidden');
394
+ });
395
+
396
+ selectFileButton.addEventListener('click', () => {
397
+ fileInput.click();
398
+ });
399
+
400
+ fileInput.addEventListener('change', (e) => {
401
+ if (e.target.files.length > 0) {
402
+ fileList.innerHTML = '';
403
+ for (let i = 0; i < e.target.files.length; i++) {
404
+ const file = e.target.files[i];
405
+ const listItem = document.createElement('li');
406
+ listItem.textContent = `${file.name} (${formatFileSize(file.size)})`;
407
+ fileList.appendChild(listItem);
408
+ }
409
+ selectedFiles.classList.remove('hidden');
410
+ }
411
+ });
412
+
413
+ cancelUpload.addEventListener('click', () => {
414
+ fileInput.value = '';
415
+ selectedFiles.classList.add('hidden');
416
+ fileModal.classList.add('hidden');
417
+ });
418
+
419
+ confirmUpload.addEventListener('click', () => {
420
+ if (fileInput.files.length > 0) {
421
+ // 这里应该是实际上传文件的代码
422
+ alert(`${fileInput.files.length}个文件已选择,准备上传`);
423
+ fileModal.classList.add('hidden');
424
+
425
+ // 模拟上传成功后在聊天中显示
426
+ setTimeout(() => {
427
+ const chatContainer = document.getElementById('chat-container');
428
+ const fileMessageDiv = document.createElement('div');
429
+ fileMessageDiv.className = 'max-w-3xl mx-auto message-fade-in';
430
+
431
+ let filesHtml = '';
432
+ for (let i = 0; i < fileInput.files.length; i++) {
433
+ const file = fileInput.files[i];
434
+ filesHtml += `
435
+ <div class="flex items-center bg-gray-700 rounded-lg p-2 mt-2">
436
+ <i class="fas fa-file-alt text-gray-400 mr-2"></i>
437
+ <span class="text-gray-300 text-sm">${file.name}</span>
438
+ <span class="text-gray-500 text-xs ml-auto">${formatFileSize(file.size)}</span>
439
+ </div>
440
+ `;
441
+ }
442
+
443
+ fileMessageDiv.innerHTML = `
444
+ <div class="flex space-x-3 justify-end">
445
+ <div class="flex-1 min-w-0 flex justify-end">
446
+ <div class="bg-blue-600 rounded-lg p-4 max-w-[80%]">
447
+ <p class="text-white">已上传文件:</p>
448
+ ${filesHtml}
449
+ </div>
450
+ </div>
451
+ <div class="flex-shrink-0">
452
+ <div class="w-8 h-8 bg-gray-700 rounded-full flex items-center justify-center">
453
+ <i class="fas fa-user text-gray-300"></i>
454
+ </div>
455
+ </div>
456
+ </div>
457
+ `;
458
+
459
+ chatContainer.appendChild(fileMessageDiv);
460
+ chatContainer.scrollTop = chatContainer.scrollHeight;
461
+
462
+ // 清空文件选择
463
+ fileInput.value = '';
464
+ selectedFiles.classList.add('hidden');
465
+ }, 500);
466
+ } else {
467
+ alert('请先选择文件');
468
+ }
469
+ });
470
+
471
+ // 语音输入功能
472
+ const voiceModal = document.getElementById('voice-modal');
473
+ const voiceButton = document.getElementById('voice-button');
474
+ const closeVoiceModal = document.getElementById('close-voice-modal');
475
+ const startRecording = document.getElementById('start-recording');
476
+ const stopRecording = document.getElementById('stop-recording');
477
+ const voiceStatus = document.getElementById('voice-status');
478
+ const voiceIcon = document.getElementById('voice-icon');
479
+ const recordingTimer = document.getElementById('recording-timer');
480
+
481
+ let isRecording = false;
482
+ let seconds = 0;
483
+ let timerInterval;
484
+
485
+ voiceButton.addEventListener('click', () => {
486
+ voiceModal.classList.remove('hidden');
487
+ });
488
+
489
+ closeVoiceModal.addEventListener('click', () => {
490
+ voiceModal.classList.add('hidden');
491
+ stopRecordingFunc();
492
+ });
493
+
494
+ startRecording.addEventListener('click', () => {
495
+ isRecording = true;
496
+ startRecording.classList.add('hidden');
497
+ stopRecording.classList.remove('hidden');
498
+ voiceStatus.textContent = '正在录音...';
499
+ voiceIcon.className = 'fas fa-microphone-alt text-3xl text-red-500';
500
+ recordingTimer.classList.remove('hidden');
501
+
502
+ // 开始计时
503
+ seconds = 0;
504
+ updateTimer();
505
+ timerInterval = setInterval(updateTimer, 1000);
506
+
507
+ // 这里应该是实际开始录音的代码
508
+ console.log('录音开始');
509
+ });
510
+
511
+ stopRecording.addEventListener('click', stopRecordingFunc);
512
+
513
+ function stopRecordingFunc() {
514
+ if (!isRecording) return;
515
+
516
+ isRecording = false;
517
+ startRecording.classList.remove('hidden');
518
+ stopRecording.classList.add('hidden');
519
+ voiceStatus.textContent = '录音已停止';
520
+ voiceIcon.className = 'fas fa-microphone text-3xl text-blue-500';
521
+ clearInterval(timerInterval);
522
+
523
+ // 这里应该是实际停止录音的代码
524
+ console.log('录音停止');
525
+
526
+ // 模拟语音识别结果
527
+ setTimeout(() => {
528
+ const recognizedText = "这是模拟的语音识别结果。实际应用中这里应该是从语音识别API返回的文本。";
529
+ document.getElementById('message-input').value = recognizedText;
530
+ autoResize(document.getElementById('message-input'));
531
+ voiceModal.classList.add('hidden');
532
+ }, 1000);
533
+ }
534
+
535
+ function updateTimer() {
536
+ seconds++;
537
+ const minutes = Math.floor(seconds / 60);
538
+ const remainingSeconds = seconds % 60;
539
+ recordingTimer.querySelector('span').textContent =
540
+ `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
541
+ }
542
+
543
+ // 辅助函数:格式化文件大小
544
+ function formatFileSize(bytes) {
545
+ if (bytes === 0) return '0 Bytes';
546
+ const k = 1024;
547
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
548
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
549
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
550
+ }
551
+
552
+ // 初始化时自动调整输入框高度
553
+ document.addEventListener('DOMContentLoaded', () => {
554
+ autoResize(document.getElementById('message-input'));
555
+ });
556
+ </script>
557
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=raineye/ds" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
558
+ </html>