@@ -568,6 +568,40 @@ async function _showTagPopover(anchor, entry, idx) {
568568 popover . appendChild ( opt ) ;
569569 } ) ;
570570
571+ // 分隔线 + 自定义标签输入
572+ const divider = document . createElement ( 'div' ) ;
573+ divider . className = 'fav-tag-popover-divider' ;
574+ popover . appendChild ( divider ) ;
575+
576+ const customRow = document . createElement ( 'div' ) ;
577+ customRow . className = 'fav-tag-custom-row' ;
578+ customRow . innerHTML = `
579+ <input type="text" class="fav-tag-custom-input" placeholder="新建分组…" maxlength="20">
580+ <button class="fav-tag-custom-add" title="添加">+</button>` ;
581+ popover . appendChild ( customRow ) ;
582+
583+ const customInput = customRow . querySelector ( '.fav-tag-custom-input' ) ;
584+ const customAdd = customRow . querySelector ( '.fav-tag-custom-add' ) ;
585+
586+ const addCustomTag = ( ) => {
587+ const name = customInput . value . trim ( ) ;
588+ if ( ! name ) return ;
589+ // 添加自定义标签到当前收藏
590+ const newTags = [ ...currentTags , name ] ;
591+ updateFavoriteTags ( entry . baseQuery , newTags ) ;
592+ const searchText = document . getElementById ( 'favSearchInput' ) ?. value || '' ;
593+ renderFavoritesList ( searchText ) ;
594+ popover . remove ( ) ;
595+ document . removeEventListener ( 'click' , closeHandler ) ;
596+ } ;
597+ customAdd . addEventListener ( 'click' , addCustomTag ) ;
598+ customInput . addEventListener ( 'keydown' , ( e ) => {
599+ if ( e . key === 'Enter' ) {
600+ e . preventDefault ( ) ;
601+ addCustomTag ( ) ;
602+ }
603+ } ) ;
604+
571605 // 点击外部关闭
572606 const closeHandler = ( e ) => {
573607 if ( ! popover . contains ( e . target ) && e . target !== anchor ) {
0 commit comments