@haluo/util 2.0.7 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +34 -20
- package/dist/modules/cookie/index.js +4 -3
- package/dist/modules/date/index.js +12 -12
- package/dist/modules/dom/index.js +2 -2
- package/dist/modules/filter/index.js +11 -20
- package/dist/modules/format/index.js +2 -1
- package/dist/modules/match/index.js +1 -1
- package/dist/modules/monitor/index.js +2 -2
- package/dist/modules/monitor/lib/jsError.js +5 -13
- package/dist/modules/monitor/lib/timing.js +1 -1
- package/dist/modules/monitor/lib/xhr.js +2 -4
- package/dist/modules/monitor/utils/tracker.js +2 -23
- package/dist/modules/number/index.js +5 -4
- package/dist/modules/sentry/index.js +9 -6
- package/dist/modules/tools/index.js +5 -5
- package/dist/tsconfig.tsbuildinfo +1 -2915
- package/dist/types/index.d.ts +24 -3
- package/dist/types/modules/cookie/index.d.ts +2 -0
- package/dist/types/modules/date/index.d.ts +52 -1
- package/dist/types/modules/dom/index.d.ts +28 -1
- package/dist/types/modules/filter/index.d.ts +4 -6
- package/dist/types/modules/format/index.d.ts +2 -0
- package/dist/types/modules/match/index.d.ts +12 -1
- package/dist/types/modules/monitor/utils/tracker.d.ts +0 -1
- package/dist/types/modules/number/index.d.ts +3 -1
- package/dist/types/modules/tools/index.d.ts +166 -1
- package/package.json +6 -2
- package/dist/index.cjs.js +0 -89
- package/dist/index.d.ts +0 -12
- package/dist/index.esm.js +0 -87
- package/dist/lib-list.d.ts +0 -2
- package/dist/modules/cookie/index.d.ts +0 -27
- package/dist/modules/date/index.d.ts +0 -1
- package/dist/modules/dom/index.d.ts +0 -1
- package/dist/modules/filter/index.d.ts +0 -26
- package/dist/modules/format/index.d.ts +0 -13
- package/dist/modules/match/index.d.ts +0 -1
- package/dist/modules/number/index.d.ts +0 -39
- package/dist/modules/sentry/index.d.ts +0 -15
- package/dist/modules/tools/index.d.ts +0 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
import cookie from './modules/cookie';
|
|
2
|
+
import date from './modules/date';
|
|
3
|
+
import dom from './modules/dom';
|
|
4
|
+
import filter from './modules/filter';
|
|
5
|
+
import format from './modules/format';
|
|
6
|
+
import match from './modules/match';
|
|
7
|
+
import number from './modules/number';
|
|
8
|
+
import tools from './modules/tools';
|
|
9
|
+
interface Modules {
|
|
10
|
+
cookie: typeof cookie;
|
|
11
|
+
date: typeof date;
|
|
12
|
+
dom: typeof dom;
|
|
13
|
+
filter: typeof filter;
|
|
14
|
+
format: typeof format;
|
|
15
|
+
match: typeof match;
|
|
16
|
+
number: typeof number;
|
|
17
|
+
tools: typeof tools;
|
|
18
|
+
}
|
|
2
19
|
declare class Utils {
|
|
3
|
-
[key: string]: Object;
|
|
4
20
|
constructor();
|
|
5
21
|
/**
|
|
6
22
|
* 挂载各组件
|
|
7
23
|
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
8
24
|
* @param {Object} Vue 需要挂载的目标对象
|
|
9
25
|
*/
|
|
10
|
-
install(
|
|
26
|
+
install(app: any): void;
|
|
27
|
+
}
|
|
28
|
+
interface Utils extends Modules {
|
|
11
29
|
}
|
|
30
|
+
declare const _default: Utils;
|
|
31
|
+
export default _default;
|
|
32
|
+
export { cookie, date, dom, filter, format, match, number, tools, };
|
|
@@ -1 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
declare class DateClass {
|
|
2
|
+
/**
|
|
3
|
+
* 格式化时间
|
|
4
|
+
* @param {String|Number} date 需要格式化的时间 2017-11-11、2017/11/11、linux time
|
|
5
|
+
* @param {String} fmt 想要格式化的格式 'YYYY-MM-DD HH:mm:ss'、'YYYY-MM-DD'、'YYYY年MM月DD日 HH时mm分ss秒'、'YYYY年MM月DD日'
|
|
6
|
+
* date.format(new Date()) // 默认格式 'YYYY-MM-DD HH:mm:ss'
|
|
7
|
+
* date.format(1586840260500) // 默认格式,传参为linux时间
|
|
8
|
+
* date.format(new Date(), 'YYYY:MM:DD') // 自定义格式 'YYYY:MM:DD'
|
|
9
|
+
* @return {String} fmt 'YYYY-MM-DD HH:mm:ss'
|
|
10
|
+
*/
|
|
11
|
+
format(date: string | number, fmt?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* 天数加减
|
|
14
|
+
* @param {string | Date} date 传入的时间 2020-10-15 or Date
|
|
15
|
+
* @param {String} days 天数
|
|
16
|
+
* addDaysToDate('2020-10-15', 10) // '2020-10-25'
|
|
17
|
+
* addDaysToDate('2020-10-15', -10) // '2020-10-05'
|
|
18
|
+
* @return {String} fmt 'YYYY-MM-DD'
|
|
19
|
+
*/
|
|
20
|
+
addDaysToDate(date: string | Date, days: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* 获取倒计时剩余时间
|
|
23
|
+
* @param {Date | Number} endTime 截止时间
|
|
24
|
+
* @param {Date | Number} startTime 开始时间,默认取客户端当前时间
|
|
25
|
+
* date.format(new Date()) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
|
|
26
|
+
* date.format(1586840260500) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
|
|
27
|
+
* @return {object | boolean} {dd: '天', hh: '时', mm: '分', ss: '秒'}
|
|
28
|
+
*/
|
|
29
|
+
remainTime(endTime: Date | Number, startTime?: Date | Number): object | boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 格式化现在的已过时间
|
|
32
|
+
* @param {Number} startTime
|
|
33
|
+
* @return {String} *年前 *个月前 *天前 *小时前 *分钟前 刚刚
|
|
34
|
+
*/
|
|
35
|
+
formatPassTime(startTime: any): string;
|
|
36
|
+
/**
|
|
37
|
+
* 格式化时间 列表里的时间内容格式 待废弃,统一时间格式
|
|
38
|
+
* @param {Number} time 1494141000*1000
|
|
39
|
+
* @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
|
|
40
|
+
*/
|
|
41
|
+
formatPassTimeForList(time: string): string | false;
|
|
42
|
+
/**
|
|
43
|
+
* 格式化时间 详情内容里的时间格式
|
|
44
|
+
* @param {Number} time 1494141000*1000
|
|
45
|
+
* @param {String} fmt 想要格式化的格式
|
|
46
|
+
* @param {Boolean} noYear 是否显示年
|
|
47
|
+
* @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
|
|
48
|
+
*/
|
|
49
|
+
formatPassTimeForDetail(time: string, fmt: string | undefined, noYear: Boolean): string | false;
|
|
50
|
+
}
|
|
51
|
+
declare const _default: DateClass;
|
|
52
|
+
export default _default;
|
|
@@ -1 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import { IObjectKey } from '../../types/index';
|
|
2
|
+
interface IDom {
|
|
3
|
+
name: string;
|
|
4
|
+
innerHTML?: string;
|
|
5
|
+
style?: IObjectKey<string>;
|
|
6
|
+
parent?: string;
|
|
7
|
+
}
|
|
8
|
+
declare class DomClass {
|
|
9
|
+
/**
|
|
10
|
+
* 创建一个子元素并添加至父节点
|
|
11
|
+
* @param {Object} { name = 'div', innerHTML = '', style = {}, parent, }
|
|
12
|
+
* @return {String}
|
|
13
|
+
*/
|
|
14
|
+
createElement({ name, innerHTML, style, parent, }: IDom): any;
|
|
15
|
+
/**
|
|
16
|
+
* 获取文本中的url并用a标签包裹
|
|
17
|
+
* @param {Object} ICookie
|
|
18
|
+
*/
|
|
19
|
+
wrapperA(text: string): string | Error;
|
|
20
|
+
/**
|
|
21
|
+
* 对象转化为formdata
|
|
22
|
+
* getFormData({a: 1, b: 2})
|
|
23
|
+
* @param {Object} object
|
|
24
|
+
*/
|
|
25
|
+
getFormData(object: IObjectKey<any>): FormData;
|
|
26
|
+
}
|
|
27
|
+
declare const _default: DomClass;
|
|
28
|
+
export default _default;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
declare const dateClass: any;
|
|
2
|
-
declare const numberClass: any;
|
|
3
|
-
declare const toolsClass: any;
|
|
4
1
|
declare class FilterClass {
|
|
5
2
|
/**
|
|
6
3
|
* 格式化时间,示例:1586840260500 | format('YYYY-MM-DD HH:mm:ss')
|
|
@@ -8,7 +5,7 @@ declare class FilterClass {
|
|
|
8
5
|
* @param {String} fmt 'YYYY-MM-DD HH:mm:ss'
|
|
9
6
|
* @return {String} 'YYYY-MM-DD HH:mm:ss'
|
|
10
7
|
*/
|
|
11
|
-
format(date: string | number, fmt?: string):
|
|
8
|
+
format(date: string | number, fmt?: string): string;
|
|
12
9
|
/**
|
|
13
10
|
* 格式化金额,示例:123456 | formatMoney
|
|
14
11
|
* @param {Number} num
|
|
@@ -21,6 +18,7 @@ declare class FilterClass {
|
|
|
21
18
|
* @param {Number} length 截取长度,从0开始
|
|
22
19
|
* @return {any}
|
|
23
20
|
*/
|
|
24
|
-
slice(target?: Array<any> | string, length?: number): any;
|
|
25
|
-
install(Vue: any): void;
|
|
21
|
+
slice(target?: Array<any> | string, length?: number): string | any[];
|
|
26
22
|
}
|
|
23
|
+
declare const _default: FilterClass;
|
|
24
|
+
export default _default;
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
declare class MatchClass {
|
|
2
|
+
/**
|
|
3
|
+
* 根据类型返回正则
|
|
4
|
+
* @param {String} str 检测的内容
|
|
5
|
+
* @param {String} type 检测类型
|
|
6
|
+
* checkType('10.120.33.11', 'ip') // true
|
|
7
|
+
* @return {Boolean} true or false
|
|
8
|
+
*/
|
|
9
|
+
checkType(str: string, type: string): boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: MatchClass;
|
|
12
|
+
export default _default;
|
|
@@ -35,5 +35,7 @@ declare class NumberClass {
|
|
|
35
35
|
* @param {Number} num
|
|
36
36
|
* @return {String} 123,456
|
|
37
37
|
*/
|
|
38
|
-
formatMoney(money: number | string, signal
|
|
38
|
+
formatMoney(money: number | string, signal?: string): string;
|
|
39
39
|
}
|
|
40
|
+
declare const _default: NumberClass;
|
|
41
|
+
export default _default;
|
|
@@ -1 +1,166 @@
|
|
|
1
|
-
|
|
1
|
+
import { IObjectKey } from '../../types/index';
|
|
2
|
+
declare class ToolsClass {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
constructor();
|
|
5
|
+
/**
|
|
6
|
+
* 深拷贝 Object|Array
|
|
7
|
+
* 深拷贝,支持 普通对象、数组,但是未解决Function、Date、RegExp,且1M以上数据性能不好
|
|
8
|
+
* @param {String} data
|
|
9
|
+
* @return {Object}
|
|
10
|
+
*/
|
|
11
|
+
deepCopy(data: object): object;
|
|
12
|
+
/**
|
|
13
|
+
* 深拷贝 Object|Array
|
|
14
|
+
* 支持 普通对象、数组和函数的深复制,但是未解决循环引用、Date、RegExp
|
|
15
|
+
* @param {Object|Array} data
|
|
16
|
+
* @return {Object}
|
|
17
|
+
*/
|
|
18
|
+
deepCopy2<T>(obj: T): T;
|
|
19
|
+
/**
|
|
20
|
+
* 深拷贝 Object|Array
|
|
21
|
+
* 注意:需要 yarn add lodash
|
|
22
|
+
* @param {Object|Array} data
|
|
23
|
+
* @return {Object}
|
|
24
|
+
*/
|
|
25
|
+
deepCopy3(obj: any): any;
|
|
26
|
+
/**
|
|
27
|
+
* 防抖
|
|
28
|
+
* demo:debounce(func, 300)(args)
|
|
29
|
+
* @param {Function} func 执行函数
|
|
30
|
+
* @param {Number} wait 节流时间,毫秒
|
|
31
|
+
* @return {Function} delay
|
|
32
|
+
*/
|
|
33
|
+
debounce(func: Function, wait: number): () => void;
|
|
34
|
+
/**
|
|
35
|
+
* 节流
|
|
36
|
+
* demo:throttle(func, 300)(args)
|
|
37
|
+
* @param {Object|Array} func 执行函数
|
|
38
|
+
* @param {Number} wait 节流时间,毫秒
|
|
39
|
+
* @return {Function} delay
|
|
40
|
+
*/
|
|
41
|
+
throttle(func: Function, wait: number): () => void;
|
|
42
|
+
/**
|
|
43
|
+
* 获取路径中文件名称
|
|
44
|
+
* @param {String} url
|
|
45
|
+
* @return {String}
|
|
46
|
+
*/
|
|
47
|
+
getUrlName(url: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* 动态加载脚本
|
|
50
|
+
* tip:按需加载时用(多次调用,js不会重复加载)
|
|
51
|
+
* @param {String} url
|
|
52
|
+
* @return {Promise}
|
|
53
|
+
*/
|
|
54
|
+
loadJs(url: string): Error | Promise<unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* 动态加载样式
|
|
57
|
+
* @param {String} url
|
|
58
|
+
* @return {Promise}
|
|
59
|
+
*/
|
|
60
|
+
loadCss(url: string): Error | Promise<unknown>;
|
|
61
|
+
/**
|
|
62
|
+
* 蒙层显示后,html禁止滚动操作
|
|
63
|
+
* @param {String} className
|
|
64
|
+
* @return {Void}
|
|
65
|
+
*/
|
|
66
|
+
stopScroll: (className: string) => Error | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* 蒙层隐藏后,html开启滚动操作
|
|
69
|
+
* @param {String} className
|
|
70
|
+
* @return {Void}
|
|
71
|
+
*/
|
|
72
|
+
startScroll: (className: string) => Error | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* 字符串复制到剪贴板
|
|
75
|
+
* 注意:需要 yarn add clipboard-copy
|
|
76
|
+
* @param {String} str
|
|
77
|
+
* @return {String}
|
|
78
|
+
*/
|
|
79
|
+
clipboard(str: string): any;
|
|
80
|
+
/**
|
|
81
|
+
* 首字母大写
|
|
82
|
+
* @param {String} str
|
|
83
|
+
* @return {String}
|
|
84
|
+
*/
|
|
85
|
+
firstUpperCase(str: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* 截取数组或字符串,示例:slice('1234', 3)
|
|
88
|
+
* @param {Array|String} target 数组或字符串
|
|
89
|
+
* @param {Number} length 截取长度,从0开始
|
|
90
|
+
* @return {any}
|
|
91
|
+
*/
|
|
92
|
+
slice(target?: Array<any> | string, length?: number): string | any[];
|
|
93
|
+
/**
|
|
94
|
+
* 获取guid
|
|
95
|
+
* @return {String}
|
|
96
|
+
*/
|
|
97
|
+
guid(): string;
|
|
98
|
+
/**
|
|
99
|
+
* 获取文本字节数(含中文)
|
|
100
|
+
* @param {String} str
|
|
101
|
+
* @return {String}
|
|
102
|
+
*/
|
|
103
|
+
getBytesOfText(str?: string): number;
|
|
104
|
+
/**
|
|
105
|
+
* object 对象转 array 数组
|
|
106
|
+
* demo:
|
|
107
|
+
* objectToArray({a:1,b:2}) 输出:["a=1", "b=2"]
|
|
108
|
+
* @param {Object} obj
|
|
109
|
+
* @returns {Array} arr
|
|
110
|
+
*/
|
|
111
|
+
objectToArray: (obj: IObjectKey<string>) => Array<string>;
|
|
112
|
+
/**
|
|
113
|
+
* convertEnum
|
|
114
|
+
* 枚举键值互换
|
|
115
|
+
* @param {Object} obj
|
|
116
|
+
* convertKeyValueEnum({a: 1, b: 2}) // {1: "a", 2: "b"}
|
|
117
|
+
* @returns {Object} result
|
|
118
|
+
*/
|
|
119
|
+
convertKeyValueEnum: (obj: IObjectKey<string>) => IObjectKey<string>;
|
|
120
|
+
/**
|
|
121
|
+
* 数组去重
|
|
122
|
+
* @param {Array} arr
|
|
123
|
+
* @returns {Array}
|
|
124
|
+
*/
|
|
125
|
+
uniqueArr(arr: Array<any>): Array<any>;
|
|
126
|
+
/**
|
|
127
|
+
* 数组元素交换位置
|
|
128
|
+
* index1和index2分别是两个数组的索引值,即是两个要交换元素位置的索引值,如1,5就是数组中下标为1和5的两个元素交换位置
|
|
129
|
+
* @param {Array<string | number>} array 数组
|
|
130
|
+
* @param {number} index1 添加项目的位置
|
|
131
|
+
* @param {number} index2 删除项目的位置
|
|
132
|
+
* swapArray([1, 2, 3, 4], 2, 3) // [1, 2, 4, 3]
|
|
133
|
+
* @returns {Array<string | number>} array
|
|
134
|
+
*/
|
|
135
|
+
swapArray(array: Array<string | number>, index1: number, index2: number): Array<string | number>;
|
|
136
|
+
/**
|
|
137
|
+
* 过滤表情符号
|
|
138
|
+
* @param {String} str
|
|
139
|
+
* @return {String}
|
|
140
|
+
*/
|
|
141
|
+
filterEmoji(str: string): string;
|
|
142
|
+
/**
|
|
143
|
+
* 是否包含表情
|
|
144
|
+
* @param {String} str
|
|
145
|
+
* @return {boolean}
|
|
146
|
+
*/
|
|
147
|
+
containsEmoji(str: string): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* 是否包含表汉字
|
|
150
|
+
* @param {String} str
|
|
151
|
+
* @return {boolean}
|
|
152
|
+
*/
|
|
153
|
+
containsHanZi(str: string): boolean;
|
|
154
|
+
isEmpty(val: any): boolean;
|
|
155
|
+
isDefined: (val: any) => boolean;
|
|
156
|
+
/**
|
|
157
|
+
* 字段脱敏处理
|
|
158
|
+
* @param {String} field 未脱敏字段
|
|
159
|
+
* @param {Int} before 开头未脱敏字符数
|
|
160
|
+
* @param {Int} after 结尾未脱敏字符数
|
|
161
|
+
* @return {String} 已脱敏字段
|
|
162
|
+
*/
|
|
163
|
+
sensitiveField(field: string | number, before?: number, after?: number): string;
|
|
164
|
+
}
|
|
165
|
+
declare const _default: ToolsClass;
|
|
166
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haluo/util",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "<wanghui@jddmoto.com>",
|
|
6
6
|
"description": "摩托范工具库",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"build:webpack": "webpack --config ./build/webpack.pro.config.js",
|
|
9
10
|
"tsc": "tsc",
|
|
11
|
+
"lib": "tsc",
|
|
12
|
+
"pub": "npm publish",
|
|
13
|
+
"pub:next": "npm publish --tag next",
|
|
10
14
|
"test": "jest --config __tests__/unit/jest.conf.js",
|
|
11
15
|
"test:watch": "jest --config __tests__/unit/jest.conf.js --watch --detectOpenHandles",
|
|
12
16
|
"test:coverage": "jest --config __tests__/unit/jest.conf.js --coverage",
|
package/dist/index.cjs.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file Cookie
|
|
5
|
-
* @Author: wanghui
|
|
6
|
-
* @createBy: @2021.01.21
|
|
7
|
-
*/
|
|
8
|
-
var CookieClass = /** @class */ (function () {
|
|
9
|
-
function CookieClass() {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 获取cookie
|
|
13
|
-
* @param {String} name
|
|
14
|
-
* @return {String}
|
|
15
|
-
*/
|
|
16
|
-
CookieClass.prototype.getCookie = function (name) {
|
|
17
|
-
var _name = name + '=';
|
|
18
|
-
var ca = document.cookie.split(';');
|
|
19
|
-
for (var i = 0; i < ca.length; i++) {
|
|
20
|
-
var c = ca[i];
|
|
21
|
-
while (c.charAt(0) === ' ')
|
|
22
|
-
c = c.substring(1);
|
|
23
|
-
if (c.includes(_name))
|
|
24
|
-
return c.substring(_name.length, c.length);
|
|
25
|
-
}
|
|
26
|
-
return '';
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* 设置cookie
|
|
30
|
-
* @param {Object} ICookie
|
|
31
|
-
*/
|
|
32
|
-
CookieClass.prototype.setCookie = function (_a) {
|
|
33
|
-
var _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c, _d = _a.exdays, exdays = _d === void 0 ? -1 : _d, _e = _a.path, path = _e === void 0 ? '/' : _e, _f = _a.domain, domain = _f === void 0 ? '.jddmoto.com' : _f;
|
|
34
|
-
var d = new Date();
|
|
35
|
-
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
|
36
|
-
var expires = "expires=" + d.toUTCString();
|
|
37
|
-
document.cookie = name + "=" + value + ";" + expires + ";path=" + path + ";domain=" + domain + ";";
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* 清除Cookie
|
|
41
|
-
* @param {String} name
|
|
42
|
-
*/
|
|
43
|
-
CookieClass.prototype.clearCookie = function (name) {
|
|
44
|
-
this.setCookie({
|
|
45
|
-
name: name,
|
|
46
|
-
value: '',
|
|
47
|
-
exdays: -1,
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
return CookieClass;
|
|
51
|
-
}());
|
|
52
|
-
var cookie = new CookieClass();
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @Author: wanghui
|
|
56
|
-
* createBy: @2020.05.21
|
|
57
|
-
*/
|
|
58
|
-
// import date from './modules/date'
|
|
59
|
-
// import dom from './modules/dom'
|
|
60
|
-
// import filter from './modules/filter'
|
|
61
|
-
// import format from './modules/format'
|
|
62
|
-
// import match from './modules/match'
|
|
63
|
-
// import number from './modules/number'
|
|
64
|
-
// import tools from './modules/tools'
|
|
65
|
-
var modules = {
|
|
66
|
-
cookie: cookie,
|
|
67
|
-
};
|
|
68
|
-
var Utils = /** @class */ (function () {
|
|
69
|
-
function Utils() {
|
|
70
|
-
Object.assign(this, modules);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* 挂载各组件
|
|
74
|
-
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
75
|
-
* @param {Object} app 需要挂载的目标对象
|
|
76
|
-
*/
|
|
77
|
-
Utils.prototype.install = function (app) {
|
|
78
|
-
Object.keys(modules).forEach(function (key) {
|
|
79
|
-
if (key === 'filter') {
|
|
80
|
-
return modules[key].install(app);
|
|
81
|
-
}
|
|
82
|
-
app.config.globalProperties['$' + key] = modules[key];
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
return Utils;
|
|
86
|
-
}());
|
|
87
|
-
var utils = new Utils();
|
|
88
|
-
|
|
89
|
-
module.exports = utils;
|
package/dist/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare class Utils {
|
|
2
|
-
[key: string]: Object;
|
|
3
|
-
constructor();
|
|
4
|
-
/**
|
|
5
|
-
* 挂载各组件
|
|
6
|
-
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
7
|
-
* @param {Object} app 需要挂载的目标对象
|
|
8
|
-
*/
|
|
9
|
-
install(app: any): void;
|
|
10
|
-
}
|
|
11
|
-
declare const utils: Utils;
|
|
12
|
-
export default utils;
|
package/dist/index.esm.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Cookie
|
|
3
|
-
* @Author: wanghui
|
|
4
|
-
* @createBy: @2021.01.21
|
|
5
|
-
*/
|
|
6
|
-
var CookieClass = /** @class */ (function () {
|
|
7
|
-
function CookieClass() {
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* 获取cookie
|
|
11
|
-
* @param {String} name
|
|
12
|
-
* @return {String}
|
|
13
|
-
*/
|
|
14
|
-
CookieClass.prototype.getCookie = function (name) {
|
|
15
|
-
var _name = name + '=';
|
|
16
|
-
var ca = document.cookie.split(';');
|
|
17
|
-
for (var i = 0; i < ca.length; i++) {
|
|
18
|
-
var c = ca[i];
|
|
19
|
-
while (c.charAt(0) === ' ')
|
|
20
|
-
c = c.substring(1);
|
|
21
|
-
if (c.includes(_name))
|
|
22
|
-
return c.substring(_name.length, c.length);
|
|
23
|
-
}
|
|
24
|
-
return '';
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* 设置cookie
|
|
28
|
-
* @param {Object} ICookie
|
|
29
|
-
*/
|
|
30
|
-
CookieClass.prototype.setCookie = function (_a) {
|
|
31
|
-
var _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c, _d = _a.exdays, exdays = _d === void 0 ? -1 : _d, _e = _a.path, path = _e === void 0 ? '/' : _e, _f = _a.domain, domain = _f === void 0 ? '.jddmoto.com' : _f;
|
|
32
|
-
var d = new Date();
|
|
33
|
-
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
|
34
|
-
var expires = "expires=" + d.toUTCString();
|
|
35
|
-
document.cookie = name + "=" + value + ";" + expires + ";path=" + path + ";domain=" + domain + ";";
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* 清除Cookie
|
|
39
|
-
* @param {String} name
|
|
40
|
-
*/
|
|
41
|
-
CookieClass.prototype.clearCookie = function (name) {
|
|
42
|
-
this.setCookie({
|
|
43
|
-
name: name,
|
|
44
|
-
value: '',
|
|
45
|
-
exdays: -1,
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
return CookieClass;
|
|
49
|
-
}());
|
|
50
|
-
var cookie = new CookieClass();
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @Author: wanghui
|
|
54
|
-
* createBy: @2020.05.21
|
|
55
|
-
*/
|
|
56
|
-
// import date from './modules/date'
|
|
57
|
-
// import dom from './modules/dom'
|
|
58
|
-
// import filter from './modules/filter'
|
|
59
|
-
// import format from './modules/format'
|
|
60
|
-
// import match from './modules/match'
|
|
61
|
-
// import number from './modules/number'
|
|
62
|
-
// import tools from './modules/tools'
|
|
63
|
-
var modules = {
|
|
64
|
-
cookie: cookie,
|
|
65
|
-
};
|
|
66
|
-
var Utils = /** @class */ (function () {
|
|
67
|
-
function Utils() {
|
|
68
|
-
Object.assign(this, modules);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* 挂载各组件
|
|
72
|
-
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
73
|
-
* @param {Object} app 需要挂载的目标对象
|
|
74
|
-
*/
|
|
75
|
-
Utils.prototype.install = function (app) {
|
|
76
|
-
Object.keys(modules).forEach(function (key) {
|
|
77
|
-
if (key === 'filter') {
|
|
78
|
-
return modules[key].install(app);
|
|
79
|
-
}
|
|
80
|
-
app.config.globalProperties['$' + key] = modules[key];
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
return Utils;
|
|
84
|
-
}());
|
|
85
|
-
var utils = new Utils();
|
|
86
|
-
|
|
87
|
-
export { utils as default };
|
package/dist/lib-list.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
interface ICookie {
|
|
2
|
-
name: string;
|
|
3
|
-
value: string;
|
|
4
|
-
exdays: number;
|
|
5
|
-
path?: string;
|
|
6
|
-
domain?: string;
|
|
7
|
-
}
|
|
8
|
-
declare class CookieClass {
|
|
9
|
-
/**
|
|
10
|
-
* 获取cookie
|
|
11
|
-
* @param {String} name
|
|
12
|
-
* @return {String}
|
|
13
|
-
*/
|
|
14
|
-
getCookie(name: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* 设置cookie
|
|
17
|
-
* @param {Object} ICookie
|
|
18
|
-
*/
|
|
19
|
-
setCookie({ name, value, exdays, path, domain, }: ICookie): void;
|
|
20
|
-
/**
|
|
21
|
-
* 清除Cookie
|
|
22
|
-
* @param {String} name
|
|
23
|
-
*/
|
|
24
|
-
clearCookie(name: string): void;
|
|
25
|
-
}
|
|
26
|
-
declare const _default: CookieClass;
|
|
27
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
declare const dateClass: any;
|
|
2
|
-
declare const numberClass: any;
|
|
3
|
-
declare const toolsClass: any;
|
|
4
|
-
declare class FilterClass {
|
|
5
|
-
/**
|
|
6
|
-
* 格式化时间,示例:1586840260500 | format('YYYY-MM-DD HH:mm:ss')
|
|
7
|
-
* @param {String|Number} date
|
|
8
|
-
* @param {String} fmt 'YYYY-MM-DD HH:mm:ss'
|
|
9
|
-
* @return {String} 'YYYY-MM-DD HH:mm:ss'
|
|
10
|
-
*/
|
|
11
|
-
format(date: string | number, fmt?: string): any;
|
|
12
|
-
/**
|
|
13
|
-
* 格式化金额,示例:123456 | formatMoney
|
|
14
|
-
* @param {Number} num
|
|
15
|
-
* @return {String} 123,456
|
|
16
|
-
*/
|
|
17
|
-
formatMoney(money: number | string): string;
|
|
18
|
-
/**
|
|
19
|
-
* 截取数组或字符串,示例:'1234' | slice(3)
|
|
20
|
-
* @param {Array|String} target 数组或字符串
|
|
21
|
-
* @param {Number} length 截取长度,从0开始
|
|
22
|
-
* @return {any}
|
|
23
|
-
*/
|
|
24
|
-
slice(target?: Array<any> | string, length?: number): any;
|
|
25
|
-
install(app: any): void;
|
|
26
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
interface Obj {
|
|
2
|
-
[prop: string]: any;
|
|
3
|
-
}
|
|
4
|
-
declare class Format {
|
|
5
|
-
/**
|
|
6
|
-
* @desc 对于对象非数字与布尔值的value,当其为falsy时,转换成separator
|
|
7
|
-
* @param {object} obj 传入的对象
|
|
8
|
-
* @param {string} separator 替换后的值
|
|
9
|
-
* transformObjectNullVal({ a: null, b: 0}, '23') // {a: "23", b: 0}
|
|
10
|
-
* @return {object}
|
|
11
|
-
*/
|
|
12
|
-
transformObjectNullVal<T extends Obj>(obj: T, separator?: string): T;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|