Skip to content

Commit 402877b

Browse files
committed
EnumOption
1 parent ddf4766 commit 402877b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/BasicConfig.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { NAlert, NForm, NFormItem } from 'naive-ui'
44
import type { Config } from 'fcitx5-js'
55
import IntegerOption from './option/IntegerOption.vue'
66
import BooleanOption from './option/BooleanOption.vue'
7+
import EnumOption from './option/EnumOption.vue'
78
import UnknownOption from './option/UnknownOption.vue'
89
import { isMobile } from './util'
910
@@ -20,6 +21,8 @@ function toComponent(type: string) {
2021
return IntegerOption
2122
case 'Boolean':
2223
return BooleanOption
24+
case 'Enum':
25+
return EnumOption
2326
default:
2427
return UnknownOption
2528
}

src/option/EnumOption.vue

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script setup lang="ts">
2+
import { computed } from 'vue'
3+
import { NSelect } from 'naive-ui'
4+
5+
const props = defineProps<{
6+
config: {
7+
Enum: { [key: string]: string }
8+
EnumI18n: { [key: string]: string }
9+
}
10+
value: string
11+
onUpdate: (value: string) => void
12+
}>()
13+
14+
const options = computed(() => Object.entries(props.config.Enum).map(([key, value]) => ({
15+
label: props.config.EnumI18n[key],
16+
value,
17+
})))
18+
</script>
19+
20+
<template>
21+
<NSelect
22+
:value="value"
23+
:options="options"
24+
@update:value="v => onUpdate(v)"
25+
/>
26+
</template>

0 commit comments

Comments
 (0)