mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-12 09:49:42 +00:00

* feat: add lockHideOnBlur to prevent app hiding during dialogs * feat: add Fuse.js for advanced search filtering across app sections * chore: update .prettierignore and clean up imports in AddDevExtForm
28 lines
864 B
TypeScript
28 lines
864 B
TypeScript
import { getSystemCommands } from "@kksh/api/commands"
|
|
import type { SysCommand } from "@kksh/api/models"
|
|
import { commandScore } from "@kksh/ui/utils"
|
|
import Fuse from "fuse.js"
|
|
import { derived, readable } from "svelte/store"
|
|
import { appState } from "../stores/appState"
|
|
|
|
export const systemCommands = getSystemCommands()
|
|
|
|
export const fuse = new Fuse<SysCommand>(systemCommands, {
|
|
includeScore: true,
|
|
threshold: 0.2,
|
|
keys: ["name"]
|
|
})
|
|
|
|
export const systemCommandsFiltered = derived(appState, ($appState) => {
|
|
return $appState.searchTerm
|
|
? fuse.search($appState.searchTerm).map((result) => result.item)
|
|
: systemCommands
|
|
})
|
|
|
|
// export const systemCommandsFiltered = derived(
|
|
// [systemCommands, appState],
|
|
// ([$systemCommands, $appState]) => {
|
|
// return $systemCommands.filter((cmd) => commandScore(cmd.name, $appState.searchTerm) > 0.5)
|
|
// }
|
|
// )
|