mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-16 14:10:52 +01:00
added fuse search
This commit is contained in:
@ -38,6 +38,7 @@
|
||||
"drizzle-orm": "^0.43.1",
|
||||
"eslint": "^9.28.0",
|
||||
"flyonui": "^2.2.0",
|
||||
"fuse.js": "^7.1.0",
|
||||
"nuxt": "^3.17.4",
|
||||
"nuxt-snackbar": "1.3.0",
|
||||
"nuxt-zod-i18n": "^1.11.5",
|
||||
|
||||
4
pnpm-lock.yaml
generated
4
pnpm-lock.yaml
generated
@ -74,6 +74,9 @@ importers:
|
||||
flyonui:
|
||||
specifier: ^2.2.0
|
||||
version: 2.2.0
|
||||
fuse.js:
|
||||
specifier: ^7.1.0
|
||||
version: 7.1.0
|
||||
nuxt:
|
||||
specifier: ^3.17.4
|
||||
version: 3.17.5(@libsql/client@0.15.9)(@parcel/watcher@2.5.1)(@types/node@24.0.3)(db0@0.3.2(@libsql/client@0.15.9)(drizzle-orm@0.43.1(@libsql/client@0.15.9)))(drizzle-orm@0.43.1(@libsql/client@0.15.9))(eslint@9.29.0(jiti@2.4.2))(ioredis@5.6.1)(lightningcss@1.30.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.44.0)(terser@5.43.1)(typescript@5.8.3)(vite@6.3.5(@types/node@24.0.3)(jiti@2.4.2)(lightningcss@1.30.1)(terser@5.43.1)(yaml@2.8.0))(vue-tsc@2.2.10(typescript@5.8.3))(yaml@2.8.0)
|
||||
@ -3580,7 +3583,6 @@ packages:
|
||||
|
||||
libsql@0.5.13:
|
||||
resolution: {integrity: sha512-5Bwoa/CqzgkTwySgqHA5TsaUDRrdLIbdM4egdPcaAnqO3aC+qAgS6BwdzuZwARA5digXwiskogZ8H7Yy4XfdOg==}
|
||||
cpu: [x64, arm64, wasm32, arm]
|
||||
os: [darwin, linux, win32]
|
||||
|
||||
lightningcss-darwin-arm64@1.30.1:
|
||||
|
||||
@ -176,12 +176,6 @@ const checkInput = () => {
|
||||
const { copy, copied } = useClipboard()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
onKeyStroke('a', (event) => {
|
||||
if (event.ctrlKey) {
|
||||
event.stopImmediatePropagation()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<i18n lang="yaml">
|
||||
|
||||
@ -71,6 +71,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { IPasswordMenuItem } from '~/components/haex/pass/mobile/menu/types'
|
||||
import { useMagicKeys } from '@vueuse/core'
|
||||
import Fuse from 'fuse.js'
|
||||
|
||||
definePageMeta({
|
||||
name: 'passwordGroupItems',
|
||||
@ -103,18 +104,28 @@ const { search } = storeToRefs(useSearchStore())
|
||||
|
||||
const groupItems = computed<IPasswordMenuItem[]>(() => {
|
||||
const menuItems: IPasswordMenuItem[] = []
|
||||
const filteredGroups = search.value
|
||||
? new Fuse(groups.value, {
|
||||
keys: ['name', 'description'],
|
||||
findAllMatches: true,
|
||||
})
|
||||
.search(search.value)
|
||||
.map((match) => match.item)
|
||||
: groups.value.filter((group) => group.parentId == currentGroupId.value)
|
||||
|
||||
const filteredItems = search.value
|
||||
? new Fuse(items.value, {
|
||||
keys: ['title', 'note', 'password', 'tags', 'url', 'username'],
|
||||
})
|
||||
.search(search.value)
|
||||
.map((match) => match.item)
|
||||
: items.value.filter(
|
||||
(item) =>
|
||||
item.haex_passwords_group_items.groupId == currentGroupId.value,
|
||||
)
|
||||
|
||||
menuItems.push(
|
||||
...groups.value
|
||||
.filter((group) => {
|
||||
if (!search.value) return group.parentId == currentGroupId.value
|
||||
|
||||
return (
|
||||
group.name?.includes(search.value) ||
|
||||
group.description?.includes(search.value)
|
||||
)
|
||||
})
|
||||
.map<IPasswordMenuItem>((group) => ({
|
||||
...filteredGroups.map<IPasswordMenuItem>((group) => ({
|
||||
color: group.color,
|
||||
icon: group.icon,
|
||||
id: group.id,
|
||||
@ -124,21 +135,7 @@ const groupItems = computed<IPasswordMenuItem[]>(() => {
|
||||
)
|
||||
|
||||
menuItems.push(
|
||||
...items.value
|
||||
.filter((item) => {
|
||||
if (!search.value)
|
||||
return item.haex_passwords_group_items.groupId == currentGroupId.value
|
||||
|
||||
return (
|
||||
item.haex_passwords_item_details.title?.includes(search.value) ||
|
||||
item.haex_passwords_item_details.note?.includes(search.value) ||
|
||||
item.haex_passwords_item_details.password?.includes(search.value) ||
|
||||
item.haex_passwords_item_details.tags?.includes(search.value) ||
|
||||
item.haex_passwords_item_details.url?.includes(search.value) ||
|
||||
item.haex_passwords_item_details.username?.includes(search.value)
|
||||
)
|
||||
})
|
||||
.map<IPasswordMenuItem>((item) => ({
|
||||
...filteredItems.map<IPasswordMenuItem>((item) => ({
|
||||
icon: item.haex_passwords_item_details.icon,
|
||||
id: item.haex_passwords_item_details.id,
|
||||
name: item.haex_passwords_item_details.title,
|
||||
@ -208,7 +205,6 @@ const onPasteAsync = async () => {
|
||||
}
|
||||
onKeyStroke('v', async (event) => {
|
||||
if (event.ctrlKey) {
|
||||
event.preventDefault()
|
||||
await onPasteAsync()
|
||||
}
|
||||
})
|
||||
@ -221,6 +217,7 @@ watch(escape, () => {
|
||||
onKeyStroke('a', (event) => {
|
||||
if (event.ctrlKey) {
|
||||
event.preventDefault()
|
||||
event.stopImmediatePropagation()
|
||||
selectedItems.value = new Set(groupItems.value)
|
||||
}
|
||||
})
|
||||
|
||||
@ -28,13 +28,13 @@ export const usePasswordGroupStore = defineStore('passwordGroupStore', () => {
|
||||
currentGroupId.value ? readGroupAsync(currentGroupId.value) : null,
|
||||
)
|
||||
|
||||
const currentGroupItems = reactive<{
|
||||
/* const currentGroupItems = reactive<{
|
||||
items: SelectHaexPasswordsItemDetails[]
|
||||
groups: SelectHaexPasswordsGroups[]
|
||||
}>({
|
||||
items: [],
|
||||
groups: [],
|
||||
})
|
||||
}) */
|
||||
|
||||
const selectedGroupItems = ref<IPasswordMenuItem[]>()
|
||||
|
||||
@ -57,19 +57,15 @@ export const usePasswordGroupStore = defineStore('passwordGroupStore', () => {
|
||||
|
||||
const syncGroupItemsAsync = async (currentGroupId?: string | null) => {
|
||||
const { addNotificationAsync } = useNotificationStore()
|
||||
const { readByGroupIdAsync } = usePasswordItemStore()
|
||||
const { readByGroupIdAsync, syncItemsAsync } = usePasswordItemStore()
|
||||
|
||||
groups.value = await readGroupsAsync()
|
||||
await syncItemsAsync()
|
||||
currentGroup.value = groups.value?.find(
|
||||
(group) => group.id === currentGroupId,
|
||||
)
|
||||
console.log(
|
||||
'syncGroupItemsAsync',
|
||||
groups.value,
|
||||
currentGroup.value,
|
||||
currentGroupId,
|
||||
)
|
||||
try {
|
||||
|
||||
/* try {
|
||||
currentGroupItems.groups =
|
||||
(await getByParentIdAsync(currentGroupId)) ?? []
|
||||
currentGroupItems.items = (await readByGroupIdAsync(currentGroupId)) ?? []
|
||||
@ -81,7 +77,7 @@ export const usePasswordGroupStore = defineStore('passwordGroupStore', () => {
|
||||
type: 'log',
|
||||
text: JSON.stringify(error),
|
||||
})
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
watch(currentGroupId, () => syncGroupItemsAsync(currentGroupId.value), {
|
||||
@ -98,7 +94,7 @@ export const usePasswordGroupStore = defineStore('passwordGroupStore', () => {
|
||||
createTrashIfNotExistsAsync,
|
||||
currentGroup,
|
||||
currentGroupId,
|
||||
currentGroupItems,
|
||||
// currentGroupItems,
|
||||
deleteGroupAsync,
|
||||
getChildGroupsRecursiveAsync,
|
||||
groups,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
export const useSearchStore = defineStore('searchStore', () => {
|
||||
const search = ref()
|
||||
const search = ref('')
|
||||
|
||||
return {
|
||||
search,
|
||||
|
||||
Reference in New Issue
Block a user