Skip to content

Commit 66b02b0

Browse files
committed
更新ts标准 增加Hide方法 隐藏显示
1 parent bde685f commit 66b02b0

File tree

13 files changed

+315
-109
lines changed

13 files changed

+315
-109
lines changed

index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export { default as isFile } from './lib/isFile'
1010
export { default as isFunction } from './lib/isFunction'
1111
export { default as isNil } from './lib/isNil'
1212
export { default as isNull } from './lib/isNull'
13+
export { default as isFormData } from './lib/isFormData'
1314
export { default as isNumber } from './lib/isNumber'
1415
export { default as isObject } from './lib/isObject'
1516
export { default as isString } from './lib/isString'
@@ -19,4 +20,6 @@ export { default as omit } from './lib/omit'
1920
export { default as PreLoad } from './lib/PreLoad'
2021
export { default as unitConvert } from './lib/unitConvert'
2122
export { default as verify } from './lib/verify'
22-
export { default as wxPay, IwxPayProps, IWxPayConfig } from './lib/wxPay'
23+
export { default as wxPay } from './lib/wxPay'
24+
// export type { IwxPayProps, IWxPayConfig } from './sources/plugs/wxPay'
25+
export { default as Hide } from './lib/Hide'

lib/Hide.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Hide from '../sources/plugs/Hide'
2+
export default Hide

lib/isFormData.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import isFormData from '../sources/type/isFormData'
2+
export default isFormData

lib/wxPay.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
import wxPay from '../sources/plugs/wxPay'
22
export default wxPay
3-
export * from '../sources/plugs/wxPay'

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"name": "muka",
33
"dependencies": {
44
"@types/axios": "^0.14.0",
5-
"axios": "^0.18.0",
6-
"tslint-react": "^3.5.1"
5+
"axios": "^0.19.2",
6+
"tslint": "^6.1.1",
7+
"tslint-react": "^5.0.0"
78
},
89
"version": "0.2.3"
910
}

sources/browser/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ const browser: IBrowser = Object.create(null, {
8686
// 获得浏览器传递的参数
8787
search: {
8888
get() {
89-
let search = location.search
89+
let search = window.location.search
9090
if (search) {
91-
search = location.search.substr(1)
91+
search = window.location.search.substr(1)
9292
} else {
9393
// 没有得到可能是单页面应用从#后截取
94-
const query = location.hash.split('?')
94+
const query = window.location.hash.split('?')
9595
try {
9696
if (query[1]) {
9797
search = query[1]

sources/browser/search.ts

Whitespace-only changes.

sources/extends/observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class Observer {
2323
}
2424
}
2525

26-
public publish(event: string, ...arg: any[]) {
26+
public publish(event: string, ...arg: any) {
2727
const keys: string[] = Object.keys(this.subscribes)
2828
if (hash(keys, event)) {
2929
this.subscribes[event].map((callback: () => void) => {

sources/plugs/Hide.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function hidden(str: string, frontLen: number, endLen: number, mark: string) {
2+
const num = endLen - frontLen
3+
let sign = ''
4+
for (let i = 0; i < num; i++) {
5+
sign += mark
6+
}
7+
return str.substring(0, frontLen) + sign + str.substring(endLen)
8+
}
9+
10+
/**
11+
* 字符串符号替换
12+
* 用于不显示完整信息
13+
*/
14+
export default class Hide {
15+
16+
public static fullName(name: string, mark?: string): string {
17+
mark = mark ?? '*'
18+
const length = name.length > 2 ? 2 : name.length
19+
return hidden(name, 0, name.length === 2 ? 1 : length, mark)
20+
}
21+
22+
public static card(name: string, mark?: string): string {
23+
mark = mark ?? '*'
24+
return hidden(name, 4, 14, mark)
25+
}
26+
27+
}

sources/plugs/PreLoad.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class PreLoad {
1212
* 加载文件数据
1313
*/
1414
// tslint:disable-next-line: array-type
15-
private loads: (string | ArrayBuffer | WindowBase64 | undefined | null)[] = []
15+
private loads: (string | ArrayBuffer | undefined | null)[] = []
1616

1717
/**
1818
* 图片类型
@@ -38,10 +38,10 @@ export default class PreLoad {
3838
private count: number = 0
3939

4040
// tslint:disable-next-line: array-type
41-
constructor(imgs: (string | WindowBase64 | ArrayBuffer | undefined | null)[] = []) {
41+
constructor(imgs: (string | ArrayBuffer | undefined | null)[] = []) {
4242
this.loads = imgs
4343
this.count = imgs.length
44-
this.loads.forEach((item: string | WindowBase64 | ArrayBuffer | undefined | null) => {
44+
this.loads.forEach((item: string | ArrayBuffer | undefined | null) => {
4545
// 获得文件后缀名
4646
if ((item && isString(item))) {
4747
this.pomiseLoads.push(this.getExtLoad(item))
@@ -53,7 +53,7 @@ export default class PreLoad {
5353
* 已经缓存过的文件会触发回调
5454
*/
5555

56-
public completeLoad: (load: (string | WindowBase64 | ArrayBuffer | undefined | null)) => void = () => { return }
56+
public completeLoad: (load: (string | ArrayBuffer | undefined | null)) => void = () => { return }
5757

5858
/**
5959
* 加载中的回调
@@ -66,7 +66,7 @@ export default class PreLoad {
6666
*/
6767

6868
// tslint:disable-next-line: array-type
69-
public success: (loads: (string | WindowBase64 | ArrayBuffer | undefined)[], pomiseLoads: Array<Promise<{} | void>>) => void = () => { this.clearAsync() }
69+
public success: (loads: (string | ArrayBuffer | undefined)[], pomiseLoads: Array<Promise<{} | void>>) => void = () => { this.clearAsync() }
7070

7171
/**
7272
* 清除没有完成的异步事件

0 commit comments

Comments
 (0)