dt-utils icon indicating copy to clipboard operation
dt-utils copied to clipboard

feat(dt-utils): refactor the dt-utils

Open jin-sir opened this issue 7 months ago • 1 comments

变更类型

请选择以下选项以描述 PR 的类型:

  • [ ] Bug 修复(修复现有问题)
  • [x] 新功能(添加了一个功能)
  • [ ] 代码优化(性能改进、代码重构)
  • [ ] 文档更新
  • [ ] 单测新增或修改
  • [ ] 其他(请说明):

相关问题

变更内容

优化

  • browserCheck
    • 更名 checkBrowserSupport
    • 使用 ua-parser-js 获取浏览器信息
    • 版本对比精确到小版本
  • copy
    • 使用 Promise 替换 callback
    • 优先使用 navigator.clipboard
  • downLoadData
    • 更名 downloadFile
    • 使用 Promise 替换 callback,且将 Response 作为参数传递
  • convertBytes
    • 更名 formatBytes
    • 新增 decimals 参数,控制小数位数
    • 优化计算逻辑
  • generateAKey、getRandomStr
    • 合并并命名为 getKey
    • 使用 nanoid 生成 key
  • generateFullUrlPath
    • 更名 generateUrlWithQuery
    • 新增 object 和 array 参数的处理:将对象转换为 JSON 字符串
  • getQueryParameters
    • 兼容 generateFullUrlPath ,新增 object 和 array 的解析
  • isMacOs
    • 更名 isMacOS
    • 使用 ua-parser-js 判断
  • isWindows
    • 使用 ua-parser-js 判断
  • isMobileDevice
    • 更名 isMobile
    • 使用 http://detectmobilebrowsers.com/
  • localDB
    • set 支持批量添加
    • clear 支持保留部分 key
  • dateTime
    • 删除 dateTime 中的所有函数,新增 formatDateTime
    • formatDateTime 支持将传入的时间根据传入的格式进行格式化
    • 同时提供 DayjsFormat 枚举,其中包含了常见的时间格式,方便使用
  • getBase64、base64Encode
    • 合并为 toBase64
    • 非文件使用 js-base64 进行编码
  • percent
    • 更名 toPercent
    • 放开最大值 1 的限制
  • exchangeOrder
    • 更名 toSortOrder
  • getThousandth
    • 更名 toThousand

新增

  • formatSecond
    • 格式化秒数:3661 -> 1h1m1s
  • fromBase64
    • 从 js-base64 导出,解码 base64 字符串
  • getTypeOfValue
    • 获取传入的值的类型
  • sessionDB
    • 功能同 localDB

对应 Previewer

https://jin-sir.github.io/dt-utils/

jin-sir avatar Jun 22 '25 17:06 jin-sir

image 这个 commit 的内容好像不太对,似乎是把改文档路径的内容也提进去了

liuxy0551 avatar Aug 28 '25 05:08 liuxy0551