From 2d48c2462d3e87d48ed45c5008651f5de1f8beb7 Mon Sep 17 00:00:00 2001 From: theajack <1506282385@qq.com> Date: Sun, 9 Apr 2023 11:44:28 +0800 Subject: [PATCH] feat: v3.2.4 done --- README.md | 29 ++++++--- helper/README.en.md | 20 ++++++ helper/README.md | 19 ++++++ helper/version.md | 16 ++++- src/cnchar-types/plugin/code/index.d.ts | 23 ++++--- src/cnchar/main/dict/spell-default.json | 3 +- src/cnchar/main/dict/spell-dict-jian.json | 8 +-- src/cnchar/main/utils/tool.ts | 2 +- src/cnchar/plugin/code/code.ts | 35 ++++++++--- src/cnchar/plugin/info/info.ts | 2 +- src/cnchar/plugin/radical/dict/radicals.json | 10 +-- src/cnchar/plugin/radical/index.ts | 14 ++++- src/cnchar/plugin/radical/radical.ts | 50 ++++++++++++++- .../plugin/trad/dict/radicals-trad.json | 2 +- vuepress/.vuepress/components/codebox.vue | 23 +++++-- vuepress/.vuepress/components/home.vue | 27 +++++++- vuepress/doc/code.md | 39 +++++++++--- vuepress/doc/radical.md | 61 ++++++++++++++++++- vuepress/guide/donate.md | 29 ++++++++- vuepress/guide/version.md | 17 ++++++ vuepress/src/util.js | 39 +++--------- 21 files changed, 376 insertions(+), 92 deletions(-) diff --git a/README.md b/README.md index c5b2f806..ae965d9d 100644 --- a/README.md +++ b/README.md @@ -71,13 +71,13 @@ 注:最新统计时间为 2023/04/08,总金额=32元 -| 昵称 | 金额(元) | 时间 | 留言 | 渠道 | -|:--:|:--:|:--:|:--:|:--:| -| 普通的disco | 20 | 2023/04/01 | 大佬开源维护不易,加油!希望能有部首查字的功能~ | 微信赞赏码 | -| mango | 5 | 2023/02/10 | - | 微信赞赏码 | -| 阿炜 | 5 | 2022/11/11 | 阿炜ky2700 | 微信赞赏码 | -| slako | 1 | 2022/10/20 | 不明觉厉 | 微信赞赏码 | -| 王三金 | 1 | 2022/10/16 | - | 微信赞赏码 | +| 昵称 | 金额(元) | 时间 | 留言 | 渠道 | 作者备注 | +|:--:|:--:|:--:|:--:|:--:|:--:| +| 普通的disco | 20 | 2023/04/01 | 大佬开源维护不易,加油!希望能有部首查字的功能~ | 微信赞赏码 |v3.2.4中已增加该功能| +| mango | 5 | 2023/02/10 | - | 微信赞赏码 | | +| 阿炜 | 5 | 2022/11/11 | 阿炜ky2700 | 微信赞赏码 | | +| slako | 1 | 2022/10/20 | 不明觉厉 | 微信赞赏码 | | +| 王三金 | 1 | 2022/10/16 | - | 微信赞赏码 | | --- @@ -87,7 +87,8 @@ - [应用例子](#应用例子) -- [赞助](#赞助) +- [赞赏](#赞赏) +- [赞赏记录](#赞赏记录) - [前言](#前言) - [0.快速使用](#0快速使用) - [1.功能](#1功能) @@ -794,6 +795,8 @@ cnchar.strokeToWord(1, 'array'); // 返回 ['一', '乙'] #### 5.7 成语功能 +(在线文档)[https://theajack.github.io/cnchar/doc/idiom.html] + cnchar在2.2.0加入了成语功能,启用该功能需要安装 `cnchar-idiom` 功能库,该库可以独立于cnchar主库运行 使用方式如下: @@ -819,6 +822,8 @@ cnchar.idiom('shang4'); // ["上兵伐谋", "上不着天,下不着地", ... ] #### 5.8 歇后语功能 +(在线文档)[https://theajack.github.io/cnchar/doc/xhy.html] + cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库,该库可以独立于cnchar主库运行 使用方式如下: @@ -844,6 +849,8 @@ cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥 #### 5.9 偏旁部首功能 +(在线文档)[https://theajack.github.io/cnchar/doc/radical.html] + cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库,该库可以独立于cnchar主库运行 且于 3.2.0 版本进行了升级,支持了查询汉字结构和偏旁笔画数 @@ -864,6 +871,8 @@ cnchar.radical(text:string | Array): Array<{ #### 5.10 组词功能 +(在线文档)[https://theajack.github.io/cnchar/doc/words.html] + cnchar 在 3.1.0 加入了组词功能,需要安装 `cnchar-words`, 具体使用如下 args 传入 trad 可以查询繁体字,但是依赖于安装了 cnchar-trad @@ -883,6 +892,8 @@ cnchar.words.addWords('你们好'); // 添加一个词组 #### 5.11 查询解释功能 +(在线文档)[https://theajack.github.io/cnchar/doc/explain.html] + cnchar 在 3.1.0 加入了查询解释功能,需要安装 `cnchar-explain`, 具体使用如下 args 传入 trad 可以查询繁体字,但是依赖于安装了 cnchar-trad @@ -905,6 +916,8 @@ cnchar.explain.addExplain({ #### 5.12 发音、语音合成和语音识别 +(在线文档)[https://theajack.github.io/cnchar/doc/voice.html] + cnchar 在 3.1.0 加入了发音、语音合成和语音识别功能, 需要安装 `cnchar-voice`, ##### 5.12.1 voice api diff --git a/helper/README.en.md b/helper/README.en.md index a7f56108..bada162f 100644 --- a/helper/README.en.md +++ b/helper/README.en.md @@ -41,6 +41,26 @@ Before starting the documentation, let's take a look at some use cases to see wh [Chinese character typing game](https://theajack.github.io/type/) | [Typing and playing the piano](https://theajack.github.io/piano/) | [Idiom Solitaire](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/idiom.js) | [Address Book Sort](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/sort.js) | [name](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/name.js) | [input method](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/input.js) | [Xie Houyu](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/xhy.js) | [Speech Recognition and Synthesis](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/voice.js) | [Simplified and Traditional Conversion](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/trad.js) +### Appreciation + +Open source maintenance is not easy. If the project is helpful to you and you have spare energy, you can scan the code on WeChat and ask the author to drink a cup of cola or coffee, thank you very much! + +If you donate, please leave a personal address on GitHub, which will be displayed on this page later. + + + +### Appreciation records + +Note: The latest statistical time is 2023/04/08, total amount = 32 yuan + +| Nickname | Amount (yuan) | Time | Message | Channel | +|:--:|:--:|:--:|:--:|:--:| +| 普通的disco | 20 | 2023/04/01 | 大佬开源维护不易,加油!希望能有部首查字的功能~ | 微信赞赏码 | +| mango | 5 | 2023/02/10 | - | 微信赞赏码 | +| 阿炜 | 5 | 2022/11/11 | 阿炜ky2700 | 微信赞赏码 | +| slako | 1 | 2022/10/20 | 不明觉厉 | 微信赞赏码 | +| 王三金 | 1 | 2022/10/16 | - | 微信赞赏码 | + ---
diff --git a/helper/README.md b/helper/README.md index 7aee7c08..3c5c6265 100644 --- a/helper/README.md +++ b/helper/README.md @@ -42,6 +42,25 @@ [汉字打字游戏](https://theajack.github.io/type/) | [打字弹钢琴](https://theajack.github.io/piano/) | [成语接龙](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/idiom.js) | [通讯录排序](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/sort.js) | [取名字](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/name.js) | [输入法](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/input.js) | [歇后语](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/xhy.js) | [语音识别与合成](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/voice.js) | [简繁体转换](https://theajack.github.io/jsbox/?github=theajack.cnchar@master.helper/jsbox/trad.js) +### 赞赏 + +开源维护不易。如果该项目对您有帮助且您有余力,可以微信扫码请作者喝一杯可乐或咖啡,非常感谢! + +如捐赠,请备注留一下github个人地址,后续会展示在此页中。 + + + +### 赞赏记录 + +注:最新统计时间为 2023/04/08,总金额=32元 + +| 昵称 | 金额(元) | 时间 | 留言 | 渠道 | +|:--:|:--:|:--:|:--:|:--:| +| 普通的disco | 20 | 2023/04/01 | 大佬开源维护不易,加油!希望能有部首查字的功能~ | 微信赞赏码 | +| mango | 5 | 2023/02/10 | - | 微信赞赏码 | +| 阿炜 | 5 | 2022/11/11 | 阿炜ky2700 | 微信赞赏码 | +| slako | 1 | 2022/10/20 | 不明觉厉 | 微信赞赏码 | +| 王三金 | 1 | 2022/10/16 | - | 微信赞赏码 | --- diff --git a/helper/version.md b/helper/version.md index ccde7684..d5e87caf 100644 --- a/helper/version.md +++ b/helper/version.md @@ -1,8 +1,22 @@ -## 3.2.4 todo +## TodoList 1. 拼音联想输入法权重调整 2. 语音识别 优化 3. writer 加上canvas渲染 +4. 注音支持多音字 +5. 新增cnchar-input-ui插件(输入法ui支持) +6. 查询包含某个汉字(笔画序列)的所有汉字【如根据斌字查到赟】 +7. 判断某个汉字是否包含某个汉字【如赟字是否包含斌】 + +## 3.2.4 + +1. fix: cnchar.spell('洗', 'flat') 参数有bug +2. fix: Cnchar 猫 字默认读音 +3. fix: 娘字读音有误 +4. fix: 钱字部首查不到,笔、画二字部首有误 +5. 增加通过部首查询 +6. cnchar-code 增加五笔码 +7. 文档首页增加部首展示和五笔展示 ## 3.2.3 diff --git a/src/cnchar-types/plugin/code/index.d.ts b/src/cnchar-types/plugin/code/index.d.ts index 49a9a9ae..5cfdc297 100644 --- a/src/cnchar-types/plugin/code/index.d.ts +++ b/src/cnchar-types/plugin/code/index.d.ts @@ -1,3 +1,8 @@ +/* + * @Author: chenzhongsheng + * @Date: 2022-10-09 09:18:54 + * @Description: Coding something + */ import {Json} from '../../main/common'; import {ICnChar} from '../../main'; // ! important for declare module '../../main/index' @@ -13,18 +18,20 @@ export interface ICodeResult extends IDictCodeResult { unicode: string; url: string; gbk: string; + fiveStroke: string; } export interface ICode { (input: string): ICodeResult[]; // 解码时 word传入code 请以空格分割 - binary(word: string, decoce?: boolean): string; - char(word: string, decoce?: boolean): string; - unicode(word: string, decoce?: boolean): string; - url(word: string, decoce?: boolean): string; - gbk(word: string, decoce?: boolean): string; - sijiao(word: string, decoce?: boolean): string; - cangjie(word: string, decoce?: boolean): string; - uniform(word: string, decoce?: boolean): string; + binary(word: string, decode?: boolean): string; + char(word: string, decode?: boolean): string; + unicode(word: string, decode?: boolean): string; + url(word: string, decode?: boolean): string; + gbk(word: string, decode?: boolean): string; + sijiao(word: string, decode?: boolean): string; + cangjie(word: string, decode?: boolean): string; + uniform(word: string, decode?: boolean): string; + fiveStroke(word: string, type?: '86'|'98'|'all'): string[]; setCode(words: string | Json, data?: IDictCodeResult): void; dict: {code: Json}; } diff --git a/src/cnchar/main/dict/spell-default.json b/src/cnchar/main/dict/spell-default.json index 4b50a445..cc9c4f30 100644 --- a/src/cnchar/main/dict/spell-default.json +++ b/src/cnchar/main/dict/spell-default.json @@ -132,6 +132,5 @@ "蹲": "dūn", "靚": "liàng", "刹": "shā", - "彷": "páng", - "风": "fēng" + "彷": "páng" } \ No newline at end of file diff --git a/src/cnchar/main/dict/spell-dict-jian.json b/src/cnchar/main/dict/spell-dict-jian.json index 4330c5c0..aaa35ce0 100644 --- a/src/cnchar/main/dict/spell-dict-jian.json +++ b/src/cnchar/main/dict/spell-dict-jian.json @@ -85,7 +85,7 @@ "chou": "2:丑3仇7抽1俦2帱7臭9惆2绸2畴2愁2稠2筹2酬2瞅3踌2瘳1雠2", "zhuan": "3:专1传9沌9转9转8砖1啭4赚9撰4篆4颛1馔4", "zhong": "2:中6中9仲4众4忪6忠1终1肿3盅1种9种8重9钟1冢3舯1衷1锺1踵3螽1塚3", - "feng": "1:丰1凤4风9风8风6冯7讽3沣1奉4枫1封1疯1砜1俸4峰1逢2唪3烽1葑9葑6锋1缝7缝9蜂1酆1峯1", + "feng": "1:丰1凤4风6风9风8冯7讽3沣1奉4枫1封1疯1砜1俸4峰1逢2唪3烽1葑9葑6锋1缝7缝9蜂1酆1峯1", "dan": "1:丹1旦4石9但4单6担9担6诞4眈1胆3疸8耽1郸1啖4弹9惮9掸8淡4聃1萏4蛋4殚1氮4赕3瘅9瘅6箪1儋9儋6澹9疍4", "shan": "2:山1讪4闪3汕4删1杉6芟1单9姗1疝4苫9苫6衫1钐9钐6陕3栅6珊1舢1剡9扇9扇6掸9掺8掺6善4禅9跚1骟4煽1鄯4潸1缮4嬗4擅4膳4膻1赡4蟮4鳝4", "zhi": "2:之1支1止3氏6卮1只8只6汁1执2旨3至4芝1吱6址3志4忮4纸3芷3识9豸4侄2制4帙4帜4枝1治4炙4直2知1祉3织9织6肢1质4郅4咫3峙9指3枳3栀1栉4祗1胝1轵3陟4值2挚4桎4秩4脂1致4贽4轾4埴2掷4痔4窒4职2趾3鸷4彘4智4植2殖7滞4痣4絷2蛭4跖2骘4黹3稚4置4酯3雉4摭2蜘1徵3膣4觯4踬4踯2製4", @@ -141,7 +141,7 @@ "zhun": "2:屯6肫1窀1准3谆1", "hai": "1:亥4还7咳7咳6孩2骇4害9氦4海3胲3嗨6骸2醢3", "huan": "2:幻4欢1奂4还7环2郇7宦4洹2唤4换4桓2浣4涣4眩9患4焕4萑2逭4痪4缓3豢4漶4锾2鲩4圜7寰2擐4缳2獾1鬟2鹮2嬛2", - "nian": "2:廿4年2念4拈1娘4埝4捻8粘7辇3鲇2蔫1辗8撵3碾3鲶2黏2", + "nian": "2:廿4年2念4拈1埝4捻8粘7辇3鲇2蔫1辗8撵3碾3鲶2黏2", "kai": "1:开1忾4凯3剀3垲3恺3铠3慨3揩1蒈3锎1楷8锴3闿3", "xin": "1:心1囟4忻1芯9芯6辛1昕1欣1信4莘6衅4锌1新1歆1薪1镡2馨1鑫1炘1", "shou": "2:手3守3收1寿4受4狩4首3兽4售4授4绶4瘦4熟7艏3", @@ -154,7 +154,7 @@ "ri": "1:日4", "yue": "2:曰1月4乐9刖4约6岳4哕8栎9说9钥9悦4钺4阅4跃4粤4越4樾4龠4瀹4玥4戉4", "mu": "1:木4仫4母3目4牟9亩3沐4牡3坶4姆3拇3牧4苜4姥8毪2莫9钼4募4墓4幕4睦4慕4模7暮4穆4", - "mao": "1:毛2卯3矛2峁3泖3牦2茂4茅2茆7茆8冒9昴3贸4旄7旄9耄4铆3猫7猫6袤4帽4瑁4锚2瞀4貌4髦2蝥2懋4蟊2冇3", + "mao": "1:毛2卯3矛2峁3泖3牦2茂4茅2茆7茆8冒9昴3贸4旄7旄9耄4铆3猫6猫7袤4帽4瑁4锚2瞀4貌4髦2蝥2懋4蟊2冇3", "shui": "3:水3说9谁7税4睡4", "huo": "2:火3和9或4货4活2钬3获4祸4惑4耠1锪1夥3劐1霍4豁7豁9豁6镬4嚯4攉1藿4蠖4伙3和7和5漷3", "zhua": "3:爪8抓1挝6", @@ -403,7 +403,7 @@ "nuan": "2:暖3", "miu": "2:谬4缪9", "seng": "1:僧1", - "niang": "2:酿4孃2嬢2", + "niang": "2:娘2酿4孃2嬢2", "nou": "1:耨4", "nang": "1:曩3囊7囊6馕7馕8囔1攮3齉4", "den": "1:扥4扽4", diff --git a/src/cnchar/main/utils/tool.ts b/src/cnchar/main/utils/tool.ts index fd15ab52..97363aea 100644 --- a/src/cnchar/main/utils/tool.ts +++ b/src/cnchar/main/utils/tool.ts @@ -95,7 +95,7 @@ export function spell (dict: Json, originArgs: Array): string | } else { result[i] = item[0]; } - if (has(args, arg.flat)) { + if (has(args, arg.flat) && has(args, arg.tone)) { result[i] = shapeSpell(result[i], true); } } diff --git a/src/cnchar/plugin/code/code.ts b/src/cnchar/plugin/code/code.ts index c33062a6..b209d4d7 100644 --- a/src/cnchar/plugin/code/code.ts +++ b/src/cnchar/plugin/code/code.ts @@ -2,7 +2,7 @@ * @Author: tackchen * @Date: 2022-05-26 09:37:18 * @LastEditors: Please set LastEditors - * @LastEditTime: 2022-06-04 10:04:45 + * @LastEditTime: 2023-04-09 11:26:06 * @FilePath: /cnchar/src/cnchar/plugin/code/code.ts * @Description: Coding something */ @@ -11,7 +11,7 @@ import {ICode, ICodeResult, IDictCodeResult} from 'cnchar-types/plugin/code'; import {Json} from 'cnchar-types/main/common'; import dict from './dict/code.json'; import GBK from './gbk'; -import {mapJson} from '@common/util'; +import {mapJson, _warn} from '@common/util'; let cnchar: ICnChar; @@ -75,6 +75,28 @@ export function uniCode (word: string, decode = false): string { return decode ? unescape(word) : escape(word); } +export function fiveStroke (words: string, type: '86'|'98'|'all' = '86') { + if (!cnchar || !cnchar.input) { + _warn('查询五笔输入法需要先安装cnchar和cnchar-input'); + return []; + } + const result = []; + for (let i = 0; i < words.length; i++) { + result.push(singleFiveStroke(words[i], type)); + } + return result; +} + +function singleFiveStroke (word: string, type: '86'|'98'|'all' = '86') { + let code = cnchar.input.dict.wubi[word]; + if (!code && cnchar?.hasPlugin('trad')) { + code = cnchar.trad.dict?.wubi[word]; + } + if (!code) return ''; + if (type === 'all' || code.indexOf(' ') === -1) return code; + return code.split(' ')[type === '86' ? 0 : 1]; +} + export const code = ((input: string) => { const result: ICodeResult[] = []; for (let i = 0; i < input.length; i++) { @@ -87,6 +109,7 @@ export const code = ((input: string) => { url: urlCode(word), unicode: uniCode(word), binary: binaryCode(word), + fiveStroke: singleFiveStroke(word), }); } return result; @@ -97,11 +120,9 @@ code.char = charCode; code.gbk = gbkCode; code.url = urlCode; code.unicode = uniCode; - +code.fiveStroke = fiveStroke; code.sijiao = buildCommonCode('sijiao'); - code.cangjie = buildCommonCode('cangjie'); - code.uniform = buildCommonCode('uniform'); code.setCode = (words:string | Json, data?: IDictCodeResult) => { @@ -135,7 +156,7 @@ function parseSingleWordCode (dict: Json, code: string, trad = false): s } } - if (!trad && cnchar && cnchar.hasPlugin('trad')) { + if (!trad && cnchar?.hasPlugin('trad')) { return parseSingleWordCode(cnchar.trad.dict?.code, code, true); } return '-'; @@ -145,7 +166,7 @@ function getSingleWordCode (dict: Json, word: string): IDictCodeResult { let str = dict[word]; if (!str) { - if (cnchar && cnchar.hasPlugin('trad')) { + if (cnchar?.hasPlugin('trad')) { str = cnchar.trad.dict?.code?.[word]; } } diff --git a/src/cnchar/plugin/info/info.ts b/src/cnchar/plugin/info/info.ts index d92279f3..95267107 100644 --- a/src/cnchar/plugin/info/info.ts +++ b/src/cnchar/plugin/info/info.ts @@ -45,7 +45,7 @@ function getSingleWordInfo (dict: Json, word: string): IInfoResult { let str = dict[word]; if (!str) { - if (cnchar && cnchar.hasPlugin('trad')) { + if (cnchar?.hasPlugin('trad')) { str = cnchar.trad.dict?.info?.[word]; } } diff --git a/src/cnchar/plugin/radical/dict/radicals.json b/src/cnchar/plugin/radical/dict/radicals.json index e5ad5cdc..410e7271 100644 --- a/src/cnchar/plugin/radical/dict/radicals.json +++ b/src/cnchar/plugin/radical/dict/radicals.json @@ -5,7 +5,7 @@ "又": "2:叔a及c友d双a反d发c叒c取a受b变b叕b叙a叛a叟b叠b叡a", "玉": "5:玺b璧b璺b", "月": "4:胺a有b肋a肌a肓b肖b肘a肚a肛a肜a肝a肟a肠a朊a朋a服a股a肢a肤a肥a肩d肪a肫a肭a肮a肯b肱a育b肴b肷a肺a肼a肽a肾b肿a胀a胁a朐a胂a胃b胄b胆a背b胍a胎a胖a胗a胙a胚a胛a胜a胝a胞a胡a胤a胥b胧a胨a胩a胪a胫a脉a朔a朕a朗a胭a胯a胰a胱a胲a胳a胴a胶a胸a胼a能a脂a脆a脊b脍a脎a脏a脐a脑a脒a脓a脩a望b脖a脘a脚h脞a脬a脯a脱a脲a脶a脸a朝a期a脾a腆a腈a腊a腋a腌a腑a腓a腔a腕a腙a腚a腱a腴a腠a腥a腧a腩a腭a腮a腰a腹a腺a腻a腼a腽a腾a腿a膀a膂b膈a膊a膏b膑a膜a膘a膛a膝a膣a膦a膨h膪a膳a朦a膺d膻a臀b臁a臂b臃a臆a臊a臌a", - "一": "1:丁c七c万c丈c三c上c下c丌c与c不c丐c丑c专c无c且c丕b世c丙c业c丛b东c丝b丞b两c严b丽b丧b", + "一": "1:画d丁c七c万c丈c三c上c下c丌c与c不c丐c丑c专c无c且c丕b世c丙c业c丛b东c丝b丞b两c严b丽b丧b", "丿": "1:乃c九c乂c丸c久c乇c么c丹c乌c乏c丘c乍c乎c乐c册c丢b乒b乓b乔b乖c乘c", "乙": "1:乜c了c乞c也c习c乡c书c予c乩a买b乱a乾a", "刀": "2:刁c刃c分b切a刍b争b免b初a龟b兔b券b剪b劈b", @@ -77,7 +77,7 @@ "火": "4:灭b灯a灰d灵b灶a灸b灼a灾b灿a炀a炅b炉a炊a炎b炒a炔a炕a炖a炙b炜a炝a炬a炘a炫a炭b炯a炱g炳a炷a炻a炼a炽a烀a烁a烂a烃a炤a烊a烘a烙a烛a烟a烤a烦a烧a烨a烩a烫b烬a烜a烯a烷a烽a焊a焐a焓a焕a焖a焗a焙a焚b焯a焰a焱b焜a煅a煊a煌a煜a煤a煨a煲b煳a煸a煺a煽a熄a熔a熘a熠a熨b熳a熵a燃a燎a燔a燠a燧a燊a燚a燥a燮b燹b爝a爨b", "犭": "3:犯a犰a犴a犷a犸a犹a狁a狂a狃a狄a狈a狍a狎a狐a狒a狗a狞a狠a狡a狨a狩a独a狭a狮a狯a狰a狱h狲h狳a狴b狷a狸a狺a狻a狼a猁a猃a猊a猎a猓a猕h猖a猗a猛a猜a猝a猞a猡a猪a猫a猢a猥a猩a猬a猱a猴a猸a猹a猾a猿a獍a獐a獗a獠a獬a獭h獴a獯a獾a", "用": "5:甩c甪d甫c甬b甭b甯b", - "田": "5:由c甲c申c电c男b甸d町a画d甾b畀b畅a畈a畋a界b畎a畏b畑a畔a留b畚b畛a畜b略a畦a番b畲b畴a畬b畸a畹a畿b疃a疆a", + "田": "5:由c甲c申c电c男b甸d町a甾b畀b畅a畈a畋a界b畎a畏b畑a畔a留b畚b畛a畜b略a畦a番b畲b畴a畬b畸a畹a畿b疃a疆a", "礻": "4:礼a祁a社a祀a祆a祈a祉a祎a祇a祓a祖a祗a祚a祛a祜a祝a神a祠a祢a祐a祥a祧a祯a祷a祸a祺a禄a禅a禊a福a禚a禤a禧a禳a", "纟": "3:纠a纡a红a纣a纤a纥a约a级a纨a纩a纪a纫a纬a纭a纯a纰a纱a纲a纳a纵a纶a纷a纸a纹a纺a纽a纾a线a绀a绁a绂a练a组a绅a细a织a终a绉a绊a绋a绌a绍a绎a经a绐a绑h绒a结a绔a绕a绗a绘a给a绚a绛a络a绝a绞a统a绠a绡a绢a绣a绥a绦a继a绨a绩a绪a绫a续a绮a绯a绰a绱a绲a绳a维a绵a绶a绷a绸a绺a绻a综a绽a绾a绿a缀a缁a缍a缂a缃a缄a缅a缆a缇a缈a缉a缋a缌a缎a缏a缑a缒a缓a缔a缕a编a缗a缘a缙a缚a缛a缜a缝a缟a缠a缡a缢a缣a缤a缥a缦a缧a缨a缩a缪a缫a缬h缭a缮a缯a缰a缱a缲a缳a缴a缵a", "车": "4:轧a轨a轩a轫a转a轭a轮a软a轰b轱a轲a轳a轴a轵a轶a轷a轸a轹a轺a轻a珲a轼a载d轾a轿a辁a辂a较a辄h辅a辆a辇b辈b辉a辊a辋a辍a辎a辏a辐a辑a输a辔b辕a辖a辗a辘a辙h辚a", @@ -103,7 +103,7 @@ "覀": "6:西c要b覃b覆b", "见": "4:观a现a规a觅b视a觇a览b觉b笕b觊a觋a觌a觎a觏a觐a觑a", "贝": "4:贞b负b贠b贡b财a责b贤b败a账a货b质d贩a贪b贫b贬a购a贮a贯b贰d贱a贲g贳b贴a贵b贶a贷b贸b费b贺b贻a贼a贽b贾b贿a赀b赁b赂a赃a资b赅a赆a赇a赈a赉b赊a赋a赍b赎a赏b赐a赓d赔a赕a赖a箦b赘b赙a赚a赛b赜a赝d赞b赠a赟b赡a赢g赣a", - "钅": "5:钆a钇a针a钉a钊a钋a钌a钍a钎a钏a钐a钒a钓a钔a钕a钗a钙a钚a钛a钜a钝a钟a钠a钡a钢a钣a钤a钥a钦a钧a钨a钩a钪a钫a钬a钭a钮a钯a钰a钲a钳a钴a钵a钶a钷a钸a钹a钺a钻a钼a钽a钾a钿a铀a铁a铂a铃a铄a铅a铆a铈a铉a铊a铋a铌a铍a铎a铐a铑a铒a铕a铖a铗a铘a铙a铛a铜a铝a铞a铟a铠a铡a铢a铣a铤a铥a铧a铨a铩a铪a铫a铬a铭a铮a铯a铰a铱a铲a铳a铴a铵a银a铷a铸a铹a铺a铼a铽a链a铿a销a锁a锂a锃a锄a锅a锆a锇a锈a锉a锊a锋a锌a锍a锎a锏a锐a锑a锒a锓a锔a锕h锖a锗a锘a错a锚a锛a锝a锞a锟a锡a锢a锣a锤a锥a锦a锨a锩a锪a锫a锬a锭a键a锯a锰a锱a锲a锴a锵a锶a锷a锸a锹h锺a锻a锼a锾a锿a镀a镁a镂a镄a镅a镆a镇a镉a镊a镌a镍a镎a镏a镐a镑a镒a镓a镔a镕a镖a镗a镘a镙a镛a镜a镝a镞h镟a镡a镢a镣a镤a镥a镦a镧a镨a镩a镪h镫a镬a镭a镯a镰a镱a镲a镳a镶a", + "钅": "5:钱a钆a钇a针a钉a钊a钋a钌a钍a钎a钏a钐a钒a钓a钔a钕a钗a钙a钚a钛a钜a钝a钟a钠a钡a钢a钣a钤a钥a钦a钧a钨a钩a钪a钫a钬a钭a钮a钯a钰a钲a钳a钴a钵a钶a钷a钸a钹a钺a钻a钼a钽a钾a钿a铀a铁a铂a铃a铄a铅a铆a铈a铉a铊a铋a铌a铍a铎a铐a铑a铒a铕a铖a铗a铘a铙a铛a铜a铝a铞a铟a铠a铡a铢a铣a铤a铥a铧a铨a铩a铪a铫a铬a铭a铮a铯a铰a铱a铲a铳a铴a铵a银a铷a铸a铹a铺a铼a铽a链a铿a销a锁a锂a锃a锄a锅a锆a锇a锈a锉a锊a锋a锌a锍a锎a锏a锐a锑a锒a锓a锔a锕h锖a锗a锘a错a锚a锛a锝a锞a锟a锡a锢a锣a锤a锥a锦a锨a锩a锪a锫a锬a锭a键a锯a锰a锱a锲a锴a锵a锶a锷a锸a锹h锺a锻a锼a锾a锿a镀a镁a镂a镄a镅a镆a镇a镉a镊a镌a镍a镎a镏a镐a镑a镒a镓a镔a镕a镖a镗a镘a镙a镛a镜a镝a镞h镟a镡a镢a镣a镤a镥a镦a镧a镨a镩a镪h镫a镬a镭a镯a镰a镱a镲a镳a镶a", "彡": "3:形a彤a彦b彧c彪d彩a彬h彭a彰a影a", "彳": "3:彷a役a彻h彼a往a征a徂a径a待a徇a很a徉a徊a律a後a徐a徒a徕a得a徘a徙a徜a御a徨a循a復a徭a微h徳a徵a德a徼a徽h", "歹": "4:歼a殁a殂a殃a殄a殆a殇a残a殉a殊a殍a殒a殓a殖a殚a殛a殡a殪a", @@ -135,7 +135,7 @@ "瓦": "4:瓮b瓯a瓴a瓶a瓷b瓿a甄a甍b甏b甑a甓b", "甘": "5:甙d甚b甜a", "皿": "5:盂b盅b盆b盈b益b盍b盎b盏b盐b监b盒b盔b盖b盗b盘b盛b盟b盥b簋g", - "竹": "6:笼b竺b竽b竿b笃b笈b笄b笆b笊b笋b笏b笑b笫b笙b笛b笞b笠b笤b笥b符b笨b笪b第b笮b笱b笳b笸b笺b笾b筇b筅b等b筋b筌b筏b筐b筑b筒b答b策b筘b筚b筛b筝b筵b筠b筢b筮b筱b筲b筷b筹b筻b签b简b箅g箍b箐b箔b箕b算b箜b箝b管b箢b箧b箨b箩b箪b箬g箸b箱b箴b篁b篆b篇b篌b篑b篓b篙b篚b篝b篡b篥b篦b篪b篮b篱b篷b篼b篾g簇b簌b簏b簖b簧b簕b簟g簦b簸b簿b籀b籁b籍b", + "竹": "6:笔b笼b竺b竽b竿b笃b笈b笄b笆b笊b笋b笏b笑b笫b笙b笛b笞b笠b笤b笥b符b笨b笪b第b笮b笱b笳b笸b笺b笾b筇b筅b等b筋b筌b筏b筐b筑b筒b答b策b筘b筚b筛b筝b筵b筠b筢b筮b筱b筲b筷b筹b筻b签b简b箅g箍b箐b箔b箕b算b箜b箝b管b箢b箧b箨b箩b箪b箬g箸b箱b箴b篁b篆b篇b篌b篑b篓b篙b篚b篝b篡b篥b篦b篪b篮b篱b篷b篼b篾g簇b簌b簏b簖b簧b簕b簟g簦b簸b簿b籀b籁b籍b", "米": "6:籴b类b籼a籽a粉a粑a粒a粕a粗a粘a粜b粝a粞a粟b粢b粤b粥h粪b粮a粱b粲b粳a粹a粼a粽a精a糁a粿a糅a糇a糈a糊h糌a糍a糕a糖a糗a糙a糜d糟a糠a糨a糯a", "罒": "5:罗b罘b罚b罟b罡b罢b罨b罩b罪b置b署b罱b罴g罹b罾b羁b", "耳": "6:耵a耶a耷b耸b耻a耽a耿a聂b聃a聆a聊a聋b职a聍a聒a联a聘a聚b聩a聪a聱b", @@ -147,7 +147,7 @@ "页": "6:顶a顷a顸a项a顺a须a顼a顽a顾a顿a颀a颁a颂a颃a预a颅a领a颇a颈a颉a颊a颌a颍a颏a颐a频a颓a颔a颖a颗a题d颚a颛a颜a额a颞a颟a颠a颡a颢a颤a颥a颦b颧a", "彑": "3:彖b彘b彝g", "旡": "4:既a", - "毛": "4:毡d毪d笔b毫b毯d毳b毵a毽d毹a氅b氆d氇d氍a", + "毛": "4:毡d毪d毫b毯d毳b毵a毽d毹a氅b氆d氇d氍a", "灬": "4:点b烈b热b羔b烹b焉b焘b焦b然b煮b煎b煞b煦b照b熊b熏b熙b熬b熟b熹b燕g", "爫": "4:爰b爱b爵b", "癶": "5:癸b登b", diff --git a/src/cnchar/plugin/radical/index.ts b/src/cnchar/plugin/radical/index.ts index 96c0d1a3..351286a6 100644 --- a/src/cnchar/plugin/radical/index.ts +++ b/src/cnchar/plugin/radical/index.ts @@ -1,7 +1,14 @@ +/* + * @Author: chenzhongsheng + * @Date: 2022-10-09 09:18:54 + * @Description: Coding something + */ import {IRadical} from 'cnchar-types/plugin/radical'; import {IPlugin} from 'cnchar-types/main/common'; -import {getDict, radical, setCnchar, setRadical} from './radical'; - +import { + getDict, getRadicalCount, isRadical, radicalToWord, + radical, setCnchar, setRadical +} from './radical'; const plugin: IPlugin & IRadical = Object.assign(radical, { pluginName: 'radical', @@ -9,6 +16,9 @@ const plugin: IPlugin & IRadical = Object.assign(radical, { setCnchar(cnchar); }, setRadical, + getRadicalCount, + radicalToWord, + isRadical, dict: getDict(), } as IPlugin); diff --git a/src/cnchar/plugin/radical/radical.ts b/src/cnchar/plugin/radical/radical.ts index af9328f7..1a6d7938 100644 --- a/src/cnchar/plugin/radical/radical.ts +++ b/src/cnchar/plugin/radical/radical.ts @@ -3,7 +3,7 @@ import {Json} from 'cnchar-types/main/common'; import dict from './dict/radicals.json'; import structDict from './dict/struct.json'; import {ISetRadical, IRadical, IRadicalResult, TStruct} from 'cnchar-types/plugin/radical'; -import {findEqualKeyInMap} from '@common/util'; +import {findEqualKeyInMap, _warn} from '@common/util'; const radicals = dict as Json; @@ -104,4 +104,52 @@ function removeWordRadical (word: string) { return; } } +} + +export function isRadical (radical: string) { + return !(radical === '*' || !radicals[radical]); +} + +export function getRadicalCount (radical: string) { + if (!isRadical(radical)) return 0; + + return parseInt(radicals[radical][0]); +} + +export function radicalToWord (radical: string, trad = false): { + word: string, struct: TStruct +}[] { + const result = radicalToWordBase(radical, radicals); + if (trad) { + if (_cnchar && _cnchar.hasPlugin('trad')) { + return result.concat(radicalToWordBase(radical, _cnchar.trad.dict?.radical)); + } else { + + } + } + return result; +} + +function radicalToWordBase (radical: string, dict: Json) { + const str = dict[radical]; + if (!str) { + _warn(`错误的偏旁部首:${radical}`); + return []; + } + let index = 2, gap = 2; + if (radical === '*') { + index = 0; + gap = 3; + } + const result = []; + for (let i = index; i < str.length; i += gap) { + if (radical === '*' && gap === 3 && /[0-9]{2}/.test(str.substr(i + 2, 2))) { + gap = 4; + } + result.push({ + word: str[i], + struct: (structDict as any)[str[i + 1]] + }); + } + return result; } \ No newline at end of file diff --git a/src/cnchar/plugin/trad/dict/radicals-trad.json b/src/cnchar/plugin/trad/dict/radicals-trad.json index 630db61b..92d50b67 100644 --- a/src/cnchar/plugin/trad/dict/radicals-trad.json +++ b/src/cnchar/plugin/trad/dict/radicals-trad.json @@ -1,5 +1,5 @@ { - "*": "門c8馬d10鬥a10見b7長d8車d7貝b7韋b9風c9鳥a11龍a16頁b9齊b14麥b11齒a15魚b11黽b12靣d8釒a8", + "*": "見b7車d7貝b7靣d8釒a8門c8長d8韋b9風c9頁b9馬d10鬥a10鳥a11麥b11魚b11黽b12齊b14齒a15龍a16", "釒": "8:銼a鎸a鉅a釦a釓a釔a鉋a針a釘a釗a釕a釙a錄a錶a釷a釺a鍆a釤a釩a釣a釵a釧a鈣a鈈a鐘a鈑a鈦a鈐a鋼a鈉a鈍a鋇a鈞a鈁a鈥a鈧a鈎a鈄a鈕a鎢a鈀a鈺a鉗a鈷a鉦a鈸a鈳a鉆a鈽a鉬a鉭a鉀a鉄a鉕a鈿a鉞a鉑a鈾a鈰a鑠a鈴a鉈a鉉a鉍a鉚a鈹a鐸a鈮a鉛a鏇a釬a銬a銪a鋮a鉺a鐃a銅a銱a鋣a鋏a銠a鐺a銦a鎧a鋌a銓a銖a銑a銩a鍘a鏵a鉿a鉻a鎩a錚a銚a銘a鉸a銫a銥a銃a銣a銀a銨a鐋a鐒a鑄a錸a鋱a鏗a鎖a鋥a銷a鋰a鍋a鋯a銹a鏈a鋨a鋶a鉲a鋒a鐧a鋅a銻a銳a錒a鋟a鋃a鋦a鍺a鍩a錨a錯a錁a錛a錆a鍀a錕a錘a鍃a錦a錮a鑼a錇a錫a錈a鍁a錐a錠a錳a鍵a錟a鋸a錙a鍥a鍇a鍔a鏘a鍤a鍛a鍶a鎪a鍰a鍾a鎂a鎄a鍍a鐨a鋂a鏤a鏌a鎘a鑷a鎮a鎦a鎰a錼a鎳a鎬a鎊a鎵a鑌a鎔a鏢a鏜a鏡a鏍a鏑a鏞a鏝a鏃a鐔a鐝a鐐a鑥a鐓a鏷a鐠a鑹a鐙a鑭a鏹a鐳a鑊a鋜a鐿a鐮a鑔a鑣a鑲a鉢a鏟a鈔a鋤a鉤a鑑a鋁a鋪a鍬a錢a鐵a銜a鏽a鑰a鑽a釹a鐗a鐦a鋝a鎿a鎇a鐲a钁a", "艹": "3:蔣b萬b蔔b藝b蘭b葉b華b莊b薌b蕭b蘆b葦b蕪b藶b萇b蕓b莧b蒼b苧b蓯b莖b蘢b蔦b蘋b薑b薦b蕘b薈b蓽b莢b荊b薺b蕎b葷b蕁b蓀b葒b藎b蕒b葯b葤b蓆b蓧b蓮b萵b蒔b萊b蕕b薟b蒓b菴b蓋b著b蔆b蘿b薩b蔴b蒐b蔥b蕆b蕢b蔞b薊b蕷b藍b蘺b藺b蘞b薔b藹b蘄b蘊b藪b蘚b蕩b蘇b蔭b藥b茲b蒞b蓴b", "土": "3:塼a壓b場a壙a堯a塵b執a堦a堅b壞a墰a塢a塊a墳a壢a垻a墜b報a壟b壚a塋b埰a坰a墾b埡a壘b堊b堖a塏a墊b塚a塤a塒a堝a垵a塹b墮b墝a墻a堿a壩a壇a塗b壎a壠a", diff --git a/vuepress/.vuepress/components/codebox.vue b/vuepress/.vuepress/components/codebox.vue index 284866f3..947620ac 100644 --- a/vuepress/.vuepress/components/codebox.vue +++ b/vuepress/.vuepress/components/codebox.vue @@ -21,6 +21,9 @@
Powered by JSBox
+
+ +
@@ -51,7 +54,10 @@ type: String, default: 'javascript' }, - title: String, + title: { + type: String, + default: '示例代码' + }, desc: String, onlineLink: { type: String, @@ -69,10 +75,11 @@ }, mounted () { jsbox = initJSBox(); + const code = this.getTextCode(); this.localFold = this.fold; - if (this.code) { - this.localCode = this.code; - this.localLang = this.lang; + if (code) { + this.localCode = code; + this.localLang = this.lang || 'javascript'; this.localDesc = this.desc; } else { const codes = window.jsbox_config.codes; @@ -95,6 +102,9 @@ }); }, methods: { + getTextCode () { + return this.code || this.$refs.slot.innerText.trim(); + }, onLog (args) { if (this.localLang === 'html') { return; @@ -121,8 +131,9 @@ } }, run () { - if (this.code) { - jsbox.code(this.code); + const code = this.getTextCode(); + if (code) { + jsbox.code(code); } else { jsbox.id(this.id); } diff --git a/vuepress/.vuepress/components/home.vue b/vuepress/.vuepress/components/home.vue index 0e143ccd..5edfb13e 100644 --- a/vuepress/.vuepress/components/home.vue +++ b/vuepress/.vuepress/components/home.vue @@ -14,10 +14,18 @@ 语音识别 语音合成 +
{{spell}} | 共{{stroke}}笔
-
繁体: {{trad}} | 火星文: {{spark}}
-
笔顺: {{order}}
+
+ 繁体 {{trad}} + | + 火星文 {{spark}} + | + 五笔码 {{fiveStroke}} +
+
笔顺 {{order}}
+
部首|结构 {{radical}}
@@ -77,6 +85,8 @@ order: '', supportVoice: false, loaded: false, + radical: '', + fiveStroke: '', }; }, mounted () { @@ -106,12 +116,17 @@ applyText () { if (this.text) { this.spell = this.text.spell('array', 'tone').join(' '); - this.stroke = this.text.stroke(); + this.stroke = `${this.text.stroke()}(${this.text.stroke('array').join('+')})`; this.trad = this.text.convertSimpleToTrad('trad'); this.spark = this.text.convertSimpleToSpark('spark'); this.order = JSON.stringify(this.text.stroke('order', 'shape')).replace(/"/g, '').replace(/null/g, '无'); const str = this.pickCnChar(this.text); const el = document.getElementById('draw-area'); + + const result = window.cnchar.radical(this.text); + this.radical = result.map(item => item.radical ? `${item.radical}|${item.struct}` : '-').join(', '); + + this.fiveStroke = window.cnchar.code.fiveStroke(this.text).map(s => s || '-').join(', '); if (el) { el.innerHTML = ''; if (str !== '') { @@ -197,6 +212,7 @@ margin: 1rem 0; .split{ margin: 0 1rem; + color: #bbb; } #draw-area{ margin-top: 0.8rem; @@ -244,5 +260,10 @@ // font-size: 1rem; // padding: 0.8rem 1.2rem; } + .demo-title{ + padding: 3px; + background-color: #eee; + border-radius: 2px; + } } diff --git a/vuepress/doc/code.md b/vuepress/doc/code.md index 3fe0694e..2a98b34f 100644 --- a/vuepress/doc/code.md +++ b/vuepress/doc/code.md @@ -23,6 +23,7 @@ code(input: string): Array<{ sijiao: string; cangjie: string; uniform: string; + fiveStroke: string; }>; ``` @@ -37,7 +38,7 @@ cnchar.code('汉字'); 返回结果会以空格分割,解码时传入的word也需要以字符串分割每个汉字的编码 ```ts -code.binary(word: string, decoce?: boolean): string; +code.binary(word: string, decode?: boolean): string; ``` ## 3. charCode编解码 @@ -45,25 +46,25 @@ code.binary(word: string, decoce?: boolean): string; 返回结果会以空格分割,解码时传入的word也需要以字符串分割每个汉字的编码 ```ts -code.char(word: string, decoce?: boolean): string; +code.char(word: string, decode?: boolean): string; ``` ## 4. unicode编解码 ```ts -code.unicode(word: string, decoce?: boolean): string; +code.unicode(word: string, decode?: boolean): string; ``` ## 5. url编解码 ```ts -code.url(word: string, decoce?: boolean): string; +code.url(word: string, decode?: boolean): string; ``` ## 6. gbk编解码 ```ts -code.gbk(word: string, decoce?: boolean): string; +code.gbk(word: string, decode?: boolean): string; ``` ## 7. 四角码编解码 @@ -71,7 +72,7 @@ code.gbk(word: string, decoce?: boolean): string; 返回结果会以空格分割,解码时传入的word也需要以字符串分割每个汉字的编码 ```ts -code.sijiao(word: string, decoce?: boolean): string; +code.sijiao(word: string, decode?: boolean): string; ``` ## 8. 仓颉码编解码 @@ -79,7 +80,7 @@ code.sijiao(word: string, decoce?: boolean): string; 返回结果会以空格分割,解码时传入的word也需要以字符串分割每个汉字的编码 ```ts -code.sijiao(word: string, decoce?: boolean): string; +code.sijiao(word: string, decode?: boolean): string; ``` ## 9. 统一汉字编码编解码 @@ -87,5 +88,27 @@ code.sijiao(word: string, decoce?: boolean): string; 返回结果会以空格分割,解码时传入的word也需要以字符串分割每个汉字的编码 ```ts -code.uniform(word: string, decoce?: boolean): string; +code.uniform(word: string, decode?: boolean): string; ``` + +## 10. 汉字五笔码 + +单独查询一个或多个汉字的五笔码,返回一个数组 + +第二个参数表示查询五笔输入法的版本,默认采用 86 版本 + +注:需要事先引入 cnchar-input 插件 + +```ts +code.fiveStroke(word: string, type?: '86'|'98'|'all'): string[]; +``` + +示例 + +
+ +cnchar.code.fiveStroke('你好'); + +
+ + diff --git a/vuepress/doc/radical.md b/vuepress/doc/radical.md index 7a1b70dc..46783eb3 100644 --- a/vuepress/doc/radical.md +++ b/vuepress/doc/radical.md @@ -1,3 +1,8 @@ + ## 1. 介绍 cnchar在2.2.5加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库,该库可以独立于cnchar主库运行 @@ -34,8 +39,62 @@ cnchar.radical(value,arg1,arg2,...); | :-----: | :----: | :------: | :---: | :---: | | array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 | -## 3. 实例 +## 3. 根据部首查字 + +使用 radicalToWord 函数可以根据部首查找汉字及汉字的结构 + +
+ +cnchar.radical.radicalToWord('牜'); + +
+ +如果只需要汉字可以使用map方法 + +
+ +cnchar.radical.radicalToWord('牜').map(item => item.word); + +
+ +可以通过 * 查询没有部首的汉字 + +
+ +cnchar.radical.radicalToWord('*').map(item => item.word).join(''); + +
+ +### 查询繁体字 + +如果需要查询繁体字,请先引入 cnchar-trad 插件,然后第二个参数传入 true +
+ +cnchar.radical.radicalToWord('*', true).map(item => item.word).join(''); + +
+ + +## 4. 判断某个字符是否是部首 + +
+ +cnchar.radical.isRadical('钅'); + +
+ +## 4. 查询某个部首的笔画 + +
+ +cnchar.radical.getRadicalCount('钅'); + +
+ +返回 0 表示该字符不是部首 + +## 3. 实例 该库为cnchar扩展了偏旁部首功能 diff --git a/vuepress/guide/donate.md b/vuepress/guide/donate.md index fb4a940d..3fa37ad5 100644 --- a/vuepress/guide/donate.md +++ b/vuepress/guide/donate.md @@ -9,4 +9,31 @@ 如捐赠,请备注留一下github个人地址,后续会展示在此页中。 - \ No newline at end of file + + +## 赞赏记录 + +注:最新统计时间为 2023/04/08,总金额=32元 + +| 昵称 | 金额(元) | 时间 | 留言 | 渠道 | 作者备注 | +|:--:|:--:|:--:|:--:|:--:|:--:| +| 普通的disco | 20 | 2023/04/01 | 大佬开源维护不易,加油!希望能有部首查字的功能~ | 微信赞赏码 |v3.2.4中已增加该功能| +| mango | 5 | 2023/02/10 | - | 微信赞赏码 | | +| 阿炜 | 5 | 2022/11/11 | 阿炜ky2700 | 微信赞赏码 | | +| slako | 1 | 2022/10/20 | 不明觉厉 | 微信赞赏码 | | +| 王三金 | 1 | 2022/10/16 | - | 微信赞赏码 | | + +## 捐赠计划 + +以下较大功能更新在未来的 ToDoList 计划之中,但是由于作者精力有限,业余闲暇时间有限,所以开启捐赠计划,每一项功能开启一个捐赠金额,捐赠满之后会分配时间来进行开发。如果以下功能对您的业务或项目有帮助,可以捐赠以鼓励作者进行开发,捐赠时请留言对应的具体功能,也可自行留言想要增加的定制功能 + +TodoList + +1. cnchar-voice: 语音识别优化 -- 进度[0/100元] +2. cnchar-draw: writer加上canvas渲染 -- 进度[0/300元] +3. cnchar-info: 注音支持多音字 -- 进度[0/100元] +4. cnchar-input: 拼音联想输入法权重调整,新增cnchar-input-ui插件(输入法ui支持) -- 进度[0/500元] +5. cnchar-order: 查询包含某个汉字(笔画序列)的所有汉字【如根据斌字查到赟】 -- 进度[0/100元] +6. cnchar-order: 判断某个汉字是否包含某个汉字【如赟字是否包含斌】 -- 进度[0/100元] + +当然也非常欢迎感兴趣的同学参与进来一起进行开源协作 \ No newline at end of file diff --git a/vuepress/guide/version.md b/vuepress/guide/version.md index a0a3f42a..b9765b35 100644 --- a/vuepress/guide/version.md +++ b/vuepress/guide/version.md @@ -1,3 +1,20 @@ +## todo list + +1. 拼音联想输入法权重调整 +2. 语音识别 优化 +3. writer 加上canvas渲染 +4. 注音支持多音字 +5. 新增cnchar-input-ui插件(输入法ui支持) + +## 3.2.4 + +1. cnchar.spell('洗', 'flat') 参数有bug +2. Cnchar 猫 字默认读音 +3. 娘字读音有误 +4. 钱字部首查不到 +5. 增加通过部首查询 +6. cnchar-code 增加五笔码 +7. 文档首页增加部首展示和五笔展示 ## 3.2.3 diff --git a/vuepress/src/util.js b/vuepress/src/util.js index 6e2fc877..7a12211c 100644 --- a/vuepress/src/util.js +++ b/vuepress/src/util.js @@ -1,3 +1,8 @@ +/* + * @Author: chenzhongsheng + * @Date: 2022-10-09 09:18:54 + * @Description: Coding something + */ export function extractScript (html) { const reg = /(.|\n)*?<\/script>/g; const arr = html.match(reg); @@ -20,49 +25,19 @@ function extractContent (html, tag = 'script') { export function execute ({ code = '', - // onload, - // onerror, - // ontimeout, - // timeout = 6000 }) { if (code.trim() === '') { console.warn('execute code 参数不可为空'); return; } if (code.indexOf('\n') === -1) { - code = `console.log(${code})`; + code = `var __ = ${code};console.log(__);`; } new Function(code.trim())(); - // let blob = new Blob([code], {type: 'application/text'}); - // let objectURL = window.URL.createObjectURL(blob); - // let script = document.createElement('script'); - // let timer = null; - // if (ontimeout) { - // timer = setTimeout(() => { - // ontimeout(); - // document.body.removeChild(script); - // }, timeout); - // } - // script.onload = function () { - // if (onload) { - // onload(); - // } - // clearTimeout(timer); - // document.body.removeChild(script); - // }; - // script.onerror = function (err) { - // if (onerror) { - // onerror(err); - // } - // clearTimeout(timer); - // document.body.removeChild(script); - // }; - // document.body.appendChild(script); - // script.src = objectURL; } export function copy (str) { - var input = document.getElementById('_copy_input_'); + let input = document.getElementById('_copy_input_'); if (!input) { input = document.createElement('input'); input.setAttribute('type', 'text');