Skip to content

Commit f40bdae

Browse files
authored
Merge pull request #4 from kongying-tavern/feat/next
fix: fix config input method and remove magic word
2 parents 0c8b94f + 0814489 commit f40bdae

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

src/shared/configSettings.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export enum ConfigInputMethodEnum {
2+
TEXT = "text",
3+
KEYBOARD = "keyboard",
4+
}
5+
6+
export type ConfigInputMethod =
7+
| ConfigInputMethodEnum.TEXT
8+
| ConfigInputMethodEnum.KEYBOARD;
9+
10+
export interface Config {
11+
inputMethod: ConfigInputMethod;
12+
keyTransform: boolean;
13+
}

src/shared/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from "./configSettings";
12
export * from "./keyboardLayout";

src/views/pageTypewriter/components/ConfigBar/ButtonInputMethod.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { computed } from "vue";
33
import SvgIcon from "@/components/SvgIcon.vue";
44
import ButtonBase from "./ButtonBase.vue";
55
import ButtonDropdown from "./ButtonDropdown.vue";
6+
import type { ConfigInputMethod } from "@/shared";
7+
import { ConfigInputMethodEnum } from "@/shared";
68
import { useConfig } from "../../hooks";
79
810
const iconBase = import.meta.url;
@@ -19,8 +21,16 @@ interface inputMethodOption {
1921
}
2022
2123
const inputMethodOptions: inputMethodOption[] = [
22-
{ icon: iconPathEnum.text, label: "文本输入", command: "text" },
23-
{ icon: iconPathEnum.keyboard, label: "键盘输入", command: "keyboard" },
24+
{
25+
icon: iconPathEnum.text,
26+
label: "文本输入",
27+
command: ConfigInputMethodEnum.TEXT,
28+
},
29+
{
30+
icon: iconPathEnum.keyboard,
31+
label: "键盘输入",
32+
command: ConfigInputMethodEnum.KEYBOARD,
33+
},
2434
];
2535
2636
const { config } = useConfig();
@@ -29,7 +39,9 @@ const iconPath = computed(() => {
2939
return iconPathEnum[config.value.inputMethod] || "";
3040
});
3141
32-
const changeInputMethod = (command: "text" | "keyboard" = "keyboard") => {
42+
const changeInputMethod = (
43+
command: ConfigInputMethod = ConfigInputMethodEnum.KEYBOARD
44+
) => {
3345
config.value.inputMethod = command;
3446
};
3547
</script>

src/views/pageTypewriter/hooks/useConfig.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
export interface Config {
2-
inputMethod: "text" | "keyboard";
3-
keyTransform: boolean;
4-
}
1+
import type { Config, ConfigInputMethod } from "@/shared";
52

63
const config: Ref<Config> = ref({
7-
inputMethod: "keyboard",
4+
inputMethod: "keyboard" as ConfigInputMethod,
85
keyTransform: true,
96
});
107

0 commit comments

Comments
 (0)