Skip to content

Commit

Permalink
EnumOption
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Sep 4, 2024
1 parent ddf4766 commit 402877b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/BasicConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NAlert, NForm, NFormItem } from 'naive-ui'
import type { Config } from 'fcitx5-js'
import IntegerOption from './option/IntegerOption.vue'
import BooleanOption from './option/BooleanOption.vue'
import EnumOption from './option/EnumOption.vue'
import UnknownOption from './option/UnknownOption.vue'
import { isMobile } from './util'
Expand All @@ -20,6 +21,8 @@ function toComponent(type: string) {
return IntegerOption
case 'Boolean':
return BooleanOption
case 'Enum':
return EnumOption
default:
return UnknownOption
}
Expand Down
26 changes: 26 additions & 0 deletions src/option/EnumOption.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script setup lang="ts">
import { computed } from 'vue'
import { NSelect } from 'naive-ui'
const props = defineProps<{
config: {
Enum: { [key: string]: string }
EnumI18n: { [key: string]: string }
}
value: string
onUpdate: (value: string) => void
}>()
const options = computed(() => Object.entries(props.config.Enum).map(([key, value]) => ({
label: props.config.EnumI18n[key],
value,
})))
</script>

<template>
<NSelect
:value="value"
:options="options"
@update:value="v => onUpdate(v)"
/>
</template>

0 comments on commit 402877b

Please sign in to comment.