samlax12 commited on
Commit
fd7c91d
·
verified ·
1 Parent(s): 5bd9f7e

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +79 -13
index.html CHANGED
@@ -2311,34 +2311,100 @@ function initAIAssistant() {
2311
  initSuggestions();
2312
  }
2313
 
2314
- // 初始化建议问题
2315
- function initSuggestions() {
2316
- const suggestionChips = [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2317
  "附近有什么好吃的火锅店?",
2318
  "推荐几家距离我500米内的咖啡厅",
2319
  "帮我规划一个3小时的美食路线",
2320
  "有什么适合带孩子去的餐厅?"
2321
  ];
2322
 
2323
- const suggestionsContainer = document.getElementById('suggestions');
2324
- suggestionsContainer.innerHTML = '';
2325
-
2326
- suggestionChips.forEach(suggestion => {
2327
  const chip = document.createElement('div');
2328
  chip.className = 'suggestion-chip';
2329
- chip.textContent = suggestion;
2330
-
2331
- // 确保只触发一次发送操作
2332
  chip.addEventListener('click', function() {
2333
  document.getElementById('user-input').value = this.textContent;
2334
- // 直接调用发送函数,而不是通过点击事件
2335
  sendUserMessage();
2336
  });
2337
-
2338
- suggestionsContainer.appendChild(chip);
 
 
 
 
 
 
 
 
 
 
 
2339
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2340
  }
2341
 
 
 
 
 
2342
  // 切换助手显示/隐藏
2343
  function toggleAssistant(show) {
2344
  const assistant = document.getElementById('ai-assistant');
 
2311
  initSuggestions();
2312
  }
2313
 
2314
+ // 添加收起/展开功能的快捷输入组件
2315
+ function createCollapsibleSuggestions() {
2316
+ // 创建容器
2317
+ const suggestionsContainer = document.getElementById('suggestions');
2318
+ if (!suggestionsContainer) return;
2319
+
2320
+ // 清空现有内容
2321
+ suggestionsContainer.innerHTML = '';
2322
+
2323
+ // 添加标题栏(可点击展开/收起)
2324
+ const titleBar = document.createElement('div');
2325
+ titleBar.className = 'suggestions-title';
2326
+ titleBar.innerHTML = `
2327
+ <span>常见问题</span>
2328
+ <i class="fas fa-chevron-down"></i>
2329
+ `;
2330
+ suggestionsContainer.appendChild(titleBar);
2331
+
2332
+ // 创建建议内容容器
2333
+ const suggestionsContent = document.createElement('div');
2334
+ suggestionsContent.className = 'suggestions-content';
2335
+ suggestionsContent.style.display = 'none'; // 默认收起
2336
+ suggestionsContainer.appendChild(suggestionsContent);
2337
+
2338
+ // 添加建议选项
2339
+ const suggestions = [
2340
  "附近有什么好吃的火锅店?",
2341
  "推荐几家距离我500米内的咖啡厅",
2342
  "帮我规划一个3小时的美食路线",
2343
  "有什么适合带孩子去的餐厅?"
2344
  ];
2345
 
2346
+ suggestions.forEach(text => {
 
 
 
2347
  const chip = document.createElement('div');
2348
  chip.className = 'suggestion-chip';
2349
+ chip.textContent = text;
 
 
2350
  chip.addEventListener('click', function() {
2351
  document.getElementById('user-input').value = this.textContent;
 
2352
  sendUserMessage();
2353
  });
2354
+ suggestionsContent.appendChild(chip);
2355
+ });
2356
+
2357
+ // 添加展开/收起功能
2358
+ titleBar.addEventListener('click', function() {
2359
+ const isExpanded = suggestionsContent.style.display !== 'none';
2360
+ if (isExpanded) {
2361
+ suggestionsContent.style.display = 'none';
2362
+ titleBar.querySelector('i').className = 'fas fa-chevron-down';
2363
+ } else {
2364
+ suggestionsContent.style.display = 'flex';
2365
+ titleBar.querySelector('i').className = 'fas fa-chevron-up';
2366
+ }
2367
  });
2368
+
2369
+ // 添加CSS
2370
+ const styleElement = document.createElement('style');
2371
+ styleElement.textContent = `
2372
+ .suggestions-title {
2373
+ display: flex;
2374
+ justify-content: space-between;
2375
+ align-items: center;
2376
+ padding: 10px 15px;
2377
+ background-color: var(--ios-bg);
2378
+ border-radius: 10px;
2379
+ margin-bottom: 5px;
2380
+ cursor: pointer;
2381
+ font-size: 14px;
2382
+ color: var(--ios-primary);
2383
+ font-weight: 500;
2384
+ }
2385
+
2386
+ .suggestions-content {
2387
+ display: flex;
2388
+ flex-wrap: wrap;
2389
+ gap: 8px;
2390
+ padding: 5px 10px 10px 10px;
2391
+ overflow: hidden;
2392
+ transition: max-height 0.3s ease;
2393
+ }
2394
+
2395
+ .chat-suggestions {
2396
+ border-top: 1px solid var(--ios-border);
2397
+ padding: 10px;
2398
+ background: var(--ios-card-bg);
2399
+ }
2400
+ `;
2401
+ document.head.appendChild(styleElement);
2402
  }
2403
 
2404
+ // 替换原有的初始化建议问题函数
2405
+ function initSuggestions() {
2406
+ createCollapsibleSuggestions();
2407
+ }
2408
  // 切换助手显示/隐藏
2409
  function toggleAssistant(show) {
2410
  const assistant = document.getElementById('ai-assistant');