Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
perf: improve the indexing threshold for the fuse search engine (#849)
Browse files Browse the repository at this point in the history
#### What type of PR is this?

/kind improvement

#### What this PR does / why we need it:

优化 Console 端使用 fuse.js 搜索引擎的搜索阈值,解决搜索关键词匹配的问题。

#### Which issue(s) this PR fixes:

Fixes halo-dev/halo#3289

#### Screenshots:

before:

![image](https://user-images.githubusercontent.com/21301288/218301830-9cc0ac6e-994c-4994-9701-28e50cc90fa3.png)

after:

<img width="676" alt="image" src="https://user-images.githubusercontent.com/21301288/218301848-0883bbe7-f2ad-4ccb-8802-74920d76ebe0.png">


#### Special notes for your reviewer:

测试方式:

1. 检查 Console 端全局搜索,以及用户/权限管理的搜索是否符合预期。

#### Does this PR introduce a user-facing change?

```release-note
优化 Console 端全局搜索的匹配规则。
```
  • Loading branch information
ruibaby authored Feb 13, 2023
1 parent 047e221 commit 8209e14
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ watch(
fuse = new Fuse(categories.value, {
keys: ["spec.displayName", "metadata.name"],
useExtendedSearch: true,
threshold: 0.2,
});
}
);
Expand Down
1 change: 1 addition & 0 deletions src/components/dropdown-selector/TagDropdownSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ watch(
fuse = new Fuse(tags.value, {
keys: ["spec.displayName", "metadata.name", "spec.email"],
useExtendedSearch: true,
threshold: 0.2,
});
}
);
Expand Down
1 change: 1 addition & 0 deletions src/components/dropdown-selector/UserDropdownSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ watch(
fuse = new Fuse(users.value, {
keys: ["spec.displayName", "metadata.name", "spec.email"],
useExtendedSearch: true,
threshold: 0.2,
});
}
);
Expand Down
1 change: 1 addition & 0 deletions src/components/global-search/GlobalSearchModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const selectedIndex = ref(0);
const fuse = new Fuse(searchableItem, {
keys: ["title", "group", "route.path", "route.name"],
useExtendedSearch: true,
threshold: 0.2,
});
const searchResults = computed((): SearchableItem[] => {
Expand Down
1 change: 1 addition & 0 deletions src/modules/system/roles/RoleList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ watch(
fuse = new Fuse(value, {
keys: ["spec.displayName", "metadata.name"],
useExtendedSearch: true,
threshold: 0.2,
});
}
);
Expand Down
1 change: 1 addition & 0 deletions src/modules/system/users/UserList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const handleFetchUsers = async (options?: { mute?: boolean }) => {
fuse = new Fuse(data.items, {
keys: ["spec.displayName", "metadata.name", "spec.email"],
useExtendedSearch: true,
threshold: 0.2,
});
const deletedUsers = users.value.items.filter(
Expand Down

1 comment on commit 8209e14

@vercel
Copy link

@vercel vercel bot commented on 8209e14 Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

halo-admin-ui.vercel.app
ui-git-main-halo-dev.vercel.app
ui-halo-dev.vercel.app

Please sign in to comment.