@haluo/util 2.0.20 → 2.0.22

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.
Files changed (43) hide show
  1. package/dist/index.js +33 -64
  2. package/dist/modules/cookie/index.js +18 -24
  3. package/dist/modules/date/index.js +49 -56
  4. package/dist/modules/dom/index.js +16 -23
  5. package/dist/modules/filter/index.js +15 -25
  6. package/dist/modules/format/index.js +6 -12
  7. package/dist/modules/match/index.js +6 -10
  8. package/dist/modules/monitor/index.js +7 -14
  9. package/dist/modules/monitor/lib/jsError.js +39 -35
  10. package/dist/modules/monitor/lib/timing.js +24 -28
  11. package/dist/modules/monitor/lib/xhr.js +26 -33
  12. package/dist/modules/monitor/utils/onload.js +1 -4
  13. package/dist/modules/monitor/utils/tracker.js +13 -27
  14. package/dist/modules/number/index.js +31 -35
  15. package/dist/modules/open-app/index.js +66 -61
  16. package/dist/modules/sentry/index.js +19 -27
  17. package/dist/modules/tools/index.d.ts +1 -1
  18. package/dist/modules/tools/index.js +158 -169
  19. package/dist/modules/upload/aliOss.d.ts +97 -45
  20. package/dist/modules/upload/aliOss.js +446 -575
  21. package/dist/modules/upload/index.d.ts +46 -1
  22. package/dist/modules/upload/index.js +41 -12
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/dist/types/index.js +1 -2
  25. package/package.json +15 -4
  26. package/dist/modules/upload/ALIOSS_EXAMPLE.d.ts +0 -83
  27. package/dist/modules/upload/ALIOSS_EXAMPLE.js +0 -320
  28. package/dist/types/modules/cookie/index.d.ts +0 -27
  29. package/dist/types/modules/date/index.d.ts +0 -52
  30. package/dist/types/modules/dom/index.d.ts +0 -28
  31. package/dist/types/modules/filter/index.d.ts +0 -24
  32. package/dist/types/modules/format/index.d.ts +0 -15
  33. package/dist/types/modules/match/index.d.ts +0 -12
  34. package/dist/types/modules/monitor/index.d.ts +0 -3
  35. package/dist/types/modules/monitor/lib/jsError.d.ts +0 -1
  36. package/dist/types/modules/monitor/lib/timing.d.ts +0 -1
  37. package/dist/types/modules/monitor/lib/xhr.d.ts +0 -1
  38. package/dist/types/modules/monitor/utils/onload.d.ts +0 -1
  39. package/dist/types/modules/monitor/utils/tracker.d.ts +0 -7
  40. package/dist/types/modules/number/index.d.ts +0 -41
  41. package/dist/types/modules/sentry/index.d.ts +0 -15
  42. package/dist/types/modules/tools/index.d.ts +0 -166
  43. package/dist/types/types/index.d.ts +0 -3
@@ -176,62 +176,64 @@ export interface AliOssApiConfig {
176
176
  */
177
177
  declare function randomString(length: number): string;
178
178
  /**
179
- * 创建阿里云OSS上传器
180
- * @param apiConfig API配置对象,包含业务相关的API函数
181
- * @returns OSS上传器实例
179
+ * 阿里云OSS上传类
180
+ * 整合所有项目的aliOss业务逻辑,通过依赖注入实现业务API解耦
182
181
  */
183
- export declare function createAliOssUploader(apiConfig: AliOssApiConfig): {
184
- /**
185
- * 图片上传
186
- * @param option 上传选项
187
- */
188
- ossUploadImage: (option: UploadOption) => Promise<any>;
189
- /**
190
- * 文件上传(视频、文档、APK等)
191
- * @param option 上传选项
192
- */
193
- ossUploadFile: (option: UploadOption) => Promise<any>;
182
+ export declare class AliOssClass {
183
+ private apiConfig;
184
+ private clientCache;
185
+ constructor(apiConfig: AliOssApiConfig);
194
186
  /**
195
- * 商品详情图片上传
196
- * @param option 上传选项
187
+ * 创建OSS客户端
188
+ * @param businessType 业务类型
189
+ * @param imggeCarType 车辆图片类型(可选,用于特定业务)
190
+ * @returns OSS客户端实例
197
191
  */
198
- shopDetailUpdate: (option: UploadOption) => Promise<any>;
192
+ createOssClient(businessType: number, imggeCarType?: any): Promise<any>;
199
193
  /**
200
- * 后缀枚举
194
+ * 预加载图片获取尺寸
195
+ * @param file 文件对象
196
+ * @returns 图片对象
201
197
  */
202
- suffixEnum: {
203
- readonly nowater: "!nowater";
204
- readonly official: "!official";
205
- readonly panoram: "!panoram";
206
- readonly forum: "!forum";
207
- readonly avatar: "!avatar";
208
- readonly square: "!square";
209
- readonly carport: "!carport";
210
- };
198
+ imgUpload(file: File): Promise<HTMLImageElement>;
211
199
  /**
212
- * 业务类型枚举
200
+ * 生成文件名
201
+ * @param imageType 图片类型
202
+ * @param extension 文件扩展名
203
+ * @returns 文件名信息
213
204
  */
214
- businessType: typeof BusinessType;
205
+ private generateFileName;
215
206
  /**
216
- * 生成随机字符串
217
- * @param num 字符串长度
207
+ * 检查图片是否为长图
208
+ * @param width 图片宽度
209
+ * @param height 图片高度
210
+ * @returns 是否为长图
218
211
  */
219
- randomString: typeof randomString;
212
+ private isLongImage;
220
213
  /**
221
- * 创建OSS客户端(高级用法)
222
- * @param businessType 业务类型
223
- * @param imggeCarType 车辆图片类型
214
+ * 执行OSS上传
215
+ * @param client OSS客户端
216
+ * @param fileName 文件名
217
+ * @param file 文件对象
218
+ * @param year 年份
219
+ * @param mimeType MIME类型
220
+ * @param onProgress 进度回调
221
+ * @returns 上传结果
224
222
  */
225
- createOssClient: (businessType: number, imggeCarType?: any) => Promise<any>;
223
+ private performOssUpload;
226
224
  /**
227
- * 预加载图片
228
- * @param file 文件对象
225
+ * 确定业务类型
226
+ * @param option 上传选项
227
+ * @param isGif 是否为GIF
228
+ * @returns 业务类型
229
229
  */
230
- imgUpload: (file: File) => Promise<HTMLImageElement>;
230
+ private determineBusinessType;
231
231
  /**
232
232
  * 加载图片并返回结果
233
+ * 用于标准的图片上传场景
234
+ * @param params 加载参数
233
235
  */
234
- loadImage: (params: {
236
+ loadImage(params: {
235
237
  url: string;
236
238
  val: any;
237
239
  suffix: string;
@@ -239,20 +241,70 @@ export declare function createAliOssUploader(apiConfig: AliOssApiConfig): {
239
241
  option: UploadOption;
240
242
  resolve: (value: any) => void;
241
243
  reject: (reason?: any) => void;
242
- isGif?: boolean | undefined;
243
- }) => void;
244
+ isGif?: boolean;
245
+ }): void;
244
246
  /**
245
247
  * 加载图片并返回结果(新版)
248
+ * 用于avatar、idCard等特殊场景,返回格式不同
249
+ * @param params 加载参数
246
250
  */
247
- loadImageNew: (params: {
251
+ loadImageNew(params: {
248
252
  url: string;
249
253
  val: any;
250
254
  file: File;
251
255
  option: UploadOption;
252
256
  resolve: (value: any) => void;
253
257
  reject: (reason?: any) => void;
254
- }) => void;
255
- };
258
+ }): void;
259
+ /**
260
+ * 图片上传主方法
261
+ * 整合了所有项目的图片上传逻辑
262
+ * @param option 上传选项
263
+ * @returns Promise
264
+ */
265
+ ossUploadImage: (option: UploadOption) => Promise<any>;
266
+ /**
267
+ * 文件上传方法
268
+ * 支持视频、文档、APK等文件类型
269
+ * @param option 上传选项
270
+ * @returns Promise
271
+ */
272
+ ossUploadFile: (option: UploadOption) => Promise<any>;
273
+ /**
274
+ * 商品详情图片上传
275
+ * 注释:此方法用于商品详情页的图片上传,不压缩,使用NoWater客户端
276
+ * @param option 上传选项
277
+ * @returns Promise
278
+ */
279
+ shopDetailUpdate: (option: UploadOption) => Promise<any>;
280
+ /**
281
+ * 生成随机字符串
282
+ * @param num 字符串长度
283
+ */
284
+ randomString: typeof randomString;
285
+ /**
286
+ * 后缀枚举
287
+ */
288
+ suffixEnum: {
289
+ readonly nowater: "!nowater";
290
+ readonly official: "!official";
291
+ readonly panoram: "!panoram";
292
+ readonly forum: "!forum";
293
+ readonly avatar: "!avatar";
294
+ readonly square: "!square";
295
+ readonly carport: "!carport";
296
+ };
297
+ /**
298
+ * 业务类型枚举
299
+ */
300
+ businessType: typeof BusinessType;
301
+ }
302
+ /**
303
+ * 创建阿里云OSS上传器(工厂函数)
304
+ * @param apiConfig API配置对象,包含业务相关的API函数
305
+ * @returns OSS上传器实例
306
+ */
307
+ export declare function createAliOssUploader(apiConfig: AliOssApiConfig): AliOssClass;
256
308
  /**
257
309
  * 默认导出
258
310
  */