Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

jin-sir
Copy link
Collaborator

@jin-sir jin-sir commented Jun 22, 2025

变更类型

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

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

相关问题

变更内容

优化

  • 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
  • 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 jin-sir requested a review from liuxy0551 June 23, 2025 02:58
@jin-sir jin-sir requested a review from LuckyFBB June 25, 2025 08:10
Copy link
Contributor

@LuckyFBB LuckyFBB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文档里面 github icon 的链接能否设置为 dt-utils 的 github 链接

@jin-sir jin-sir force-pushed the feat_utils branch 16 times, most recently from d8de76a to f9fb886 Compare August 11, 2025 04:11
Copy link
Contributor

@LuckyFBB LuckyFBB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

想到一个问题,这个里面有些 console 是用中文写的,可能源码合并到产品里面之后,中文校验不通过

@@ -0,0 +1,28 @@
import { nanoid } from 'nanoid';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是否需要单元测试啊

export { default as dayjs } from 'dayjs';
export * as idb from 'idb';
export { default as Cookie } from 'js-cookie';
export * as lodash from 'lodash-es';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些是为了以后大家都走 utils 引入吗?

* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB|MDN IndexedDB 使用指南}
* @see {@link https://caniuse.com/#feat=indexeddb|浏览器兼容性}
*/
class IndexedDB {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个单元测试需要吗?

/**
* IndexedDB
*
* @deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是打了移除标记吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants