Skip to content

Commit 5960f81

Browse files
committed
mobile adaption: global and theme
1 parent cdb3e31 commit 5960f81

File tree

4 files changed

+57
-24
lines changed

4 files changed

+57
-24
lines changed

src/AdvancedConfig.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@ function selectAddon(item: string) {
5454
:options="options"
5555
@update-value="selectAddon"
5656
/>
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>
57+
<BasicConfig
58+
v-else
59+
:path="addon"
60+
:config="manager.config"
61+
:value="manager.form.value"
62+
style="margin: 16px"
63+
@update="(v) => manager.set(v)"
64+
/>
6665
</NScrollbar>
6766
<FooterButtons
6867
v-if="mobileState === 'DETAIL'"

src/GlobalConfig.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<script setup lang="ts">
22
import SplitConfig from './SplitConfig.vue'
3-
4-
defineProps<{
5-
onClose: () => void
6-
}>()
73
</script>
84

95
<template>
106
<SplitConfig
117
uri="fcitx://config/global"
12-
@close="onClose"
138
/>
149
</template>

src/SplitConfig.vue

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
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
89
const props = defineProps<{
910
uri: string
10-
onClose: () => void
11+
}>()
12+
13+
const emit = defineEmits<{
14+
close: []
15+
updateTitle: [string]
1116
}>()
1217
1318
const options = { Children: [], ...window.fcitx.getConfig(props.uri) }.Children.map((child, i) => ({
@@ -19,10 +24,49 @@ const index = ref(0)
1924
const manager = computed(() => new ConfigManager(props.uri, index.value))
2025
2126
const collapsed = ref(false)
27+
28+
const mobileState = ref<'LIST' | 'DETAIL'>('LIST')
29+
30+
watchEffect(() => {
31+
let title = ''
32+
if (isMobile.value && mobileState.value === 'DETAIL') {
33+
title = options[index.value].label
34+
}
35+
emit('updateTitle', title)
36+
})
37+
38+
function selectIndex(i: number) {
39+
index.value = i
40+
mobileState.value = 'DETAIL'
41+
}
2242
</script>
2343

2444
<template>
25-
<NLayout has-sider>
45+
<div v-if="isMobile" style="display: flex; flex-direction: column; height: 100%">
46+
<NScrollbar>
47+
<NMenu
48+
v-if="mobileState === 'LIST'"
49+
:value="index"
50+
:options="options"
51+
@update-value="selectIndex"
52+
/>
53+
<BasicConfig
54+
v-else
55+
:path="{ Option: '', ...manager.config }.Option"
56+
:config="manager.config"
57+
:value="manager.form.value"
58+
style="margin: 16px"
59+
@update="(v) => manager.set(v)"
60+
/>
61+
</NScrollbar>
62+
<FooterButtons
63+
v-if="mobileState === 'DETAIL'"
64+
is-return
65+
:manager="manager"
66+
@close="mobileState = 'LIST'"
67+
/>
68+
</div>
69+
<NLayout v-else has-sider>
2670
<NLayoutSider
2771
bordered
2872
collapse-mode="width"
@@ -55,7 +99,7 @@ const collapsed = ref(false)
5599
<NLayoutFooter position="absolute">
56100
<FooterButtons
57101
:manager="manager"
58-
@close="onClose"
102+
@close="emit('close')"
59103
/>
60104
</NLayoutFooter>
61105
</NLayout>

src/ThemeConfig.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<script setup lang="ts">
22
import SplitConfig from './SplitConfig.vue'
3-
4-
defineProps<{
5-
onClose: () => void
6-
}>()
73
</script>
84

95
<template>
106
<SplitConfig
117
uri="fcitx://config/addon/webpanel"
12-
@close="onClose"
138
/>
149
</template>

0 commit comments

Comments
 (0)