初始化项目

This commit is contained in:
2026-03-22 00:27:15 +08:00
parent b40a1634ef
commit 1b9448a5a3
105 changed files with 11434 additions and 193 deletions

View File

@@ -0,0 +1,44 @@
/**
* 全局数据脱敏工具函数
* 支持:姓名、手机、身份证、银行卡、邮箱
*/
/**
* 姓名脱敏
*/
export function desensitizeName(value: string | null | undefined): string {
if (!value || value.length <= 1) return value || ''
return value.charAt(0) + '*'
}
/**
* 手机号脱敏
*/
export function desensitizePhone(value: string | null | undefined): string {
if (!value || value.length !== 11) return value || ''
return value.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
}
/**
* 身份证脱敏
*/
export function desensitizeIdCard(value: string | null | undefined): string {
if (!value) return ''
return value.replace(/(\d{6})\d{8}(\w{4})/, '$1********$2')
}
/**
* 银行卡脱敏
*/
export function desensitizeBankCard(value: string | null | undefined): string {
if (!value || value.length < 16) return value || ''
return value.replace(/(\d{4})\d{10}(\d{2})/, '$1**********$2')
}
/**
* 邮箱脱敏
*/
export function desensitizeEmail(value: string | null | undefined): string {
if (!value) return ''
return value.replace(/(.)(.*)(@.*)/, '$1***$3')
}