Files
rubick/feature/src/views/market/components/result.vue
2024-02-20 18:07:19 +08:00

58 lines
1.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="result">
<PluginList
v-if="result && !!result.length"
@downloadSuccess="downloadSuccess"
:title="$t('feature.market.searchResult')"
:list="result"
/>
<a-result
class="error-content"
v-else
sub-title="哎呀暂时还没有这个插件哟"
>
<template #icon>
<Vue3Lottie :animationData="emptyJson" :height="240" :width="240" />
</template>
</a-result>
</div>
</template>
<script setup>
import { computed } from 'vue';
import emptyJson from '@/assets/lottie/empty.json';
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.toLowerCase());
return totalPlugins.value.filter((plugin) => {
if (plugin.pluginName.toLowerCase().match(pattern)) {
return true;
} else {
return false;
}
});
} else {
return totalPlugins.value;
}
});
</script>
<style lang="less">
.result {
width: 100%;
overflow-x: hidden;
box-sizing: border-box;
.error-content {
padding-top: 40px;
}
}
</style>