File tree Expand file tree Collapse file tree
src/main/resources/META-INF/web Expand file tree Collapse file tree Original file line number Diff line number Diff line change 891891 selectedNoteId = note . id ;
892892 noteItem = note ;
893893 showNoteDetail ( note ) ;
894- renderNotes ( notes . filter ( n =>
895- document . getElementById ( 'searchInput' ) . value ?
896- n . noteTitle . toLowerCase ( ) . includes ( document . getElementById ( 'searchInput' ) . value . toLowerCase ( ) ) : true
897- ) ) ;
894+ renderNotes ( notes . filter ( n => {
895+ let value = document . getElementById ( 'searchInput' ) . value ;
896+ if ( value ) {
897+ return n . noteTitle . toLowerCase ( ) . includes ( value . toLowerCase ( ) ) ||
898+ n . noteFilePath . toLowerCase ( ) . includes ( value . toLowerCase ( ) ) ||
899+ n . selectCode . toLowerCase ( ) . includes ( value . toLowerCase ( ) )
900+ } else
901+ return true ;
902+ } ) ) ;
898903 }
899904
900905 function showNoteDetail ( note ) {
10321037 /** 搜索时保持选中状态 **/
10331038 document . getElementById ( 'searchInput' ) . addEventListener ( 'input' , function ( ) {
10341039 const filtered = notes . filter ( n =>
1035- n . noteTitle . toLowerCase ( ) . includes ( this . value . toLowerCase ( ) )
1040+ n . noteTitle . toLowerCase ( ) . includes ( this . value . toLowerCase ( ) ) ||
1041+ n . noteFilePath . toLowerCase ( ) . includes ( this . value . toLowerCase ( ) ) ||
1042+ n . selectCode . toLowerCase ( ) . includes ( this . value . toLowerCase ( ) )
10361043 ) ;
10371044 if ( ! filtered . some ( n => n . id === selectedNoteId ) ) {
10381045 selectedNoteId = filtered [ 0 ] ?. id ;
11641171
11651172 // 应用搜索过滤
11661173 if ( searchText ) {
1167- filteredNotes = filteredNotes . filter ( note =>
1168- note . noteTitle . toLowerCase ( ) . includes ( searchText )
1174+ filteredNotes = filteredNotes . filter ( n =>
1175+ n . noteTitle . toLowerCase ( ) . includes ( this . value . toLowerCase ( ) ) ||
1176+ n . noteFilePath . toLowerCase ( ) . includes ( this . value . toLowerCase ( ) ) ||
1177+ n . selectCode . toLowerCase ( ) . includes ( this . value . toLowerCase ( ) )
11691178 ) ;
11701179 }
11711180
You can’t perform that action at this time.
0 commit comments