@@ -287,6 +287,11 @@ function _getBuiltinTags() {
287287 return _builtinTags ;
288288}
289289
290+ // 预构建 SVG 图标字符串,避免每条收藏重复创建(WebKit2GTK 性能优化)
291+ const _SVG_CHECK = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>' ;
292+ const _SVG_EDIT = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>' ;
293+ const _SVG_DELETE = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>' ;
294+
290295/**
291296 * 从收藏列表中聚合所有标签,按出现频次降序排序。
292297 * 优先展示 "用户" 标签和用户自定义标签,内置标签按频次补位。
@@ -359,10 +364,9 @@ function _renderChips(tags) {
359364 * @param {number } index - 渲染索引
360365 * @returns {string }
361366 */
362- function _renderUserTags ( fav , index ) {
367+ function _renderUserTags ( fav , index , builtin ) {
363368 const tags = Array . isArray ( fav . tags ) ? fav . tags : [ '用户' ] ;
364369 if ( tags . length === 0 ) return '' ;
365- const builtin = _getBuiltinTags ( ) ;
366370 const chips = tags . map ( t => {
367371 const canQuickRemove = t !== '用户' && ! builtin . has ( t ) ;
368372 return `<span class="fav-tag-chip${ canQuickRemove ? ' fav-tag-chip-removable' : '' } " data-tag="${ escapeHtml ( t ) } ">#${ escapeHtml ( t ) } ${ canQuickRemove ? `<button class="fav-tag-chip-remove" data-tag-index="${ index } " data-tag="${ escapeHtml ( t ) } " title="从当前规则移除此标签">×</button>` : '' } </span>` ;
@@ -412,6 +416,9 @@ export function renderFavoritesList(filterText) {
412416 listEl . style . display = '' ;
413417 emptyEl . style . display = 'none' ;
414418
419+ // 预计算内置标签集合,避免每条收藏重复计算(WebKit2GTK 性能优化)
420+ const builtin = _getBuiltinTags ( ) ;
421+
415422 listEl . innerHTML = favorites . map ( ( f , i ) => {
416423 // 仅前 12 项应用 staggered 渐入,避免长列表动画开销
417424 const delay = i < 12 ? ` style="animation-delay:${ ( i * 24 ) . toFixed ( 0 ) } ms"` : '' ;
@@ -430,11 +437,7 @@ export function renderFavoritesList(filterText) {
430437 ${ sysTags }
431438 </div>
432439 <div class="fav-item-actions">
433- <button class="btn btn-sm fav-fill" data-index="${ i } " title="填充到搜索框">
434- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
435- <polyline points="20 6 9 17 4 12"/>
436- </svg>
437- </button>
440+ <button class="btn btn-sm fav-fill" data-index="${ i } " title="填充到搜索框">${ _SVG_CHECK } </button>
438441 </div>
439442 </div>` ;
440443 }
@@ -443,28 +446,15 @@ export function renderFavoritesList(filterText) {
443446 <div class="fav-item-main">
444447 <div class="fav-name-row">
445448 <span class="fav-name" data-name-index="${ i } " title="点击编辑别名">${ escapeHtml ( f . name || f . baseQuery ) } </span>
446- <button class="fav-edit-btn" data-edit-index="${ i } " title="编辑别名">
447- <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
448- <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
449- <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
450- </svg>
451- </button>
449+ <button class="fav-edit-btn" data-edit-index="${ i } " title="编辑别名">${ _SVG_EDIT } </button>
452450 </div>
453451 <span class="fav-query" title="${ escapeHtml ( f . query ) } ">${ escapeHtml ( f . query ) } </span>
454- ${ _renderUserTags ( f , i ) }
452+ ${ _renderUserTags ( f , i , builtin ) }
455453 <span class="fav-time">${ formatTime ( f . time ) } </span>
456454 </div>
457455 <div class="fav-item-actions">
458- <button class="btn btn-sm fav-fill" data-index="${ i } " title="填充到搜索框">
459- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
460- <polyline points="20 6 9 17 4 12"/>
461- </svg>
462- </button>
463- <button class="btn btn-sm fav-delete" data-index="${ i } " title="删除收藏">
464- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
465- <line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
466- </svg>
467- </button>
456+ <button class="btn btn-sm fav-fill" data-index="${ i } " title="填充到搜索框">${ _SVG_CHECK } </button>
457+ <button class="btn btn-sm fav-delete" data-index="${ i } " title="删除收藏">${ _SVG_DELETE } </button>
468458 </div>
469459 </div>` ;
470460 } ) . join ( '' ) ;
0 commit comments