Skip to content

Commit

Permalink
Merge pull request #301 from hotoo/feat/dumi
Browse files Browse the repository at this point in the history
Feat/dumi
  • Loading branch information
hotoo committed Oct 20, 2021
2 parents 320e4a7 + ca10cc6 commit 02f0417
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ tools/dict/error.log
coverage/
package-lock.json
yarn.lock
.umi/
41 changes: 41 additions & 0 deletions .umirc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// import { readdirSync } from 'fs';
// import { join } from 'path';
import { defineConfig } from 'dumi';

// const headPkgList = [];
// // utils must build before core
// // runtime must build before renderer-react
// const pkgList = readdirSync(join(__dirname, 'packages')).filter(
// (pkg) => pkg.charAt(0) !== '.' && !headPkgList.includes(pkg),
// );
// const alias = pkgList.reduce((pre, pkg) => {
// pre[`@alipay/${pkg}`] = join(__dirname, 'packages', pkg, 'src');
// return {
// ...pre,
// };
// }, {});

export default defineConfig({
title: 'pīnyīn',
favicon:
'https://gw.alipayobjects.com/mdn/rms_f6322a/afts/img/A*VqPXS4ODZTMAAAAAAAAAAAAAARQnAQ',
logo:
'https://gw.alipayobjects.com/mdn/rms_f6322a/afts/img/A*bGz9QbNudekAAAAAAAAAAAAAARQnAQ',
outputPath: 'docs-dist/dist',
mode: 'site',
exportStatic: {},
hash: true,
resolve: {
includes: ['.'],
},
locales: [
['zh-CN', '中文'],
['en-US', 'English'],
],
// Because of using GitHub Pages
base: '/',
publicPath: '/',
// alias,
mfsu: {},
// more config: https://d.umijs.org/config
});
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CHANGELOG

----

## 2.10.2 (2021-04-11)

- feat(cli): pinyin cli support group by phrases.
Expand Down
2 changes: 1 addition & 1 deletion CNAME
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pinyin.hotoo.me
pinyin.js.org
57 changes: 29 additions & 28 deletions examples/index.md → EXAMPLE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 演示文档

---
----

<style>
textarea{width:90%; height:100px;}
</style>

### 输入[汉字](?han= 简体中文汉字)
### 输入[汉字](?han=%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%E6%B1%89%E5%AD%97)

<div>
<textarea id="input"></textarea>
Expand All @@ -31,33 +31,34 @@ textarea{width:90%; height:100px;}
</div>


<script type="text/spm">
var pinyin = require('pinyin');
//var Url = require('url');
```jsx
import pinyin from 'pinyin';
import Url from 'aurl';

var $ = function(id){return document.getElementById(id);}
var styles = document.getElementsByName("style");
//var han = new Url(location.href).getParam("han");
var han = "中文"
setTimeout(function() {
var $$ = function(id){return document.getElementById(id);}
var styles = document.getElementsByName("style");
var han = new Url(location.href).getParam("han") || '中文';

function build(){
var han = $("input").value;
var style = "STYLE_TONE";
for(var i=0,l=styles.length; i<l; i++){
if(styles[i].checked){
style = styles[i].value;
function build(){
var han = $$("input").value;
var style = "STYLE_TONE";
for(var i=0,l=styles.length; i<l; i++){
if(styles[i].checked){
style = styles[i].value;
}
}
$$("output").value = pinyin(han, {
style: pinyin[style]
}).join(" ");
};

$$("input").onkeyup = build;
for(var i=0,l=styles.length; i<l; i++){
styles[i].onclick = build;
}
$("output").value = pinyin(han, {
style: pinyin[style]
}).join(" ");
};

$("input").onkeyup = build;
for(var i=0,l=styles.length; i<l; i++){
styles[i].onclick = build;
}

$("input").value = han;
build();
</script>

$$("input").value = han;
build();
}, 100);
```
File renamed without changes.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# 汉字拼音转换工具。
# README

---
pinyin, 汉字拼音转换工具。

----

[![NPM version][npm-badge]][npm-url]
[![Build Status][build-badge]][build-url]
Expand All @@ -27,7 +29,7 @@
>
> Python 版请关注 [mozillazg/python-pinyin](https://github.com/mozillazg/python-pinyin)
---
----

## 特性

Expand All @@ -41,7 +43,7 @@
via npm:

```bash
npm install pinyin
npm install pinyin --save
```

## 用法
Expand Down Expand Up @@ -170,7 +172,7 @@ wǒ xǐhuān nǐ

## Test

```
```bash
npm test
```

Expand Down Expand Up @@ -205,7 +207,7 @@ const sortedData = data.sort(pinyin.compare);

如果默认的比较方法不能满足你的需求,你可以自定义 pinyinCompare 方法:

```
```js
const pinyin = require('pinyin');

const data = '我要排序'.split('');
Expand Down
Binary file added assets/pinyin-favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pinyin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"url": "https://github.com/hotoo/pinyin/issues"
},
"scripts": {
"start": "dumi dev",
"doc:build": "dumi build",
"doc:deploy": "npm run doc:build && cp CNAME docs-dist/dist && gh-pages -d docs-dist/dist",
"lint": "eslint ./lib/ ./bin/ ./tests/",
"test-cli": "mocha -R spec --timeout 5000 tests/cli.test.js",
"test-npm": "istanbul cover _mocha -- --harmony --reporter spec --timeout 2000 --inline-diffs ./tests/test.js",
Expand All @@ -49,11 +52,17 @@
"nodejieba": "^2.2.1"
},
"devDependencies": {
"aurl": "^1.2.0",
"aws-sdk": "^2.1011.0",
"benchmark": "~1.0.0",
"dumi": "^1.1.30",
"eslint": "~0.24.0",
"expect.js": "~0.3.1",
"gh-pages": "^3.2.3",
"istanbul": "~0.3.17",
"mocha": "^8.3.2",
"mock-aws-s3": "^4.0.2",
"nock": "^13.1.4",
"request": "~2.68.0"
},
"license": "MIT"
Expand Down

0 comments on commit 02f0417

Please sign in to comment.