File size: 1,141 Bytes
755dd12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<script setup lang="ts">
import { useAppStore } from '../store';
import { SearXNGCategories } from '../contants';
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { TSearCategory } from '../interface';

const { t } = useI18n();

type Emits = {
  (e: 'change', val: TSearCategory): void;
}

const emits = defineEmits<Emits>();

const categories = SearXNGCategories.map(item => {
  return {
    name: item.displayName,
    value: item.name
  };
});
const appStore = useAppStore();

const value = ref(appStore.category);

const onCategoryChange = (val: any) => {
  appStore.updateCategory(val);
  emits('change', val);
};
</script>

<script lang="ts">
export default {
  name: 'SearchCategory'
};
</script>

<template>
  <div class="sear-category">
    <t-radio-group variant="default-filled" :default-value="value" @change="onCategoryChange">
      <t-radio-button v-for="item in categories" :key="item.value" :value="item.value">
        {{ t(item.name) }}
      </t-radio-button>
    </t-radio-group>
  </div>
</template>

<style scoped>
.sear-category {
 --td-radius-default: 20px;
 --td-radius-small: 20px;
}
</style>