@haluo/util 2.0.20 → 2.0.21
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 +33 -64
- package/dist/modules/cookie/index.js +18 -24
- package/dist/modules/date/index.js +49 -56
- package/dist/modules/dom/index.js +16 -23
- package/dist/modules/filter/index.js +15 -25
- package/dist/modules/format/index.js +6 -12
- package/dist/modules/match/index.js +6 -10
- package/dist/modules/monitor/index.js +7 -14
- package/dist/modules/monitor/lib/jsError.js +39 -35
- package/dist/modules/monitor/lib/timing.js +24 -28
- package/dist/modules/monitor/lib/xhr.js +26 -33
- package/dist/modules/monitor/utils/onload.js +1 -4
- package/dist/modules/monitor/utils/tracker.js +13 -27
- package/dist/modules/number/index.js +31 -35
- package/dist/modules/open-app/index.js +66 -61
- package/dist/modules/sentry/index.js +19 -27
- package/dist/modules/tools/index.d.ts +1 -1
- package/dist/modules/tools/index.js +158 -169
- package/dist/modules/upload/aliOss.d.ts +97 -45
- package/dist/modules/upload/aliOss.js +437 -575
- package/dist/modules/upload/index.d.ts +46 -1
- package/dist/modules/upload/index.js +41 -12
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.js +1 -2
- package/package.json +15 -4
- package/dist/modules/upload/ALIOSS_EXAMPLE.d.ts +0 -83
- package/dist/modules/upload/ALIOSS_EXAMPLE.js +0 -320
- package/dist/types/modules/cookie/index.d.ts +0 -27
- package/dist/types/modules/date/index.d.ts +0 -52
- package/dist/types/modules/dom/index.d.ts +0 -28
- package/dist/types/modules/filter/index.d.ts +0 -24
- package/dist/types/modules/format/index.d.ts +0 -15
- package/dist/types/modules/match/index.d.ts +0 -12
- package/dist/types/modules/monitor/index.d.ts +0 -3
- package/dist/types/modules/monitor/lib/jsError.d.ts +0 -1
- package/dist/types/modules/monitor/lib/timing.d.ts +0 -1
- package/dist/types/modules/monitor/lib/xhr.d.ts +0 -1
- package/dist/types/modules/monitor/utils/onload.d.ts +0 -1
- package/dist/types/modules/monitor/utils/tracker.d.ts +0 -7
- package/dist/types/modules/number/index.d.ts +0 -41
- package/dist/types/modules/sentry/index.d.ts +0 -15
- package/dist/types/modules/tools/index.d.ts +0 -166
- package/dist/types/types/index.d.ts +0 -3
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file aliOss 使用示例
|
|
4
|
-
* @description 展示如何在项目中使用统一的 aliOss 工具
|
|
5
|
-
*/
|
|
6
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
17
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
|
-
function step(op) {
|
|
20
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
21
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
22
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
23
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
24
|
-
switch (op[0]) {
|
|
25
|
-
case 0: case 1: t = op; break;
|
|
26
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
27
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
28
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
29
|
-
default:
|
|
30
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
31
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
32
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
33
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
34
|
-
if (t[2]) _.ops.pop();
|
|
35
|
-
_.trys.pop(); continue;
|
|
36
|
-
}
|
|
37
|
-
op = body.call(thisArg, _);
|
|
38
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
39
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.uploadShopDetail = exports.uploadIdCard = exports.uploadVideo = exports.uploadAvatar = exports.uploadNormalImage = exports.fullOssUploader = exports.basicOssUploader = void 0;
|
|
44
|
-
var aliOss_1 = require("./aliOss");
|
|
45
|
-
// ============================================
|
|
46
|
-
// 示例1:基础配置(最小配置)
|
|
47
|
-
// ============================================
|
|
48
|
-
var basicOssUploader = (0, aliOss_1.createAliOssUploader)({
|
|
49
|
-
// 必需:获取阿里云STS临时凭证
|
|
50
|
-
getAliyunSts: function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
-
var response;
|
|
52
|
-
return __generator(this, function (_a) {
|
|
53
|
-
switch (_a.label) {
|
|
54
|
-
case 0: return [4 /*yield*/, fetch('/api/getAliyunSts', {
|
|
55
|
-
method: 'POST',
|
|
56
|
-
body: JSON.stringify(params)
|
|
57
|
-
})];
|
|
58
|
-
case 1:
|
|
59
|
-
response = _a.sent();
|
|
60
|
-
return [2 /*return*/, response.json()];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}); },
|
|
64
|
-
// 必需:日期格式化函数
|
|
65
|
-
dateFormat: function (date, format) {
|
|
66
|
-
// 简单实现,实际项目中使用 util.date.format 或 util.filter.format
|
|
67
|
-
var year = date.getFullYear();
|
|
68
|
-
var month = String(date.getMonth() + 1).padStart(2, '0');
|
|
69
|
-
var day = String(date.getDate()).padStart(2, '0');
|
|
70
|
-
var hour = String(date.getHours()).padStart(2, '0');
|
|
71
|
-
var minute = String(date.getMinutes()).padStart(2, '0');
|
|
72
|
-
var second = String(date.getSeconds()).padStart(2, '0');
|
|
73
|
-
return format
|
|
74
|
-
.replace('YYYY', String(year))
|
|
75
|
-
.replace('MM', month)
|
|
76
|
-
.replace('DD', day)
|
|
77
|
-
.replace('HH', hour)
|
|
78
|
-
.replace('mm', minute)
|
|
79
|
-
.replace('ss', second);
|
|
80
|
-
},
|
|
81
|
-
// 可选:消息提示
|
|
82
|
-
messageWarning: function (msg) {
|
|
83
|
-
console.warn(msg);
|
|
84
|
-
// 或使用你的消息组件:window.$message.warning(msg)
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
exports.basicOssUploader = basicOssUploader;
|
|
88
|
-
// ============================================
|
|
89
|
-
// 示例2:完整配置(OSS后台项目)
|
|
90
|
-
// ============================================
|
|
91
|
-
var fullOssUploader = (0, aliOss_1.createAliOssUploader)({
|
|
92
|
-
getAliyunSts: function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
-
var response;
|
|
94
|
-
return __generator(this, function (_a) {
|
|
95
|
-
switch (_a.label) {
|
|
96
|
-
case 0: return [4 /*yield*/, fetch('/api/getAliyunSts', {
|
|
97
|
-
method: 'POST',
|
|
98
|
-
body: JSON.stringify(params)
|
|
99
|
-
})];
|
|
100
|
-
case 1:
|
|
101
|
-
response = _a.sent();
|
|
102
|
-
return [2 /*return*/, response.json()];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}); },
|
|
106
|
-
// 暗水印上传
|
|
107
|
-
darkWaterUploadImage: function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
|
-
var formData, response;
|
|
109
|
-
return __generator(this, function (_a) {
|
|
110
|
-
switch (_a.label) {
|
|
111
|
-
case 0:
|
|
112
|
-
formData = new FormData();
|
|
113
|
-
formData.append('file', params.file);
|
|
114
|
-
return [4 /*yield*/, fetch('/api/darkWaterUploadImage', {
|
|
115
|
-
method: 'POST',
|
|
116
|
-
body: formData
|
|
117
|
-
})];
|
|
118
|
-
case 1:
|
|
119
|
-
response = _a.sent();
|
|
120
|
-
return [2 /*return*/, response.json()];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}); },
|
|
124
|
-
// 批量转换水印
|
|
125
|
-
multiTransferImage: function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
-
var formData, response;
|
|
127
|
-
return __generator(this, function (_a) {
|
|
128
|
-
switch (_a.label) {
|
|
129
|
-
case 0:
|
|
130
|
-
formData = new FormData();
|
|
131
|
-
formData.append('file', params.file);
|
|
132
|
-
return [4 /*yield*/, fetch('/api/multiTransferImage', {
|
|
133
|
-
method: 'POST',
|
|
134
|
-
body: formData
|
|
135
|
-
})];
|
|
136
|
-
case 1:
|
|
137
|
-
response = _a.sent();
|
|
138
|
-
return [2 /*return*/, response.json()];
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}); },
|
|
142
|
-
// 头像处理
|
|
143
|
-
aliyunPersist: function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
144
|
-
var response;
|
|
145
|
-
return __generator(this, function (_a) {
|
|
146
|
-
switch (_a.label) {
|
|
147
|
-
case 0: return [4 /*yield*/, fetch('/api/aliyunPersist', {
|
|
148
|
-
method: 'POST',
|
|
149
|
-
body: JSON.stringify(params)
|
|
150
|
-
})];
|
|
151
|
-
case 1:
|
|
152
|
-
response = _a.sent();
|
|
153
|
-
return [2 /*return*/, response.json()];
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}); },
|
|
157
|
-
// 生成预签名URL
|
|
158
|
-
generatePrePresignedUrl: function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
159
|
-
var response;
|
|
160
|
-
return __generator(this, function (_a) {
|
|
161
|
-
switch (_a.label) {
|
|
162
|
-
case 0: return [4 /*yield*/, fetch('/api/generatePrePresignedUrl', {
|
|
163
|
-
method: 'GET'
|
|
164
|
-
})];
|
|
165
|
-
case 1:
|
|
166
|
-
response = _a.sent();
|
|
167
|
-
return [2 /*return*/, response.json()];
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}); },
|
|
171
|
-
// 上传配置
|
|
172
|
-
uploadConf: function (businessType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
173
|
-
var response;
|
|
174
|
-
return __generator(this, function (_a) {
|
|
175
|
-
switch (_a.label) {
|
|
176
|
-
case 0: return [4 /*yield*/, fetch("/api/uploadConf?businessType=".concat(businessType))];
|
|
177
|
-
case 1:
|
|
178
|
-
response = _a.sent();
|
|
179
|
-
return [2 /*return*/, response.json()];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}); },
|
|
183
|
-
dateFormat: function (date, format) {
|
|
184
|
-
// 日期格式化实现
|
|
185
|
-
return format;
|
|
186
|
-
},
|
|
187
|
-
messageWarning: function (msg) {
|
|
188
|
-
console.warn(msg);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
exports.fullOssUploader = fullOssUploader;
|
|
192
|
-
// ============================================
|
|
193
|
-
// 使用示例
|
|
194
|
-
// ============================================
|
|
195
|
-
// 1. 普通图片上传
|
|
196
|
-
function uploadNormalImage(file) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
-
var result, error_1;
|
|
199
|
-
return __generator(this, function (_a) {
|
|
200
|
-
switch (_a.label) {
|
|
201
|
-
case 0:
|
|
202
|
-
_a.trys.push([0, 2, , 3]);
|
|
203
|
-
return [4 /*yield*/, basicOssUploader.ossUploadImage({
|
|
204
|
-
file: file,
|
|
205
|
-
imageType: 'official',
|
|
206
|
-
quality: 0.7,
|
|
207
|
-
onProgress: function (e) {
|
|
208
|
-
console.log("\u4E0A\u4F20\u8FDB\u5EA6: ".concat(e.percent, "%"));
|
|
209
|
-
},
|
|
210
|
-
onSuccess: function (val) {
|
|
211
|
-
console.log('上传成功:', val.imgUrl);
|
|
212
|
-
},
|
|
213
|
-
onError: function (err) {
|
|
214
|
-
console.error('上传失败:', err);
|
|
215
|
-
}
|
|
216
|
-
})];
|
|
217
|
-
case 1:
|
|
218
|
-
result = _a.sent();
|
|
219
|
-
return [2 /*return*/, result];
|
|
220
|
-
case 2:
|
|
221
|
-
error_1 = _a.sent();
|
|
222
|
-
console.error('上传异常:', error_1);
|
|
223
|
-
return [3 /*break*/, 3];
|
|
224
|
-
case 3: return [2 /*return*/];
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
exports.uploadNormalImage = uploadNormalImage;
|
|
230
|
-
// 2. 头像上传
|
|
231
|
-
function uploadAvatar(file) {
|
|
232
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
233
|
-
var result;
|
|
234
|
-
return __generator(this, function (_a) {
|
|
235
|
-
switch (_a.label) {
|
|
236
|
-
case 0: return [4 /*yield*/, fullOssUploader.ossUploadImage({
|
|
237
|
-
file: file,
|
|
238
|
-
imageType: 'avatar',
|
|
239
|
-
quality: 0.8,
|
|
240
|
-
businessType: aliOss_1.BusinessType.AVATAR,
|
|
241
|
-
onSuccess: function (val) {
|
|
242
|
-
console.log('头像上传成功:', val.imgUrl);
|
|
243
|
-
}
|
|
244
|
-
})];
|
|
245
|
-
case 1:
|
|
246
|
-
result = _a.sent();
|
|
247
|
-
return [2 /*return*/, result];
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
exports.uploadAvatar = uploadAvatar;
|
|
253
|
-
// 3. 视频上传
|
|
254
|
-
function uploadVideo(file) {
|
|
255
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
-
var result;
|
|
257
|
-
return __generator(this, function (_a) {
|
|
258
|
-
switch (_a.label) {
|
|
259
|
-
case 0: return [4 /*yield*/, fullOssUploader.ossUploadFile({
|
|
260
|
-
file: file,
|
|
261
|
-
isVideo: true,
|
|
262
|
-
onProgress: function (e) {
|
|
263
|
-
console.log("\u89C6\u9891\u4E0A\u4F20\u8FDB\u5EA6: ".concat(e.percent, "%"));
|
|
264
|
-
},
|
|
265
|
-
onSuccess: function (val) {
|
|
266
|
-
console.log('视频上传成功:', val.url);
|
|
267
|
-
}
|
|
268
|
-
})];
|
|
269
|
-
case 1:
|
|
270
|
-
result = _a.sent();
|
|
271
|
-
return [2 /*return*/, result];
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
exports.uploadVideo = uploadVideo;
|
|
277
|
-
// 4. 身份证上传(私有)
|
|
278
|
-
function uploadIdCard(file) {
|
|
279
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
280
|
-
var result;
|
|
281
|
-
return __generator(this, function (_a) {
|
|
282
|
-
switch (_a.label) {
|
|
283
|
-
case 0: return [4 /*yield*/, fullOssUploader.ossUploadImage({
|
|
284
|
-
file: file,
|
|
285
|
-
imageType: 'official',
|
|
286
|
-
idCard: true,
|
|
287
|
-
businessType: aliOss_1.BusinessType.PRIVATE,
|
|
288
|
-
onSuccess: function (val) {
|
|
289
|
-
console.log('身份证上传成功:', val.imgUrl);
|
|
290
|
-
}
|
|
291
|
-
})];
|
|
292
|
-
case 1:
|
|
293
|
-
result = _a.sent();
|
|
294
|
-
return [2 /*return*/, result];
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
exports.uploadIdCard = uploadIdCard;
|
|
300
|
-
// 5. 商品详情图片上传
|
|
301
|
-
function uploadShopDetail(file) {
|
|
302
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
303
|
-
var result;
|
|
304
|
-
return __generator(this, function (_a) {
|
|
305
|
-
switch (_a.label) {
|
|
306
|
-
case 0: return [4 /*yield*/, fullOssUploader.shopDetailUpdate({
|
|
307
|
-
file: file,
|
|
308
|
-
imageType: 'official',
|
|
309
|
-
onSuccess: function (val) {
|
|
310
|
-
console.log('商品详情图片上传成功:', val.imgUrl);
|
|
311
|
-
}
|
|
312
|
-
})];
|
|
313
|
-
case 1:
|
|
314
|
-
result = _a.sent();
|
|
315
|
-
return [2 /*return*/, result];
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
exports.uploadShopDetail = uploadShopDetail;
|
|
@@ -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, path, domain, }: ICookie): void;
|
|
25
|
-
}
|
|
26
|
-
declare const _default: CookieClass;
|
|
27
|
-
export default _default;
|
|
@@ -1,52 +0,0 @@
|
|
|
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,28 +0,0 @@
|
|
|
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,24 +0,0 @@
|
|
|
1
|
-
declare class FilterClass {
|
|
2
|
-
/**
|
|
3
|
-
* 格式化时间,示例:1586840260500 | format('YYYY-MM-DD HH:mm:ss')
|
|
4
|
-
* @param {String|Number} date
|
|
5
|
-
* @param {String} fmt 'YYYY-MM-DD HH:mm:ss'
|
|
6
|
-
* @return {String} 'YYYY-MM-DD HH:mm:ss'
|
|
7
|
-
*/
|
|
8
|
-
format(date: string | number, fmt?: string): string;
|
|
9
|
-
/**
|
|
10
|
-
* 格式化金额,示例:123456 | formatMoney
|
|
11
|
-
* @param {Number} num
|
|
12
|
-
* @return {String} 123,456
|
|
13
|
-
*/
|
|
14
|
-
formatMoney(money: number | string): string;
|
|
15
|
-
/**
|
|
16
|
-
* 截取数组或字符串,示例:'1234' | slice(3)
|
|
17
|
-
* @param {Array|String} target 数组或字符串
|
|
18
|
-
* @param {Number} length 截取长度,从0开始
|
|
19
|
-
* @return {any}
|
|
20
|
-
*/
|
|
21
|
-
slice(target?: Array<any> | string, length?: number): string | any[];
|
|
22
|
-
}
|
|
23
|
-
declare const _default: FilterClass;
|
|
24
|
-
export default _default;
|
|
@@ -1,15 +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
|
-
}
|
|
14
|
-
declare const _default: Format;
|
|
15
|
-
export default _default;
|
|
@@ -1,12 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function injectJsError(data?: any): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function timing(): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function injectXHR(data?: any): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function onload(cb: any): void;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
declare class NumberClass {
|
|
2
|
-
/**
|
|
3
|
-
* 个位数前面补0
|
|
4
|
-
* @param {Number} num 需要格式化的数字
|
|
5
|
-
* @return {String} '01'
|
|
6
|
-
*/
|
|
7
|
-
formatNumber(num: number): string;
|
|
8
|
-
/**
|
|
9
|
-
* 将手机号中间部分替换为星号
|
|
10
|
-
* @param {String} phone 手机号码
|
|
11
|
-
* @return {String} 131****1111
|
|
12
|
-
*/
|
|
13
|
-
formatPhone(phone: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* 格式化数字 万
|
|
16
|
-
* @param {Number} num
|
|
17
|
-
* @return {String} 12.3万
|
|
18
|
-
*/
|
|
19
|
-
convertToWan(num: number): string | number;
|
|
20
|
-
/**
|
|
21
|
-
* 格式化数字 k
|
|
22
|
-
* @param {Number} num
|
|
23
|
-
* @return {String} 1.2k
|
|
24
|
-
*/
|
|
25
|
-
convertToThousand(num: number): string | number;
|
|
26
|
-
/**
|
|
27
|
-
* 随机数,指定范围
|
|
28
|
-
* @param {Number} min 开始
|
|
29
|
-
* @param {Number} max 结束
|
|
30
|
-
* @return {Number|Object}
|
|
31
|
-
*/
|
|
32
|
-
random(min: number, max: number): number | null;
|
|
33
|
-
/**
|
|
34
|
-
* 格式化金额
|
|
35
|
-
* @param {Number} num
|
|
36
|
-
* @return {String} 123,456
|
|
37
|
-
*/
|
|
38
|
-
formatMoney(money: number | string, signal?: string): string;
|
|
39
|
-
}
|
|
40
|
-
declare const _default: NumberClass;
|
|
41
|
-
export default _default;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
declare class Report {
|
|
2
|
-
static instance: any;
|
|
3
|
-
constructor(Vue: Object, options?: {});
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
static getInstance(Vue: Object, Option: Object): any;
|
|
6
|
-
install(): void;
|
|
7
|
-
/**
|
|
8
|
-
* 主动上报
|
|
9
|
-
* @param {String} data
|
|
10
|
-
* @param {String} type 'info','warning','error'
|
|
11
|
-
* @param {Object} options
|
|
12
|
-
*/
|
|
13
|
-
log(data?: any, type?: any, options?: any): void;
|
|
14
|
-
}
|
|
15
|
-
export default Report;
|