ModelDropdown.vue 853 Bytes
Newer Older
LiangLiu's avatar
LiangLiu committed
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
<template>
  <DropdownMenu
    :items="modelItems"
    :selected-value="selectedModel"
    :placeholder="t('selectModel')"
    :empty-message="t('selectTaskTypeFirst')"
    @select-item="handleSelectModel"
  />
</template>

<script setup>
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import DropdownMenu from './DropdownMenu.vue'

const { t } = useI18n()

// Props
const props = defineProps({
  availableModels: {
    type: Array,
    default: () => []
  },
  selectedModel: {
    type: String,
    default: ''
  }
})

// Emits
const emit = defineEmits(['select-model'])

// Computed
const modelItems = computed(() => {
  return props.availableModels.map(model => ({
    value: model,
    label: model,
    icon: 'fas fa-cog'
  }))
})

// Methods
const handleSelectModel = (item) => {
  emit('select-model', item.value)
}
</script>