()
| 352 | |
| 353 | // 全局更新按钮文本函数 |
| 354 | function updateButtonTexts() { |
| 355 | // 更新回收站按钮 |
| 356 | const trashBtn = document.querySelector('.nsn-btn[title="回收站"]'); |
| 357 | if (trashBtn) { |
| 358 | const trashData = readJSON(LS_KEYS.trash, []); |
| 359 | const trashCount = trashData.length; |
| 360 | trashBtn.textContent = trashCount > 0 ? `回收站 (${trashCount})` : '回收站'; |
| 361 | } |
| 362 | |
| 363 | const historyBtn = document.querySelector('.nsn-btn[title="历史记录"]'); |
| 364 | |
| 365 | if (!window.currentNoteId) { |
| 366 | if (historyBtn) historyBtn.textContent = '历史记录'; |
| 367 | return; |
| 368 | } |
| 369 | |
| 370 | const map = readJSON(LS_KEYS.notes, {}); |
| 371 | const list = map[window.currentCategoryId] || []; |
| 372 | const note = list.find(n => n.id === window.currentNoteId); |
| 373 | |
| 374 | if (note) { |
| 375 | // 更新历史记录按钮 |
| 376 | if (historyBtn) { |
| 377 | const historyCount = (note.history && note.history.length > 0) ? note.history.length : 0; |
| 378 | historyBtn.textContent = historyCount > 0 ? `历史记录 (${historyCount})` : '历史记录'; |
| 379 | } |
| 380 | |
| 381 | |
| 382 | } else { |
| 383 | if (historyBtn) historyBtn.textContent = '历史记录'; |
| 384 | |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | function buildToolbar(cmd) { |
| 389 | const bar = createElement('div', { className: 'nsn-toolbar' }); |
no test coverage detected