File tree 1 file changed +16
-7
lines changed
src/main/resources/META-INF/web
1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change 891
891
selectedNoteId = note . id ;
892
892
noteItem = note ;
893
893
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
+ } ) ) ;
898
903
}
899
904
900
905
function showNoteDetail ( note ) {
1032
1037
/** 搜索时保持选中状态 **/
1033
1038
document . getElementById ( 'searchInput' ) . addEventListener ( 'input' , function ( ) {
1034
1039
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 ( ) )
1036
1043
) ;
1037
1044
if ( ! filtered . some ( n => n . id === selectedNoteId ) ) {
1038
1045
selectedNoteId = filtered [ 0 ] ?. id ;
1164
1171
1165
1172
// 应用搜索过滤
1166
1173
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 ( ) )
1169
1178
) ;
1170
1179
}
1171
1180
You can’t perform that action at this time.
0 commit comments