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

Commit

Permalink
chore: search by useFuse
Browse files Browse the repository at this point in the history
  • Loading branch information
liuseen-l committed Jul 6, 2023
1 parent 04af532 commit 9d80bf0
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"play": "nr -C playground dev",
"stub": "unbuild --stub",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"prepublishOnly": "npm run build",
"release": "bumpp && npm publish",
"dep:up": "taze -I major"
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/AssetPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defineProps<{
/>
<div v-else-if="asset.type === 'text' && !textContent" i-carbon-document text-3xl op20 />
<div v-else-if="asset.type === 'text' && textContent" w-full self-start p4>
<pre max-h-10rem of-hidden font-mono text-xs v-text="textContent" />
<pre max-h-10rem of-hidden text-xs font-mono v-text="textContent" />
</div>
<div v-else i-carbon-help text-3xl op20 />
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/RoutePathItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function navigate() {
<div px2 text-sm op50>
Fill params and navigate:
</div>
<div flex="~" items-center p2 font-mono text-sm>
<div flex="~" items-center p2 text-sm font-mono>
<template v-for="part, idx of parts" :key="idx">
<VTextInput
v-if="part[0] === ':'"
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/RoutesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const sorted = computed(() => {
/>
</div>
</td>
<td w-30 ws-nowrap pr-1 text-left font-mono text-sm op50>
<td w-30 ws-nowrap pr-1 text-left text-sm font-mono op50>
{{ item.name ?? '-' }}
</td>
</tr>
Expand Down
8 changes: 6 additions & 2 deletions src/client/pages/documentations.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { useFuse } from '@vueuse/integrations/useFuse'
import { rpc } from '../logic/rpc'
import type { DocumentInfo } from '../../types'
import { data } from '../logic/documentations'
Expand All @@ -21,9 +22,12 @@ function navigate(data: DocumentInfo) {
}
const keywords = ref('')
const { results: filterDocuments } = useFuse(keywords, rawItems.map(i => i.name), {
matchAllWhenSearchEmpty: true,
})
watch(keywords, () => {
items.value = rawItems.filter(item => packagesName.includes(item.id) && (item.id.includes(keywords.value) || keywords.value.length === 0))
watch(filterDocuments, () => {
items.value = rawItems.filter(item => (filterDocuments.value.map(i => i.item).includes(item.name) && packagesName.includes(item.id)))
})
function back() {
Expand Down
8 changes: 4 additions & 4 deletions src/client/pages/npm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ useInfiniteScroll(
</td>
<VDropdown max-w="10" placement="bottom-start" :distance="5">
<td
hover="text-primary" h-7 cursor-pointer ws-nowrap pr-1 text-left font-mono text-sm lh-7 underline
op70
hover="text-primary"
h-7 cursor-pointer ws-nowrap pr-1 text-left text-sm lh-7 font-mono underline op70
>
{{ item.activeVersion ?? item.version }}
</td>
Expand All @@ -243,12 +243,12 @@ useInfiniteScroll(
</ul>
</template>
</VDropdown>
<td w-30 ws-nowrap pr-1 text-left font-mono text-sm underline op70 hover="text-primary">
<td w-30 ws-nowrap pr-1 text-left text-sm font-mono underline op70 hover="text-primary">
<a :href="item?.owner?.link" target="_blank">
{{ item?.owner?.name ?? '-' }}
</a>
</td>
<td w-30 ws-nowrap pr-1 text-left font-mono text-sm op70>
<td w-30 ws-nowrap pr-1 text-left text-sm font-mono op70>
{{ item.humanDownloadsLast30Days }}
</td>
<td w-30 text-center>
Expand Down
2 changes: 1 addition & 1 deletion src/client/pages/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const showTabGroup = ref(false)
<div>
<VDarkToggle v-slot="{ toggle, isDark }">
<VButton n="primary" @click="toggle">
<div carbon-sun dark:carbon-moon translate-y--1px /> {{ isDark.value ? 'Dark' : 'Light' }}
<div carbon-sun translate-y--1px dark:carbon-moon /> {{ isDark.value ? 'Dark' : 'Light' }}
</VButton>
</VDarkToggle>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export interface DocumentInfo {
website: string
github: string
icon: string
tips: string
openInBlank: boolean
tips?: string
openInBlank?: boolean
}

export interface PackageInfo {
Expand Down

0 comments on commit 9d80bf0

Please sign in to comment.