Skip to content

Commit 5ba766a

Browse files
committed
global and theme config
1 parent d453914 commit 5ba766a

File tree

5 files changed

+111
-1
lines changed

5 files changed

+111
-1
lines changed

src/GlobalConfig.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script setup lang="ts">
2+
import SplitConfig from './SplitConfig.vue'
3+
4+
defineProps<{
5+
onClose: () => void
6+
}>()
7+
</script>
8+
9+
<template>
10+
<SplitConfig
11+
uri="fcitx://config/global"
12+
@close="onClose"
13+
/>
14+
</template>

src/InputMethodConfig.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function apply() {
202202
</NLayoutFooter>
203203
</NLayout>
204204
</NLayoutSider>
205-
<NLayout style="min-height: 480px; max-height: calc(100vh - 100px)">
205+
<NLayout style="height: calc(100vh - 100px)">
206206
<template v-if="adding">
207207
<div
208208
v-if="selectedLanguage === null"

src/SplitConfig.vue

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<script setup lang="ts">
2+
import { ref } from 'vue'
3+
import { NLayout, NLayoutFooter, NLayoutSider, NMenu } from 'naive-ui'
4+
import type { Config } from 'fcitx5-js'
5+
import BasicConfig from './BasicConfig.vue'
6+
import FooterButtons from './FooterButtons.vue'
7+
import { extractValue } from './util'
8+
9+
const props = defineProps<{
10+
uri: string
11+
onClose: () => void
12+
}>()
13+
14+
const index = ref(0)
15+
const config = {
16+
Children: [],
17+
...window.fcitx.getConfig(props.uri),
18+
}
19+
const options = config.Children.map((child, i) => ({
20+
key: i,
21+
label: child.Description,
22+
}))
23+
24+
const collapsed = ref(false)
25+
26+
function childToConfig(child: typeof config.Children[0]): Config {
27+
return { Children: child.Children || [] }
28+
}
29+
30+
const form = ref(extractValue(config, false))
31+
32+
function reset() {
33+
form.value[config.Children[index.value].Option] = extractValue(childToConfig(config.Children[index.value]), true)
34+
}
35+
36+
function apply() {
37+
window.fcitx.setConfig(props.uri, form.value)
38+
}
39+
</script>
40+
41+
<template>
42+
<NLayout has-sider>
43+
<NLayoutSider
44+
bordered
45+
collapse-mode="width"
46+
:collapsed="collapsed"
47+
show-trigger
48+
style="max-height: calc(100vh - 100px)"
49+
@collapse="collapsed = true"
50+
@expand="collapsed = false"
51+
>
52+
<NMenu
53+
v-model:value="index"
54+
:options="options"
55+
/>
56+
</NLayoutSider>
57+
<NLayout style="height: calc(100vh - 100px)">
58+
<NLayout
59+
position="absolute"
60+
:native-scrollbar="false"
61+
style="bottom: 50px"
62+
>
63+
<BasicConfig
64+
:path="config.Children[index].Option"
65+
:config="childToConfig(config.Children[index])"
66+
:value="form[config.Children[index].Option]"
67+
style="margin: 16px"
68+
@update="v => form[config.Children[index].Option] = v"
69+
/>
70+
</NLayout>
71+
<NLayoutFooter position="absolute">
72+
<FooterButtons
73+
:reset="reset"
74+
:apply="apply"
75+
:close="onClose"
76+
/>
77+
</NLayoutFooter>
78+
</NLayout>
79+
</NLayout>
80+
</template>

src/ThemeConfig.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script setup lang="ts">
2+
import SplitConfig from './SplitConfig.vue'
3+
4+
defineProps<{
5+
onClose: () => void
6+
}>()
7+
</script>
8+
9+
<template>
10+
<SplitConfig
11+
uri="fcitx://config/addon/webpanel"
12+
@close="onClose"
13+
/>
14+
</template>

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export { default as InputMethodConfig } from './InputMethodConfig.vue'
2+
export { default as GlobalConfig } from './GlobalConfig.vue'
3+
export { default as ThemeConfig } from './ThemeConfig.vue'
24
export { default as GearButton } from './GearButton.vue'

0 commit comments

Comments
 (0)