/** * @file js/ui/glossary-editor-enhanced.js * @description 增强版术语库编辑器 - 支持大数据量、搜索、分页、批量操作 */ (function() { const ITEMS_PER_PAGE = 20; // 每页显示条数 // 编辑器状态 const editorState = { currentSetId: null, allEntries: [], filteredEntries: [], currentPage: 1, totalPages: 0, searchQuery: '', selectedIds: new Set(), selectAll: false }; /** * 打开增强版编辑器 * @param {string} setId - 术语库 ID */ async function openEnhancedEditor(setId) { if (!setId) return; editorState.currentSetId = setId; editorState.currentPage = 1; editorState.searchQuery = ''; editorState.selectedIds.clear(); editorState.selectAll = false; // 显示加载提示 showEditorLoading(); try { // 从缓存加载数据 const sets = window._glossarySetsCache || {}; const set = sets[setId]; if (!set) { throw new Error('术语库不存在'); } editorState.allEntries = Array.isArray(set.entries) ? set.entries : []; editorState.filteredEntries = [...editorState.allEntries]; editorState.totalPages = Math.ceil(editorState.filteredEntries.length / ITEMS_PER_PAGE); // 渲染编辑器 renderEnhancedEditor(set); } catch (err) { console.error('Failed to open enhanced editor:', err); alert('打开术语库失败: ' + err.message); } } /** * 显示加载提示 */ function showEditorLoading() { const container = document.getElementById('glossaryEntriesTable'); if (!container) return; container.innerHTML = `
正在加载术语库数据...
共 ${totalEntries.toLocaleString()} 条 ${filteredCount !== totalEntries ? `,筛选后 ${filteredCount.toLocaleString()} 条` : ''} ${selectedCount > 0 ? `,已选择 ${selectedCount} 条` : ''}
${editorState.searchQuery ? '未找到匹配的术语' : '暂无术语条目'}
| # | 术语 | 译文 | 区分大小写 | 全词匹配 | 启用 | 操作 |
|---|