Skip to content

Commit c47f3d4

Browse files
committed
feat: improve fuse keys
1 parent 9b5421a commit c47f3d4

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

docs/.vuepress/components/Demo/Demo.vue

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,29 @@ import Fuse from '../../../../dist/fuse.esm.js'
5252
import Books from './books.js'
5353
import MonacoEditor from './MonacoEditor.vue'
5454
55-
let possibleFuseKeys: string[] = []
56-
for (const key in Fuse.config) {
57-
if (typeof Fuse.config[key] != 'function' && key !== 'keys') {
58-
possibleFuseKeys.push(key)
59-
}
60-
}
61-
6255
const searchPattern = ref('')
56+
const fuseSearchOptions = ref({
57+
isCaseSensitive: false,
58+
includeScore: false,
59+
shouldSort: true,
60+
includeMatches: false,
61+
findAllMatches: false,
62+
minMatchCharLength: 1,
63+
location: 0,
64+
threshold: 0.6,
65+
distance: 100,
66+
useExtendedSearch: false,
67+
ignoreLocation: false,
68+
ignoreFieldNorm: false,
69+
fieldNormWeight: 1
70+
})
6371
6472
let codify = () => {
6573
return `
6674
const Fuse = require('fuse.js');
6775
6876
const fuseOptions = {
69-
${possibleFuseKeys.map((key) => `\t// ${key}: ${Fuse.config[key]},`).join('\n')}
77+
${Object.entries(fuseSearchOptions).map(([key, value]) => `\t// ${key}: ${value},`).join('\n')}
7078
\tkeys: [
7179
\t\t"title",
7280
\t\t"author.firstName"

0 commit comments

Comments
 (0)