ly-utils-lib 1.0.3 → 1.0.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 自定义函数库,集成 day.js 和 es-toolkit
2
2
 
3
- 安装:npm install dayjs es-toolkit ly-utils-lib
3
+ 安装:npm install dayjs jspdf es-toolkit ly-utils-lib
4
4
 
5
5
  # 时间函数
6
6
 
@@ -246,3 +246,141 @@ createUUID()
246
246
  exportExcel(name: string, title: any, data: any, cols: any, sheetName: any = {})
247
247
 
248
248
  例: exportExcel('1111', { id: 'ID' }, [[{ id: 10 }, { id: 11 }]], [{ width: 20 }], ['111'])
249
+
250
+ ## 导入xlsx文件 importExcel
251
+
252
+ /\*\*
253
+
254
+ - 导入xlsx文件
255
+ - @param {string} file - xlsx文件
256
+ - @returns {Promise<any>} xlsx表格数据
257
+ \*/
258
+
259
+ importExcel(file: any)
260
+
261
+ 例: importExcel(xlsx文件)
262
+
263
+ ## 导出xlsx文件 exportPdf
264
+
265
+ /\*\*
266
+
267
+ - 导出pdf文件
268
+ - @param {string} name - 文件名称
269
+ - @param {any} dom - 页面dom
270
+ - @param {any} type - 是否直接导出
271
+ - @returns {Promise<unknown>} 不直接导出返回base64文件
272
+ \*/
273
+
274
+ exportPdf(name: string, dom: any, type: boolean = true)
275
+
276
+ 例: exportPdf('aa.pdf', document.getElementById('aaa'))
277
+
278
+ ## 生成图片文件 importImage
279
+
280
+ /\*\*
281
+
282
+ - 生成图片文件
283
+ - @param {any} dom - 页面dom
284
+ - @param {string} type - 图片格式
285
+ - @returns {Promise<unknown>} base64文件
286
+ \*/
287
+
288
+ importImage(dom: any, type: string = 'image/jpeg')
289
+
290
+ 例: await importImage(document.getElementById('aaa'))
291
+
292
+ ## hex 颜色转 rgb 颜色 hexToRgb
293
+
294
+ /\*\*
295
+
296
+ - hex 颜色转 rgb 颜色
297
+ - @param {string} str - hex 颜色
298
+ - @returns {string} rgb 颜色
299
+ \*/
300
+
301
+ hexToRgb(str: string)
302
+
303
+ 例: hexToRgb('#ff0000')
304
+
305
+ ## rgb 颜色转 Hex 颜色 rgbToHex
306
+
307
+ /\*\*
308
+
309
+ - rgb 颜色转 Hex 颜色
310
+ - @param {number} r - r 颜色
311
+ - @param {number} g - g 颜色
312
+ - @param {number} b - b 颜色
313
+ - @returns {string} hex 颜色
314
+ \*/
315
+
316
+ rgbToHex(r: number, g: number, b: number)
317
+
318
+ 例: rgbToHex(255, 0, 0)
319
+
320
+ ## hex 颜色变浅颜色值 getLightColor
321
+
322
+ /\*\*
323
+
324
+ - hex 颜色变浅颜色值
325
+ - @param {string} color - hex 颜色
326
+ - @param {number} alpha - 透明度
327
+ - @returns {string} hex 颜色
328
+ \*/
329
+
330
+ getLightColor(color: string, alpha: number)
331
+
332
+ 例: getLightColor('#ff0000', 0.1)
333
+
334
+ ## hex 颜色变深颜色值 getDarkColor
335
+
336
+ /\*\*
337
+
338
+ - hex 颜色变深颜色值
339
+ - @param {string} color - hex 颜色
340
+ - @param {number} alpha - 透明度
341
+ - @returns {string} hex 颜色
342
+ \*/
343
+
344
+ getDarkColor(color: string, alpha: number)
345
+
346
+ 例: getDarkColor('#ff0000', 0.1)
347
+
348
+ ## 图片转base64 imgToBase64
349
+
350
+ /\*\*
351
+
352
+ - 图片转base64
353
+ - @param {string} url - 图片路径
354
+ - @returns {Promise<string>} base64图片内容
355
+ \*/
356
+
357
+ imgToBase64(url: string)
358
+
359
+ 例: await imgToBase64(new URL(`./file1.png`, import.meta.url).href)
360
+
361
+ ## base64转文件 base64toFile
362
+
363
+ /\*\*
364
+
365
+ - base64转文件
366
+ - @param {string} url - base64文件
367
+ - @param {string} fileName - 文件名称
368
+ - @returns {File} 文件
369
+ \*/
370
+
371
+ base64toFile(url: string, fileName: string)
372
+
373
+ 例: base64toFile('base64', 'aa.jpg')
374
+
375
+ ## base64转文件 downloadFile
376
+
377
+ /\*\*
378
+
379
+ - 下载文件
380
+ - @param {string} url - 文件路径
381
+ - @param {string} fileName - 文件名称
382
+ \*/
383
+
384
+ downloadFile(url: string, fileName: string)
385
+
386
+ 例: downloadFile('url', 'aa.jpg')
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ export * as esToolkit from 'es-toolkit';
1
2
  export { default as dayjs } from 'dayjs';
2
- export * from 'es-toolkit';
3
+ export { default as jsPDF } from 'jspdf';
3
4
  export * from './utils/time';
4
5
  export * from './utils/tool';
5
6
  export * from './utils/storage';