Skip to content

Commit 100f8d7

Browse files
committed
advanced config
1 parent dc5692a commit 100f8d7

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

src/AdvancedConfig.vue

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

src/SplitConfig.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function apply() {
4444
bordered
4545
collapse-mode="width"
4646
:collapsed="collapsed"
47+
:native-scrollbar="false"
4748
show-trigger
4849
style="max-height: calc(100vh - 100px)"
4950
@collapse="collapsed = true"

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export { default as InputMethodConfig } from './InputMethodConfig.vue'
22
export { default as GlobalConfig } from './GlobalConfig.vue'
33
export { default as ThemeConfig } from './ThemeConfig.vue'
4+
export { default as AdvancedConfig } from './AdvancedConfig.vue'
45
export { default as GearButton } from './GearButton.vue'

0 commit comments

Comments
 (0)