Skip to content

Commit cdb3e31

Browse files
committed
mobile adaption: advanced
1 parent 5ca119f commit cdb3e31

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

src/AdvancedConfig.vue

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<script setup lang="ts">
2-
import { NLayout, NLayoutFooter, NLayoutSider, NMenu } from 'naive-ui'
3-
import { computed, ref } from 'vue'
2+
import { NLayout, NLayoutFooter, NLayoutSider, NMenu, NScrollbar } from 'naive-ui'
3+
import { computed, ref, watchEffect } from 'vue'
44
import BasicConfig from './BasicConfig.vue'
55
import FooterButtons from './FooterButtons.vue'
66
import { ConfigManager } from './manager'
7+
import { isMobile } from './util'
78
8-
defineProps<{
9-
onClose: () => void
9+
const emit = defineEmits<{
10+
close: []
11+
updateTitle: [string]
1012
}>()
1113
1214
const options = window.fcitx.getAddons().map(category => ({
@@ -19,15 +21,57 @@ const options = window.fcitx.getAddons().map(category => ({
1921
})),
2022
}))
2123
24+
const addonNameMap = options.flatMap(option => option.children).reduce<Record<string, string>>((acc, value) => ({ ...acc, [value.key]: value.label }), {})
25+
2226
const addon = ref(options[0].children[0].key)
2327
2428
const manager = computed(() => new ConfigManager(`fcitx://config/addon/${addon.value}`))
2529
2630
const collapsed = ref(false)
31+
32+
const mobileState = ref<'DETAIL' | 'LIST'>('LIST')
33+
34+
watchEffect(() => {
35+
let title = ''
36+
if (isMobile.value && mobileState.value === 'DETAIL') {
37+
title = addonNameMap[addon.value]
38+
}
39+
emit('updateTitle', title)
40+
})
41+
42+
function selectAddon(item: string) {
43+
addon.value = item
44+
mobileState.value = 'DETAIL'
45+
}
2746
</script>
2847

2948
<template>
30-
<NLayout has-sider>
49+
<div v-if="isMobile" style="display: flex; flex-direction: column; height: 100%">
50+
<NScrollbar>
51+
<NMenu
52+
v-if="mobileState === 'LIST'"
53+
:value="addon"
54+
:options="options"
55+
@update-value="selectAddon"
56+
/>
57+
<template v-else>
58+
<BasicConfig
59+
:path="addon"
60+
:config="manager.config"
61+
:value="manager.form.value"
62+
style="margin: 16px"
63+
@update="(v) => manager.set(v)"
64+
/>
65+
</template>
66+
</NScrollbar>
67+
<FooterButtons
68+
v-if="mobileState === 'DETAIL'"
69+
is-return
70+
:manager="manager"
71+
@close="mobileState = 'LIST'"
72+
/>
73+
</div>
74+
<NLayout v-else has-sider>
3175
<NLayoutSider
3276
bordered
3377
collapse-mode="width"
@@ -60,7 +104,7 @@ const collapsed = ref(false)
60104
<NLayoutFooter position="absolute">
61105
<FooterButtons
62106
:manager="manager"
63-
@close="onClose"
107+
@close="emit('close')"
64108
/>
65109
</NLayoutFooter>
66110
</NLayout>

src/InputMethodConfig.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ const filteredLanguageOptions = computed(() => {
310310
</NFlex>
311311
<NFlex
312312
v-else-if="mobileState === 'LANG_DETAIL'"
313-
style="padding: 8px; justify-content: space-between"
313+
style="padding-top: 8px; justify-content: space-between"
314314
>
315315
<NButton secondary @click="cancelAddingIM">
316316
{{ t('Cancel') }}

0 commit comments

Comments
 (0)