mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-29 22:39:45 +08:00
实现简易的搜索功能
This commit is contained in:
45
feature/src/views/market/components/result.vue
Normal file
45
feature/src/views/market/components/result.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<div class="result">
|
||||
<PluginList
|
||||
v-if="result && !!result.length"
|
||||
@downloadSuccess="downloadSuccess"
|
||||
:title="$t('feature.market.searchResult')"
|
||||
:list="result"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import PluginList from './plugin-list.vue';
|
||||
|
||||
import { useStore } from 'vuex';
|
||||
const store = useStore();
|
||||
|
||||
const totalPlugins = computed(() => store.state.totalPlugins);
|
||||
const searchValue = computed(() => store.state.searchValue);
|
||||
|
||||
const result = computed(() => {
|
||||
if (searchValue.value.trim().length > 0) {
|
||||
const pattern = new RegExp(searchValue.value);
|
||||
return totalPlugins.value.filter((plugin) => {
|
||||
if (plugin.pluginName.match(pattern)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return totalPlugins.value;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.result {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
overflow-x: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user