diff --git a/www/app.js b/www/app.js
index 06d990c..39216eb 100644
--- a/www/app.js
+++ b/www/app.js
@@ -198,11 +198,16 @@ function bindPageEvents() {
function renderChatsPage() {
return `
-
+
+
+
`;
}
@@ -229,6 +246,70 @@ function bindChatsPageEvents() {
newChatBtn.addEventListener('click', createNewConversation);
}
+ // 搜索功能
+ const searchToggleBtn = document.getElementById('searchToggleBtn');
+ const searchBar = document.getElementById('searchBar');
+ const searchInput = document.getElementById('searchInput');
+ const searchCloseBtn = document.getElementById('searchCloseBtn');
+ const searchResults = document.getElementById('searchResults');
+
+ if (searchToggleBtn) {
+ searchToggleBtn.addEventListener('click', () => {
+ if (searchBar) {
+ searchBar.classList.add('show');
+ if (searchInput) {
+ searchInput.focus();
+ }
+ }
+ });
+ }
+
+ if (searchCloseBtn) {
+ searchCloseBtn.addEventListener('click', () => {
+ hideSearchBarInChats();
+ });
+ }
+
+ if (searchInput) {
+ searchInput.addEventListener('input', (e) => {
+ const keyword = e.target.value.trim();
+ if (keyword) {
+ searchConversations(keyword);
+ } else {
+ if (searchResults) searchResults.innerHTML = '';
+ }
+ });
+
+ searchInput.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape') {
+ hideSearchBarInChats();
+ }
+ });
+ }
+
+ if (searchResults) {
+ searchResults.addEventListener('click', (e) => {
+ const item = e.target.closest('.search-result-item');
+ if (item) {
+ const id = item.getAttribute('data-id');
+ hideSearchBarInChats();
+ openConversation(id);
+ }
+ });
+ }
+
+ function hideSearchBarInChats() {
+ if (searchBar) {
+ searchBar.classList.remove('show');
+ }
+ if (searchInput) {
+ searchInput.value = '';
+ }
+ if (searchResults) {
+ searchResults.innerHTML = '';
+ }
+ }
+
const conversationList = document.getElementById('conversationList');
if (conversationList) {
conversationList.addEventListener('click', (e) => {
diff --git a/www/index.html b/www/index.html
index 3a36bac..109a581 100644
--- a/www/index.html
+++ b/www/index.html
@@ -8,12 +8,12 @@
AI助手
-
+
-
-
+
+