diff --git a/src/components/Hanzi.vue b/src/components/Hanzi.vue
index edbaee9..b6655d5 100644
--- a/src/components/Hanzi.vue
+++ b/src/components/Hanzi.vue
@@ -2,7 +2,6 @@
import { effect, ref } from "vue";
import { useStore } from "../store";
import { getPinyinOf } from "../utils/hanzi";
-import { randomChoice } from "../utils/number";
const props = defineProps<{
hanziSeq: string[];
diff --git a/src/components/Keyboard.vue b/src/components/Keyboard.vue
index f4052e3..14dea77 100644
--- a/src/components/Keyboard.vue
+++ b/src/components/Keyboard.vue
@@ -1,5 +1,5 @@
diff --git a/src/components/SingleMode.vue b/src/components/SingleMode.vue
index 342fdae..66995a1 100644
--- a/src/components/SingleMode.vue
+++ b/src/components/SingleMode.vue
@@ -12,7 +12,7 @@ import { computed } from "vue";
import { getPinyinOf } from "../utils/hanzi";
import { TypingSummary } from "../utils/summary";
import { followKeys, leadKeys } from "../utils/pinyin";
-import { randInt, randomChoice } from "../utils/number";
+import { randInt } from "../utils/number";
export interface SingleModeProps {
nextChar?: () => string;
@@ -21,7 +21,7 @@ export interface SingleModeProps {
mode?: "Lead" | "Follow";
}
-function nextChar() {
+function getNextChar() {
if (!props.mode) {
return props.nextChar?.() ?? "";
}
@@ -32,7 +32,7 @@ const pinyin = ref([]);
const store = useStore();
const props = defineProps();
-const hanziSeq = ref(new Array(4).fill(0).map(() => nextChar()));
+const hanziSeq = ref(new Array(4).fill(0).map(() => getNextChar()));
const isValid = ref(false);
const summary = ref(new TypingSummary());
@@ -78,7 +78,7 @@ function onMenuChange(i: number) {
watchPostEffect(() => {
for (let i = 0; i < 4; ++i) {
- hanziSeq.value.unshift(nextChar());
+ hanziSeq.value.unshift(getNextChar());
hanziSeq.value.pop();
}
});
@@ -132,7 +132,7 @@ function onSeq([lead, follow]: [string?, string?]) {
watchPostEffect(() => {
if (isValid.value) {
setTimeout(() => {
- hanziSeq.value.unshift(nextChar());
+ hanziSeq.value.unshift(getNextChar());
hanziSeq.value.pop();
pinyin.value = [];
isValid.value = false;
diff --git a/src/env.d.ts b/src/env.d.ts
index dc76cbb..1a1f5c7 100644
--- a/src/env.d.ts
+++ b/src/env.d.ts
@@ -39,10 +39,10 @@ declare type Char =
type Pinyin = { lead: string; follow: string; full: string };
interface Progress {
- currentIndex: number = 0;
- total: number = 0;
- correctTry: number = 0;
- totalTry: number = 0;
+ currentIndex: number;
+ total: number;
+ correctTry: number;
+ totalTry: number;
}
interface Combine {
diff --git a/src/pages/FollowMode.vue b/src/pages/FollowMode.vue
index 6b5f587..7bbfe67 100644
--- a/src/pages/FollowMode.vue
+++ b/src/pages/FollowMode.vue
@@ -2,7 +2,7 @@
import SingleMode from '../components/SingleMode.vue';
import { followMap, followKeys } from '../utils/pinyin'
import { useStore } from '../store'
-import { computed, ref } from 'vue';
+import { computed } from 'vue';
import { hanziMap } from '../utils/hanzi';
import { storeToRefs } from 'pinia';
diff --git a/src/pages/PragraphMode.vue b/src/pages/PragraphMode.vue
index 9206e11..7340075 100644
--- a/src/pages/PragraphMode.vue
+++ b/src/pages/PragraphMode.vue
@@ -8,7 +8,6 @@ import {
watchPostEffect,
onActivated,
onDeactivated,
- onMounted,
watchEffect,
} from "vue";
import { useStore } from "../store";
diff --git a/src/utils/keyboard.ts b/src/utils/keyboard.ts
index fb6ef89..591b771 100644
--- a/src/utils/keyboard.ts
+++ b/src/utils/keyboard.ts
@@ -14,11 +14,22 @@ declare global {
* ],
* zeroMap: [ // 零声母映射
* '${双拼按键}/${对应拼音}'
+ * ],
+ * additionalMap: [ // 附加映射
+ * '${双拼按键}/${对应拼音}'
+ * ],
+ * excludingMap: [ // 不匹配映射
+ * '${双拼按键}/${对应拼音}'
* ]
* }
* ```
*/
- type RawShuangPinConfig = typeof configs["小鹤双拼"];
+ type RawShuangPinConfig = {
+ keyMap: string[],
+ zeroMap: string[],
+ additionalMap?: string[],
+ excludingMap?: string[],
+ };
type ShuangpinMode = ShuangpinConfig;
}
@@ -33,6 +44,7 @@ export class ShuangpinConfig {
zero2sp = new Map(); // 双拼 -> 零声母
sp2py = new Map(); // 双拼 -> 拼音
py2sp = new Map(); // 拼音 -> 双拼
+ spNot2py = new Map(); // 不匹配映射:双拼 -> 拼音
constructor(
public name: string,
@@ -41,6 +53,9 @@ export class ShuangpinConfig {
) {
for (const line of config["keyMap"]) {
const [main, follow, lead] = line.split("/");
+ if (!follow && !lead) {
+ continue;
+ }
const keyConfig: KeyConfig = {
main: (main as Char) ?? "",
follows: follow?.split(",") ?? [],
@@ -60,6 +75,22 @@ export class ShuangpinConfig {
this.py2sp.set(zero, sp);
this.sp2py.set(sp, zero);
}
+ const additionalMap = config["additionalMap"];
+ if (additionalMap) {
+ for (const line of additionalMap) {
+ const [sp, pinyin] = line.split("/");
+ this.py2sp.set(pinyin, sp);
+ this.sp2py.set(sp, pinyin);
+ }
+ }
+
+ const excludingMap = config["excludingMap"];
+ if (excludingMap) {
+ for (const line of excludingMap) {
+ const [sp, pinyin] = line.split("/");
+ this.spNot2py.set(sp, pinyin);
+ }
+ }
const allCombs = product(
[...this.groupByKey.keys()],
@@ -72,8 +103,14 @@ export class ShuangpinConfig {
const pinyins = product(leads, follows);
for (const [l, f] of pinyins) {
const pinyin = l + f;
+ if (!(l && f)) {
+ continue;
+ }
+ if (pinyin == this.spNot2py.get(sp)) {
+ continue;
+ }
if (validCombines.has(pinyin)) {
- this.py2sp.set(pinyin, sp);
+ this.py2sp.set(pinyin, sp.concat(this.py2sp.get(pinyin) ?? ""));
this.sp2py.set(sp, pinyin);
}
}
diff --git a/src/utils/spconfig.json b/src/utils/spconfig.json
index ece5b23..59091ab 100644
--- a/src/utils/spconfig.json
+++ b/src/utils/spconfig.json
@@ -400,5 +400,113 @@
"oo/o",
"op/ou"
]
+ },
+ "蓝天双拼": {
+ "keyMap": [
+ "q/ua/q",
+ "w/ei/w",
+ "e/e/",
+ "r/ou/r",
+ "t/iu/t",
+ "y/ue,ve/y",
+ "u/u/sh",
+ "i/i/ch",
+ "o/uo,o/",
+ "p/ie/p",
+ "a/a/",
+ "s/iong,ong/s",
+ "d/ai/d",
+ "f/ing,uai/f",
+ "g/ang/g",
+ "h/uan/h",
+ "j/an/j",
+ "k/en,ia/k",
+ "l/iang,uang/l",
+ ";//",
+ "z/eng/z",
+ "x/in/x",
+ "c/ao/c",
+ "v/ui,v/zh",
+ "b/un/b",
+ "n/iao/n",
+ "m/ian/m"
+ ],
+ "zeroMap": [
+ "aa/a",
+ "ai/ai",
+ "an/an",
+ "ag/ang",
+ "ao/ao",
+ "ee/e",
+ "ei/ei",
+ "en/en",
+ "ez/eng",
+ "er/er",
+ "oo/o",
+ "ou/ou"
+ ]
+ },
+ "大牛双拼": {
+ "keyMap": [
+ "q/ua,ian/q",
+ "w/vn,ei/w",
+ "e/e/",
+ "r/ou/r",
+ "t/iu/t",
+ "y/un/y",
+ "u/u,er/sh",
+ "i/i/ch",
+ "o/o,uo/zh",
+ "p/ie/p",
+ "a/a/zh",
+ "s/ao/s",
+ "d/an/d",
+ "f/ang/f",
+ "g/uai,ing/g",
+ "h/ai,ue/h",
+ "j/eng,van/j",
+ "k/en,ia/k",
+ "l/ong,iong/l",
+ ";//",
+ "z/uan/z",
+ "x/ve,uang/x",
+ "c/ian/c",
+ "v/ui,v/sh",
+ "b/in/b",
+ "n/ui,iang/n",
+ "m/iao/m"
+ ],
+ "zeroMap": [
+ "ea/a",
+ "eh/ai",
+ "ed/an",
+ "ef/ang",
+ "es/ao",
+ "ee/e",
+ "ew/ei",
+ "ek/en",
+ "ej/eng",
+ "eu/er",
+ "eo/o",
+ "er/ou"
+ ],
+ "additionalMap": [
+ "jw/jun",
+ "qw/qun",
+ "xw/xun",
+ "yw/yun",
+ "jj/juan",
+ "qj/quan",
+ "xj/xuan",
+ "yj/yuan",
+ "jx/jue",
+ "qx/que",
+ "xx/xue",
+ "yx/yue",
+ "jv/ju",
+ "qv/qu",
+ "xv/xu",
+ "yv/yu"
+ ]
}
}