From 5db734eccebd4de233b8df3c85a95358a47d0af3 Mon Sep 17 00:00:00 2001 From: hegotit Date: Fri, 12 Jan 2024 16:00:49 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=93=9D?= =?UTF-8?q?=E5=A4=A9=E5=8F=8C=E6=8B=BC=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/spconfig.json | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/utils/spconfig.json b/src/utils/spconfig.json index ece5b23..dcad5af 100644 --- a/src/utils/spconfig.json +++ b/src/utils/spconfig.json @@ -400,5 +400,50 @@ "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" + ] } } From 8be7813e427350fc8661b8e4ee8dd3f159d20bde Mon Sep 17 00:00:00 2001 From: hegotit Date: Tue, 16 Jan 2024 16:33:18 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=A4=A7?= =?UTF-8?q?=E7=89=9B=E5=8F=8C=E6=8B=BC=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/keyboard.ts | 35 +++++++++++++++++++++-- src/utils/spconfig.json | 63 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/src/utils/keyboard.ts b/src/utils/keyboard.ts index fb6ef89..4253cc6 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, @@ -60,6 +72,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 +100,11 @@ export class ShuangpinConfig { const pinyins = product(leads, follows); for (const [l, f] of pinyins) { const pinyin = l + f; + 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 dcad5af..59091ab 100644 --- a/src/utils/spconfig.json +++ b/src/utils/spconfig.json @@ -445,5 +445,68 @@ "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" + ] } } From 2cfa875970d9f322ff4fdcb10b9c6fd2b065302f Mon Sep 17 00:00:00 2001 From: hegotit Date: Sat, 17 Feb 2024 22:50:26 +0800 Subject: [PATCH 3/4] refactor: eslint related --- src/components/Hanzi.vue | 1 - src/components/Keyboard.vue | 2 +- src/components/MenuList.vue | 2 +- src/components/Pinyin.vue | 3 +-- src/components/SingleMode.vue | 10 +++++----- src/env.d.ts | 8 ++++---- src/pages/FollowMode.vue | 2 +- src/pages/PragraphMode.vue | 1 - 8 files changed, 13 insertions(+), 16 deletions(-) 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"; From 4ebe73579437cfb39db7ad93ad722a263415e391 Mon Sep 17 00:00:00 2001 From: hegotit Date: Mon, 19 Feb 2024 11:46:35 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AF=B9=E9=9B=B6?= =?UTF-8?q?=E5=A3=B0=E6=AF=8D=E6=B1=89=E5=AD=97=E5=88=A4=E5=AE=9A=E4=B8=8D?= =?UTF-8?q?=E5=87=86=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/keyboard.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/keyboard.ts b/src/utils/keyboard.ts index 4253cc6..591b771 100644 --- a/src/utils/keyboard.ts +++ b/src/utils/keyboard.ts @@ -53,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(",") ?? [], @@ -100,6 +103,9 @@ 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; }