-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4efdda
commit 0ecf114
Showing
10 changed files
with
168 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<script setup lang="ts"> | ||
import { NButton, NFlex } from 'naive-ui' | ||
defineProps<{ | ||
reset: () => void | ||
close: () => void | ||
apply: () => void | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<NFlex | ||
style="padding: 8px; justify-content: space-between" | ||
> | ||
<NFlex> | ||
<NButton | ||
secondary | ||
@click="reset" | ||
> | ||
Reset to default | ||
</NButton> | ||
<NButton | ||
secondary | ||
@click="close" | ||
> | ||
Cancel | ||
</NButton> | ||
</NFlex> | ||
<NFlex> | ||
<NButton | ||
secondary | ||
@click="apply" | ||
> | ||
Apply | ||
</NButton> | ||
<NButton | ||
secondary | ||
type="info" | ||
@click="apply(); close()" | ||
> | ||
OK | ||
</NButton> | ||
</NFlex> | ||
</NFlex> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script setup lang="ts"> | ||
import { NButton, NIcon } from 'naive-ui' | ||
import GearIcon from './GearIcon.vue' | ||
</script> | ||
|
||
<template> | ||
<NButton secondary> | ||
<template #icon> | ||
<NIcon> | ||
<GearIcon /> | ||
</NIcon> | ||
</template> | ||
</NButton> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script lang="ts"> | ||
export default { | ||
name: 'MdiCog', | ||
} | ||
</script> | ||
|
||
<template> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M12 15.5A3.5 3.5 0 0 1 8.5 12A3.5 3.5 0 0 1 12 8.5a3.5 3.5 0 0 1 3.5 3.5a3.5 3.5 0 0 1-3.5 3.5m7.43-2.53c.04-.32.07-.64.07-.97s-.03-.66-.07-1l2.11-1.63c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.31-.61-.22l-2.49 1c-.52-.39-1.06-.73-1.69-.98l-.37-2.65A.506.506 0 0 0 14 2h-4c-.25 0-.46.18-.5.42l-.37 2.65c-.63.25-1.17.59-1.69.98l-2.49-1c-.22-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64L4.57 11c-.04.34-.07.67-.07 1s.03.65.07.97l-2.11 1.66c-.19.15-.25.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1.01c.52.4 1.06.74 1.69.99l.37 2.65c.04.24.25.42.5.42h4c.25 0 .46-.18.5-.42l.37-2.65c.63-.26 1.17-.59 1.69-.99l2.49 1.01c.22.08.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64z" /></svg> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as InputMethodConfig } from './InputMethodConfig.vue' | ||
export { default as GearButton } from './GearButton.vue' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<script setup lang="ts"> | ||
import { h, ref } from 'vue' | ||
import { useDialog } from 'naive-ui' | ||
import GearButton from '../GearButton.vue' | ||
import BasicConfig from '../BasicConfig.vue' | ||
import FooterButtons from '../FooterButtons.vue' | ||
import { extractValue } from '../util' | ||
const props = defineProps<{ | ||
config: { | ||
Description: string | ||
External: string | ||
Option: string | ||
LaunchSubConfig?: string | ||
} | ||
}>() | ||
const dialog = useDialog() | ||
const form = ref({}) | ||
function click() { | ||
switch (props.config.Option) { | ||
default: | ||
if (props.config.LaunchSubConfig === 'True') { | ||
const config = window.fcitx.getConfig(props.config.External) | ||
form.value = extractValue(config, false) | ||
const instance = dialog.info({ | ||
title: props.config.Description, | ||
content: () => h(BasicConfig, { | ||
path: props.config.Option, | ||
config, | ||
value: form.value, | ||
onUpdate(v) { | ||
form.value = v | ||
}, | ||
}), | ||
action: () => h(FooterButtons, { | ||
reset() { | ||
form.value = extractValue(config, true) | ||
}, | ||
close() { | ||
instance.destroy() | ||
}, | ||
apply() { | ||
window.fcitx.setConfig(props.config.External, form.value) | ||
}, | ||
}), | ||
}) | ||
} | ||
else { | ||
dialog.error({ | ||
title: 'Error', | ||
content: `Unknown External Option: ${props.config.Option}`, | ||
positiveText: 'OK', | ||
}) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<GearButton @click="click" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
import { computed } from 'vue' | ||
import { useBreakpoint } from 'vooks' | ||
import type { Config } from 'fcitx5-js' | ||
|
||
const breakpoint = useBreakpoint() | ||
export const isMobile = computed(() => breakpoint.value === 'xs' || breakpoint.value === 's') | ||
|
||
export function extractValue(config: Config, reset: boolean) { | ||
const value: { [key: string]: any } = {} | ||
if ('Children' in config) { | ||
for (const child of config.Children) { | ||
value[child.Option] = reset | ||
? ( | ||
'DefaultValue' in child ? child.DefaultValue : extractValue(child, true) | ||
) | ||
: child.Value | ||
} | ||
} | ||
return value | ||
} |