File size: 1,134 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 { SearchMode } from '../contants';
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { TSearchMode } from '../interface';

const { t } = useI18n();

type Emits = {
  (e: 'change', val: TSearchMode): void
}
const emits = defineEmits<Emits>();

const modes = SearchMode.map(item => {
  return {
    name: item.displayName,
    value: item.name,
    disabled: item.disabled
  };
});
const appStore = useAppStore();

const value = ref(appStore.mode);

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

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

<template>
  <div class="search-mode">
    <t-radio-group variant="primary-filled" :default-value="value" @change="onChange">
      <t-radio-button v-for="item in modes" :key="item.value" :disabled="item.disabled" :value="item.value">
        {{ t(item.name) }}
      </t-radio-button>
    </t-radio-group>
  </div>
</template>

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