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",
|
"drizzle-orm": "^0.43.1",
|
||||||
"eslint": "^9.28.0",
|
"eslint": "^9.28.0",
|
||||||
"flyonui": "^2.2.0",
|
"flyonui": "^2.2.0",
|
||||||
|
"fuse.js": "^7.1.0",
|
||||||
"nuxt": "^3.17.4",
|
"nuxt": "^3.17.4",
|
||||||
"nuxt-snackbar": "1.3.0",
|
"nuxt-snackbar": "1.3.0",
|
||||||
"nuxt-zod-i18n": "^1.11.5",
|
"nuxt-zod-i18n": "^1.11.5",
|
||||||
|
|||||||
4
pnpm-lock.yaml
generated
4
pnpm-lock.yaml
generated
@ -74,6 +74,9 @@ importers:
|
|||||||
flyonui:
|
flyonui:
|
||||||
specifier: ^2.2.0
|
specifier: ^2.2.0
|
||||||
version: 2.2.0
|
version: 2.2.0
|
||||||
|
fuse.js:
|
||||||
|
specifier: ^7.1.0
|
||||||
|
version: 7.1.0
|
||||||
nuxt:
|
nuxt:
|
||||||
specifier: ^3.17.4
|
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)
|
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:
|
libsql@0.5.13:
|
||||||
resolution: {integrity: sha512-5Bwoa/CqzgkTwySgqHA5TsaUDRrdLIbdM4egdPcaAnqO3aC+qAgS6BwdzuZwARA5digXwiskogZ8H7Yy4XfdOg==}
|
resolution: {integrity: sha512-5Bwoa/CqzgkTwySgqHA5TsaUDRrdLIbdM4egdPcaAnqO3aC+qAgS6BwdzuZwARA5digXwiskogZ8H7Yy4XfdOg==}
|
||||||
cpu: [x64, arm64, wasm32, arm]
|
|
||||||
os: [darwin, linux, win32]
|
os: [darwin, linux, win32]
|
||||||
|
|
||||||
lightningcss-darwin-arm64@1.30.1:
|
lightningcss-darwin-arm64@1.30.1:
|
||||||
|
|||||||
@ -176,12 +176,6 @@ const checkInput = () => {
|
|||||||
const { copy, copied } = useClipboard()
|
const { copy, copied } = useClipboard()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
onKeyStroke('a', (event) => {
|
|
||||||
if (event.ctrlKey) {
|
|
||||||
event.stopImmediatePropagation()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<i18n lang="yaml">
|
<i18n lang="yaml">
|
||||||
|
|||||||
@ -71,6 +71,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { IPasswordMenuItem } from '~/components/haex/pass/mobile/menu/types'
|
import type { IPasswordMenuItem } from '~/components/haex/pass/mobile/menu/types'
|
||||||
import { useMagicKeys } from '@vueuse/core'
|
import { useMagicKeys } from '@vueuse/core'
|
||||||
|
import Fuse from 'fuse.js'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
name: 'passwordGroupItems',
|
name: 'passwordGroupItems',
|
||||||
@ -103,47 +104,43 @@ const { search } = storeToRefs(useSearchStore())
|
|||||||
|
|
||||||
const groupItems = computed<IPasswordMenuItem[]>(() => {
|
const groupItems = computed<IPasswordMenuItem[]>(() => {
|
||||||
const menuItems: 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(
|
menuItems.push(
|
||||||
...groups.value
|
...filteredGroups.map<IPasswordMenuItem>((group) => ({
|
||||||
.filter((group) => {
|
color: group.color,
|
||||||
if (!search.value) return group.parentId == currentGroupId.value
|
icon: group.icon,
|
||||||
|
id: group.id,
|
||||||
return (
|
name: group.name,
|
||||||
group.name?.includes(search.value) ||
|
type: 'group',
|
||||||
group.description?.includes(search.value)
|
})),
|
||||||
)
|
|
||||||
})
|
|
||||||
.map<IPasswordMenuItem>((group) => ({
|
|
||||||
color: group.color,
|
|
||||||
icon: group.icon,
|
|
||||||
id: group.id,
|
|
||||||
name: group.name,
|
|
||||||
type: 'group',
|
|
||||||
})),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
menuItems.push(
|
menuItems.push(
|
||||||
...items.value
|
...filteredItems.map<IPasswordMenuItem>((item) => ({
|
||||||
.filter((item) => {
|
icon: item.haex_passwords_item_details.icon,
|
||||||
if (!search.value)
|
id: item.haex_passwords_item_details.id,
|
||||||
return item.haex_passwords_group_items.groupId == currentGroupId.value
|
name: item.haex_passwords_item_details.title,
|
||||||
|
type: 'item',
|
||||||
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) => ({
|
|
||||||
icon: item.haex_passwords_item_details.icon,
|
|
||||||
id: item.haex_passwords_item_details.id,
|
|
||||||
name: item.haex_passwords_item_details.title,
|
|
||||||
type: 'item',
|
|
||||||
})),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return menuItems
|
return menuItems
|
||||||
@ -208,7 +205,6 @@ const onPasteAsync = async () => {
|
|||||||
}
|
}
|
||||||
onKeyStroke('v', async (event) => {
|
onKeyStroke('v', async (event) => {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
event.preventDefault()
|
|
||||||
await onPasteAsync()
|
await onPasteAsync()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -221,6 +217,7 @@ watch(escape, () => {
|
|||||||
onKeyStroke('a', (event) => {
|
onKeyStroke('a', (event) => {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
event.stopImmediatePropagation()
|
||||||
selectedItems.value = new Set(groupItems.value)
|
selectedItems.value = new Set(groupItems.value)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -28,13 +28,13 @@ export const usePasswordGroupStore = defineStore('passwordGroupStore', () => {
|
|||||||
currentGroupId.value ? readGroupAsync(currentGroupId.value) : null,
|
currentGroupId.value ? readGroupAsync(currentGroupId.value) : null,
|
||||||
)
|
)
|
||||||
|
|
||||||
const currentGroupItems = reactive<{
|
/* const currentGroupItems = reactive<{
|
||||||
items: SelectHaexPasswordsItemDetails[]
|
items: SelectHaexPasswordsItemDetails[]
|
||||||
groups: SelectHaexPasswordsGroups[]
|
groups: SelectHaexPasswordsGroups[]
|
||||||
}>({
|
}>({
|
||||||
items: [],
|
items: [],
|
||||||
groups: [],
|
groups: [],
|
||||||
})
|
}) */
|
||||||
|
|
||||||
const selectedGroupItems = ref<IPasswordMenuItem[]>()
|
const selectedGroupItems = ref<IPasswordMenuItem[]>()
|
||||||
|
|
||||||
@ -57,19 +57,15 @@ export const usePasswordGroupStore = defineStore('passwordGroupStore', () => {
|
|||||||
|
|
||||||
const syncGroupItemsAsync = async (currentGroupId?: string | null) => {
|
const syncGroupItemsAsync = async (currentGroupId?: string | null) => {
|
||||||
const { addNotificationAsync } = useNotificationStore()
|
const { addNotificationAsync } = useNotificationStore()
|
||||||
const { readByGroupIdAsync } = usePasswordItemStore()
|
const { readByGroupIdAsync, syncItemsAsync } = usePasswordItemStore()
|
||||||
|
|
||||||
groups.value = await readGroupsAsync()
|
groups.value = await readGroupsAsync()
|
||||||
|
await syncItemsAsync()
|
||||||
currentGroup.value = groups.value?.find(
|
currentGroup.value = groups.value?.find(
|
||||||
(group) => group.id === currentGroupId,
|
(group) => group.id === currentGroupId,
|
||||||
)
|
)
|
||||||
console.log(
|
|
||||||
'syncGroupItemsAsync',
|
/* try {
|
||||||
groups.value,
|
|
||||||
currentGroup.value,
|
|
||||||
currentGroupId,
|
|
||||||
)
|
|
||||||
try {
|
|
||||||
currentGroupItems.groups =
|
currentGroupItems.groups =
|
||||||
(await getByParentIdAsync(currentGroupId)) ?? []
|
(await getByParentIdAsync(currentGroupId)) ?? []
|
||||||
currentGroupItems.items = (await readByGroupIdAsync(currentGroupId)) ?? []
|
currentGroupItems.items = (await readByGroupIdAsync(currentGroupId)) ?? []
|
||||||
@ -81,7 +77,7 @@ export const usePasswordGroupStore = defineStore('passwordGroupStore', () => {
|
|||||||
type: 'log',
|
type: 'log',
|
||||||
text: JSON.stringify(error),
|
text: JSON.stringify(error),
|
||||||
})
|
})
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(currentGroupId, () => syncGroupItemsAsync(currentGroupId.value), {
|
watch(currentGroupId, () => syncGroupItemsAsync(currentGroupId.value), {
|
||||||
@ -98,7 +94,7 @@ export const usePasswordGroupStore = defineStore('passwordGroupStore', () => {
|
|||||||
createTrashIfNotExistsAsync,
|
createTrashIfNotExistsAsync,
|
||||||
currentGroup,
|
currentGroup,
|
||||||
currentGroupId,
|
currentGroupId,
|
||||||
currentGroupItems,
|
// currentGroupItems,
|
||||||
deleteGroupAsync,
|
deleteGroupAsync,
|
||||||
getChildGroupsRecursiveAsync,
|
getChildGroupsRecursiveAsync,
|
||||||
groups,
|
groups,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
export const useSearchStore = defineStore('searchStore', () => {
|
export const useSearchStore = defineStore('searchStore', () => {
|
||||||
const search = ref()
|
const search = ref('')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
search,
|
search,
|
||||||
|
|||||||
Reference in New Issue
Block a user