Skip to content

Commit

Permalink
feat(search): support proxy search
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqVictor committed Sep 27, 2023
1 parent 29362c6 commit 10c77c7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/components/MirrorList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ import RightSideBar from '@/views/sidebar/RightSideBar.vue'
import { MirrorItem, MirrorViewItem } from '@/types/MirrorItem'
import { mirrorViewShim } from '@/utils/shims'
const compareByName = (a: MirrorViewItem, b: MirrorViewItem) => a.alias === b.alias ? 0 : (a.alias > b.alias ? 1 : -1)
const compareByName = (a: MirrorViewItem, b: MirrorViewItem) => {
const valA = a.alias || a.id
const valB = a.alias || a.id
return valA === valB ? 0 : (valA > valB ? 1 : -1)
}
const searchFilter = (mirrorQ: string) => {
return (value: MirrorViewItem) =>
value.status !== 'paused' && (value.alias || value.id).toLocaleLowerCase().includes(mirrorQ.toLocaleLowerCase())
}
export default defineComponent({
name: 'MirrorList',
Expand All @@ -67,12 +76,10 @@ export default defineComponent({
},
computed: {
mirrorDataFilter () {
return (this.mirrorData as MirrorViewItem[]).sort(compareByName).filter(
value => value.status !== 'paused' && (value.alias || value.id).toLocaleLowerCase().includes(this.mirrorQ.toLocaleLowerCase())
)
return (this.mirrorData as MirrorViewItem[]).sort(compareByName).filter(searchFilter(this.mirrorQ))
},
proxyDataFilter () {
return (this.proxyData as MirrorViewItem[]).sort(compareByName)
return (this.proxyData as MirrorViewItem[]).sort(compareByName).filter(searchFilter(this.mirrorQ))
}
},
created () {
Expand Down

0 comments on commit 10c77c7

Please sign in to comment.