File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -382,7 +382,7 @@ export default {
382382 }
383383 let items
384384 if (this .searchQuery && this .searchQuery .length >= 2 ) {
385- items = this .search (this .searchQuery .toLowerCase ().trim (), this .currentFolder )
385+ return this .search (this .searchQuery .toLowerCase ().trim (), this .currentFolder )
386386 } else {
387387 items = this .currentFolder .children
388388 }
@@ -466,11 +466,17 @@ export default {
466466 }, 500 )
467467 },
468468 search (query , tree ) {
469- return Object .values (tree .index .bookmark ).filter (item => {
470- const matchTitle = item .title ? query .split (' ' ).every (term => item .title .toLowerCase ().includes (term)) : false
471- const matchUrl = query .split (' ' ).every (term => item .url .toLowerCase ().includes (term))
472- return matchUrl || matchTitle
473- })
469+ return Object .values (tree .index .bookmark )
470+ .filter (item => {
471+ const matchTitle = item .title ? query .split (' ' ).every (term => item .title .toLowerCase ().split (' ' ).some (word => word === term)) : false
472+ const matchUrl = query .split (' ' ).every (term => item .url .toLowerCase ().includes (term))
473+ return matchUrl || matchTitle
474+ })
475+ .sort ((a , b ) => {
476+ const matchTitleA = a .title ? query .split (' ' ).every (term => a .title .toLowerCase ().split (' ' ).some (word => word === term)) : false
477+ const matchTitleB = b .title ? query .split (' ' ).every (term => b .title .toLowerCase ().split (' ' ).some (word => word === term)) : false
478+ return matchTitleA ? (matchTitleB ? 0 : - 1 ) : 1
479+ })
474480 },
475481 goBack () {
476482 if (this .isAddingBookmark ) {
You can’t perform that action at this time.
0 commit comments