|
218 | 218 | padding: 20px; |
219 | 219 | background-color: var(--bg-tertiary); |
220 | 220 | } |
| 221 | + .sidebar-header { |
| 222 | + display: flex; |
| 223 | + gap: 8px; |
| 224 | + margin-bottom: 15px; |
| 225 | + align-items: center; |
| 226 | + } |
| 227 | + #search-input { |
| 228 | + flex: 1; |
| 229 | + height: 18px; |
| 230 | + padding: 8px; |
| 231 | + border: 1px solid var(--border-color); |
| 232 | + border-radius: 8px; |
| 233 | + background-color: var(--bg-quaternary); |
| 234 | + color: var(--text-primary); |
| 235 | + font-size: 14px; |
| 236 | + transition: all 0.2s ease; |
| 237 | + } |
| 238 | + #search-input:focus { |
| 239 | + outline: none; |
| 240 | + border-color: var(--border-hover); |
| 241 | + } |
| 242 | + #search-input::placeholder { |
| 243 | + color: var(--text-primary); |
| 244 | + opacity: 0.6; |
| 245 | + } |
221 | 246 | .sidebar ul { |
222 | 247 | list-style-type: none; |
223 | 248 | padding: 0; |
|
467 | 492 | width: 36px; |
468 | 493 | height: 36px; |
469 | 494 | padding: 8px; |
470 | | - margin-bottom: 15px; |
471 | | - border: 1px solid #e0e0e0; |
472 | | - background-color: #f7f9fc; |
| 495 | + border: 1px solid var(--border-color); |
| 496 | + background-color: var(--button-bg); |
473 | 497 | border-radius: 8px; |
474 | | - color: #666; |
| 498 | + color: var(--text-primary); |
475 | 499 | cursor: pointer; |
476 | 500 | transition: all 0.2s ease; |
477 | 501 | display: flex; |
478 | 502 | align-items: center; |
479 | 503 | justify-content: center; |
480 | 504 | font-size: 18px; |
| 505 | + flex-shrink: 0; |
481 | 506 | } |
482 | 507 | #new-chat-button:hover { |
483 | 508 | background-color: #fff; |
|
592 | 617 | </div> |
593 | 618 | <div class="container"> |
594 | 619 | <div class="sidebar" id="history-bar"> |
595 | | - <button id="new-chat-button">➕</button> |
| 620 | + <div class="sidebar-header"> |
| 621 | + <button id="new-chat-button">➕</button> |
| 622 | + <input type="text" id="search-input" placeholder="Search chats..."> |
| 623 | + </div> |
596 | 624 | <ul id="history-list"> |
597 | 625 | <!-- History records will be listed here --> |
598 | 626 | </ul> |
|
1350 | 1378 | newchat() |
1351 | 1379 | }); |
1352 | 1380 |
|
| 1381 | + document.getElementById('search-input').addEventListener('input', function(e) { |
| 1382 | + const searchTerm = e.target.value.toLowerCase(); |
| 1383 | + const historyItems = document.querySelectorAll('#history-list li'); |
| 1384 | + |
| 1385 | + historyItems.forEach(item => { |
| 1386 | + const text = item.querySelector('.history-span').textContent.toLowerCase(); |
| 1387 | + if (text.includes(searchTerm)) { |
| 1388 | + item.style.display = ''; |
| 1389 | + } else { |
| 1390 | + item.style.display = 'none'; |
| 1391 | + } |
| 1392 | + }); |
| 1393 | + }); |
| 1394 | + |
| 1395 | + document.getElementById('search-input').addEventListener('keydown', function(e) { |
| 1396 | + if (e.key === 'Escape') { |
| 1397 | + this.value = ''; |
| 1398 | + this.dispatchEvent(new Event('input')); |
| 1399 | + } |
| 1400 | + }); |
| 1401 | + |
1353 | 1402 | // Load history list on page load |
1354 | 1403 | window.onload = function() { |
1355 | 1404 | initThemeToggle(); |
|
0 commit comments