From c96c1b00d9d609f0560deb2f0e8e06dc992a110e Mon Sep 17 00:00:00 2001 From: chufan Date: Tue, 18 Nov 2025 15:08:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix(@142vip/utils):=20=E6=8B=93=E5=B1=95`Vi?= =?UTF-8?q?pDayjs`=E7=B1=BB=EF=BC=8C=E5=A2=9E=E5=8A=A0`formatToISOStr`?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/utils/src/pkgs/dayjs.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/utils/src/pkgs/dayjs.ts b/packages/utils/src/pkgs/dayjs.ts index 0e7c8d60..1591dcc3 100644 --- a/packages/utils/src/pkgs/dayjs.ts +++ b/packages/utils/src/pkgs/dayjs.ts @@ -75,6 +75,14 @@ export class VipDayjs { public formatCurrentDateToStr(): string { return this.formatDateToStr(new Date(), this.FORMAT_TEMPLATE_STR) } + + /** + * 格式化时间为ISO字符串 + * @param date + */ + public formatToISOStr(date?: dayjs.ConfigType): string { + return dayjs(date).toISOString() + } } // 导出 From dc1473efb29a018b18e3cda6eca87a50bdab8f8a Mon Sep 17 00:00:00 2001 From: "142vip.cn" <2237221210@qq.com> Date: Tue, 18 Nov 2025 16:27:16 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix(@142vip/utils):=20=E5=A2=9E=E5=8A=A0`Vi?= =?UTF-8?q?pDataTransform`=E7=B1=BB=20(#738)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/utils/src/pkgs/data-transform.ts | 51 +++++++++++++++++++++++ packages/utils/src/pkgs/index.ts | 1 + 2 files changed, 52 insertions(+) create mode 100644 packages/utils/src/pkgs/data-transform.ts diff --git a/packages/utils/src/pkgs/data-transform.ts b/packages/utils/src/pkgs/data-transform.ts new file mode 100644 index 00000000..0f98da5e --- /dev/null +++ b/packages/utils/src/pkgs/data-transform.ts @@ -0,0 +1,51 @@ +class VipDataTransform { + /** + * 字符串脱敏,生成指定长度的字符串,默认6位,默认模板:* + */ + public sensitiveStr(length?: number, template?: string): string { + return (template ?? '*').repeat(length ?? 6) + } + + /** + * 手机号脱敏 + */ + public sensitivePhoneNum(phone: string, template?: string): string { + const phoneStr = phone.trim() + const len = phoneStr.length + // 前3位、后4位,中间按照template模板加密,默认* + if (len > 7) { + return phoneStr.replace(/(\d{3})\d*(\d{4})/, `$1${this.sensitiveStr(len - 7, template)}$2`) + } + + return phoneStr + } + + // /** + // * jwt数据加密 + // * @param payload + // * @param secretOrPrivateKey + // * @param expiresIn + // */ + // public jwtEncrypt(payload: string | object, secretOrPrivateKey?: Secret | PrivateKey, expiresIn?: string | number): string { + // // 类型优化 + // return jwt.sign(payload, secretOrPrivateKey, { + // expiresIn, + // }) + // } + // + // /** + // * jwt数据解密 + // * @param data + // * @param cryptoKey + // */ + // public jwtDecrypt(data: string, secretOrPrivateKey: Secret | PrivateKey): string | object | null { + // try { + // return jwt.verify(data, secretOrPrivateKey) + // } + // catch { + // return null + // } + // } +} + +export const vipDataTransform = new VipDataTransform() diff --git a/packages/utils/src/pkgs/index.ts b/packages/utils/src/pkgs/index.ts index 3a29b4c7..a7ec1586 100644 --- a/packages/utils/src/pkgs/index.ts +++ b/packages/utils/src/pkgs/index.ts @@ -2,6 +2,7 @@ export * from './color' export * from './commander' export * from './config' export * from './console' +export * from './data-transform' export * from './dayjs' export * from './detect' export * from './inquirer' From 862b2faf41f11cc9c9882247c5290309fc082045 Mon Sep 17 00:00:00 2001 From: chufan Date: Tue, 18 Nov 2025 19:38:31 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix(@142vip/utils):=20=E5=A2=9E=E5=8A=A0`Vi?= =?UTF-8?q?pQs`=E7=B1=BB=E5=92=8C=E5=B7=A5=E5=85=B7=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/utils/src/pkgs/qs.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/utils/src/pkgs/qs.ts b/packages/utils/src/pkgs/qs.ts index fc5e3e1e..2d6ad286 100644 --- a/packages/utils/src/pkgs/qs.ts +++ b/packages/utils/src/pkgs/qs.ts @@ -1,21 +1,20 @@ import type { BooleanOptional, IParseOptions, IStringifyOptions, ParsedQs } from 'qs' import qs from 'qs' -/** - * 序列化 query string - */ -function stringify(obj: any, options?: IStringifyOptions): string { - return qs.stringify(obj, options) -} +export class VipQs { + /** + * 序列化 query string + */ + public stringify(obj: any, options?: IStringifyOptions): string { + return qs.stringify(obj, options) + } -/** - * 解析 query string - */ -function parse(str: string, options?: IParseOptions & { decoder?: never | undefined }): ParsedQs { - return qs.parse(str, options) + /** + * 解析 query string + */ + public parse(str: string, options?: IParseOptions & { decoder?: never | undefined }): ParsedQs { + return qs.parse(str, options) + } } -export const VipQs = { - stringify, - parse, -} +export const vipQs = new VipQs() From a70f1588b4b82f3e2ae56adc785e81b58b281c17 Mon Sep 17 00:00:00 2001 From: chufan Date: Tue, 18 Nov 2025 19:39:16 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix(@142vip/changelog):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D`vipQs`=E7=B1=BB=E6=96=B9=E6=B3=95=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/changelog/src/core/github.api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/changelog/src/core/github.api.ts b/packages/changelog/src/core/github.api.ts index a2b2bc56..4673a58a 100644 --- a/packages/changelog/src/core/github.api.ts +++ b/packages/changelog/src/core/github.api.ts @@ -1,5 +1,5 @@ import type { Commit, GitAuthorInfo } from '@142vip/changelog' -import { HttpMethod, VipColor, VipConsole, vipLogger, VipQs } from '@142vip/utils' +import { HttpMethod, VipColor, VipConsole, vipLogger, vipQs } from '@142vip/utils' import { $fetch } from 'ofetch' function getHeaders(token: string) { @@ -132,7 +132,7 @@ function generateReleaseUrl(markdown: string, config: { prerelease: boolean }): string { const baseUrl = `https://${config.baseUrl}/${config.repo}/releases/new` - const queryParams = VipQs.stringify({ + const queryParams = vipQs.stringify({ title: config.name || config.to, body: markdown, tag: config.to,