Skip to content

Commit 0c60624

Browse files
author
steven
committed
1. added chat history search feature.
1 parent ab0dad3 commit 0c60624

File tree

1 file changed

+54
-5
lines changed

1 file changed

+54
-5
lines changed

ailice/ui/templates/index.html

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,31 @@
218218
padding: 20px;
219219
background-color: var(--bg-tertiary);
220220
}
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+
}
221246
.sidebar ul {
222247
list-style-type: none;
223248
padding: 0;
@@ -467,17 +492,17 @@
467492
width: 36px;
468493
height: 36px;
469494
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);
473497
border-radius: 8px;
474-
color: #666;
498+
color: var(--text-primary);
475499
cursor: pointer;
476500
transition: all 0.2s ease;
477501
display: flex;
478502
align-items: center;
479503
justify-content: center;
480504
font-size: 18px;
505+
flex-shrink: 0;
481506
}
482507
#new-chat-button:hover {
483508
background-color: #fff;
@@ -592,7 +617,10 @@
592617
</div>
593618
<div class="container">
594619
<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>
596624
<ul id="history-list">
597625
<!-- History records will be listed here -->
598626
</ul>
@@ -1350,6 +1378,27 @@
13501378
newchat()
13511379
});
13521380

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+
13531402
// Load history list on page load
13541403
window.onload = function() {
13551404
initThemeToggle();

0 commit comments

Comments
 (0)