Skip to content
This repository was archived by the owner on Sep 6, 2020. It is now read-only.

Commit fd5f2c9

Browse files
committed
更新
1 parent a59c8fe commit fd5f2c9

16 files changed

+210
-275
lines changed

.fatherrc.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { IBundleOptions } from 'father-build';
22

33
const options: IBundleOptions = {
4-
esm: 'babel',
4+
entry: 'src/index.ts',
5+
esm: {
6+
type: 'babel',
7+
importLibToEs: true,
8+
},
9+
cjs: 'babel',
10+
extraBabelPlugins: [['import', { libraryName: 'antd', style: true }]],
511
disableTypeCheck: true,
612
preCommit: {
713
eslint: true,
814
prettier: true,
9-
}
15+
},
1016
};
1117

1218
export default options;

.umirc.ts

+32-20
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { defineConfig } from 'umi';
44
// const isSite = REACT_APP_ENV !== 'dev';
55

66
export default defineConfig({
7-
// history: 'hash',
87
hash: true,
8+
history: {
9+
type: 'hash',
10+
},
911
//dynamicImport: {},
1012
base: '/core',
1113
publicPath: '/core/',
@@ -18,25 +20,35 @@ export default defineConfig({
1820
includes: ['docs'],
1921
previewLangs: [], // tsx、jsx
2022
},
21-
// navs: [
22-
// null,
23-
// {
24-
// title: 'v2.x',
25-
// path: 'https://v2.umijs.org',
26-
// },
27-
// {
28-
// title: 'GitHub',
29-
// path: 'https://github.com/umijs/umi',
30-
// },
31-
// ],
32-
scripts: [
33-
// 由于github不支持url重写,history-route模式下会跳转到404 404页面会对路由进行处理将路由转换成?path=xxx/xxx这种形式,首页需要对这种进行处理通过window.g_history.push()进行跳转
34-
`(function(g_history){
35-
if(g_history&&g_history.location&&g_history.location.query&&g_history.location.query.path){
36-
var hash=g_history.location.hash
37-
g_history.push({pathname:g_history.location.query.path,hash:hash})
38-
}
39-
}(window.g_history))`,
23+
navs: [
24+
null,
25+
{
26+
title: 'component',
27+
path: 'https://wetrial.github.io/component',
28+
},
29+
{
30+
title: 'hooks',
31+
path: 'https://wetrial.github.io/hooks',
32+
},
4033
],
34+
extraBabelPlugins: [
35+
[
36+
'import',
37+
{
38+
libraryName: 'antd',
39+
libraryDirectory: 'es',
40+
style: 'css',
41+
},
42+
],
43+
],
44+
// scripts: [
45+
// // 由于github不支持url重写,history-route模式下会跳转到404 404页面会对路由进行处理将路由转换成?path=xxx/xxx这种形式,首页需要对这种进行处理通过window.g_history.push()进行跳转
46+
// `(function(g_history){
47+
// if(g_history&&g_history.location&&g_history.location.query&&g_history.location.query.path){
48+
// var hash=g_history.location.hash
49+
// g_history.push({pathname:g_history.location.query.path,hash:hash})
50+
// }
51+
// }(window.g_history))`,
52+
// ],
4153
//plugins: ['@umijs/plugin-qiankun'],
4254
});

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ npm i @wetrial/core --save
2626
## 🔨 使用
2727

2828
```
29-
import { request } from '@wetrial/core';
29+
import { get } from '@wetrial/core';
3030
```
3131

3232
## 🖥 开发
@@ -40,6 +40,10 @@ $ npm start
4040

4141
打开浏览器访问 http://127.0.0.1:8001
4242

43+
## 说明
44+
45+
库中只会将高频使用的方法在 index 中导出,其他的需要全名引用,如:`import validationMessage from '@wetrial/core/es/validation'`
46+
4347
## 🤝 贡献
4448

4549
我们欢迎所有人参与共建,请参考[CONTRIBUTING.MD](https://github.com/wetrial/core/blob/master/CONTRIBUTING.MD)

docs/authority.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
title: 权限相关
3-
order: 1
4-
group:
5-
title: 权限相关
6-
path: /authority
7-
order: 1
3+
order: 50
84
nav:
9-
title: 权限相关
10-
path: /authority
11-
order: 1
5+
title: 核心
6+
path: /list
7+
group:
8+
title: 通用
9+
path: /common
10+
legacy: /common/authority
1211
---
1312

1413
# authority 权限相关
@@ -18,7 +17,7 @@ nav:
1817
## 使用方式
1918

2019
```tsx |pure
21-
import { setToken, getToken } from '@wetrial/core/authority';
20+
import { setToken, getToken } from '@wetrial/core/es/authority';
2221

2322
const token = getToken();
2423
```

docs/exception.md

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
2-
title: 异常
3-
order: 1
4-
group:
5-
title: 异常
6-
path: /exception
7-
order: 5
2+
title: exception
3+
order: 40
84
nav:
9-
title: dva基类
10-
path: /exception
11-
order: 5
5+
title: 核心
6+
path: /list
7+
group:
8+
title: 通用
9+
path: /common
10+
legacy: /common/exception
1211
---
1312

1413
# exception 基础异常类
@@ -18,7 +17,7 @@ nav:
1817
## 使用方式
1918

2019
```tsx |pure
21-
import { UnAuthorizedException, UserFriendlyException } from '@wetrial/core/exception';
20+
import { UnAuthorizedException, UserFriendlyException } from '@wetrial/core/es/exception';
2221

2322
throw new UnAuthorizedException();
2423
```

docs/model.md

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
2-
title: dva基类
3-
order: 1
4-
group:
5-
title: dva基类
6-
path: /model
7-
order: 4
2+
title: dva model
3+
order: 30
84
nav:
9-
title: dva基类
10-
path: /model
11-
order: 4
5+
title: 核心
6+
path: /list
7+
group:
8+
title: 通用
9+
path: /common
10+
legacy: /common/model
1211
---
1312

1413
# model model 基础类
@@ -18,7 +17,7 @@ nav:
1817
## 使用方式
1918

2019
```tsx |pure
21-
import extend from '@wetrial/core/model';
20+
import extend from '@wetrial/core';
2221

2322
export interface IAccountModelState {
2423
currentUser?: any;

docs/request.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
title: ajax
33
order: 1
4-
group:
5-
title: ajax
6-
path: /request
7-
order: 5
84
nav:
9-
title: ajax
10-
path: /request
11-
order: 6
5+
title: 核心
6+
path: /list
7+
group:
8+
title: 通用
9+
path: /common
10+
legacy: /common/request
1211
---
1312

1413
# request ajax 请求
@@ -23,14 +22,14 @@ import {
2322
addResponseInterceptor,
2423
commonRequestInterceptor,
2524
commonResponseInterceptor,
26-
} from '@wetrial/core/request';
25+
} from '@wetrial/core/es/request';
2726

2827
// 添加请求拦截器(自动带上Authority请求头)
2928
addRequestInterceptor(...commonRequestInterceptor);
3029
// 添加响应拦截器(处理tip、全局错误等)
3130
addResponseInterceptor(...commonResponseInterceptor);
3231

33-
export { request, get, post, put, patch } from '@wetrial/core/request';
32+
export { request, get, post, put, patch } from '@wetrial/core';
3433
```
3534

3635
## 使用方式

docs/store.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
title: 本地存储
3-
order: 1
4-
group:
5-
title: 本地存储
6-
path: /store
7-
order: 3
3+
order: 20
84
nav:
9-
title: 本地存储
10-
path: /store
11-
order: 3
5+
title: 核心
6+
path: /list
7+
group:
8+
title: 通用
9+
path: /common
10+
legacy: /common/store
1211
---
1312

1413
# store 本地存储
@@ -18,7 +17,7 @@ nav:
1817
## 使用方式
1918

2019
```tsx |pure
21-
import store from '@wetrial/core/store';
20+
import store from '@wetrial/core/es/store';
2221

2322
store.set('', '');
2423
```

docs/utils.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
title: 辅助方法
3-
order: 1
4-
group:
5-
title: 辅助方法
6-
path: /utils
7-
order: 1
3+
order: 10
84
nav:
9-
title: 辅助方法
10-
path: /utils
11-
order: 1
5+
title: 核心
6+
path: /list
7+
group:
8+
title: 通用
9+
path: /common
10+
legacy: /common/utils
1211
---
1312

1413
# utils 辅助方法
@@ -18,7 +17,7 @@ nav:
1817
## 使用方式
1918

2019
```tsx |pure
21-
import { isPromise } from '@wetrial/core/utils';
20+
import { isPromise } from '@wetrial/core/es/utils';
2221

2322
const isP = isPromise(()=>{
2423
return new Promise(resolve=>{
@@ -29,10 +28,11 @@ const isP = isPromise(()=>{
2928

3029
## Methods
3130

32-
| 名称 | 描述 | 类型 |
33-
| --------- | ------------------------ | ------------------------- |
34-
| urlToList | 将路由转成 list 形式 | `(url?:string)=>string[]` |
35-
| isPromise | 判断是否是 Promise 对象 | `(obj)=>boolean` |
36-
| isUrl | 判断是否是一个合法的 url | `(path:string)=>boolean` |
37-
| getQuery | 获取查询字符串 | `(query?:string)=>Object` |
38-
| isBrowser | 判断是否是浏览器环境 | `()=>boolean` |
31+
| 名称 | 描述 | 类型 |
32+
| ---------- | ------------------------ | ------------------------- |
33+
| urlToList | 将路由转成 list 形式 | `(url?:string)=>string[]` |
34+
| isPromise | 判断是否是 Promise 对象 | `(obj)=>boolean` |
35+
| isUrl | 判断是否是一个合法的 url | `(path:string)=>boolean` |
36+
| getQuery | 获取查询字符串 | `(query?:string)=>Object` |
37+
| isBrowser | 判断是否是浏览器环境 | `()=>boolean` |
38+
| listToFlat | 将列表字典转换成对象 | `(any[])=>Object` |

docs/validation.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
title: 验证
3-
order: 10
4-
group:
5-
title: 验证
6-
path: /authority
7-
order: 2
3+
order: 100
84
nav:
9-
title: 验证
10-
path: /authority
11-
order: 2
5+
title: 核心
6+
path: /list
7+
group:
8+
title: 通用
9+
path: /common
10+
legacy: /common/validation
1211
---
1312

1413
# validation 验证

docs/validation/demo/demo1.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { ConfigProvider, Form, Input, InputNumber, Button } from 'antd';
3-
import validateMessages from '@wetrial/core/validation';
3+
import validateMessages from '@wetrial/core/es/validation';
44

55
const layout = {
66
labelCol: { span: 4 },
@@ -11,11 +11,11 @@ const tailLayout = {
1111
};
1212

1313
export default () => {
14-
const onFinish = values => {
14+
const onFinish = (values) => {
1515
console.log('Success:', values);
1616
};
1717

18-
const onFinishFailed = errorInfo => {
18+
const onFinishFailed = (errorInfo) => {
1919
console.log('Failed:', errorInfo);
2020
};
2121

0 commit comments

Comments
 (0)