bootCryptoDecrypt
useDesensitise
// 是否全局进行表格字段脱敏
useDesensitise: { type: Boolean, default: true },
const desensitiseField = Object.keys(desensitiseFields)

      .map((k) => desensitiseFields[k])
      .flat();

定义脱敏

const desensitiseFields = {
  phone: [
    'phone',
    'mobile',
    'customerPhone',
    'ownerPhone',
    'phoneNum',
    'carOwnerPhone',
    'cellphonenumber',
    'telephone',
    'appointPhone',
    'contactNumber',
    'contactPhone',
    'receiverPhone',
  ], // 手机号脱敏
  vin: ['vin', 'ownerVin', 'vins', 'deviceId'], // VIN脱敏
  licensenum: ['licensenum', 'licensePlate'], // 车牌号脱敏
  vinEncrypt: ['vinEncrypt', 'ownerId'], // 车辆唯一标识
  serialNo: ['serialNo'], // 发票流水号
  invoiceNo: ['invoiceNo'], // 发票号码
  email: ['email', 'buyerEmail'], // 邮箱脱敏
  longitude: ['longitude', 'positionLatitude', 'gpsLatitude'], // 经度坐标
  latitude: ['latitude', 'positionLongitude', 'gpsLongitude'], // 纬度坐标
  notifySn: ['notifySn', 'paymentSn'], // 支付记录号
  refundSn: ['refundSn'], // 支付记录号
  address: ['address', 'gasAddress', 'detailAddr', 'ownerAddress'], // 地址
  logisticsTrackingNumber: ['logisticsTrackingNumber'], //物流单号
};

定义脱敏规则

export const desensitiseMethods = {
  phone: (text) =>
    text.length > 7
      ? text.replace(/^(.{3})(.*)(.{4})$/, `$1${'*'.repeat(text.length - 7)}$3`)
      : text, // 手机号脱敏, 输出123****901
  vin: (text) => text.replace(/^(.{6})(.{5})(.{6})$/, '$1*****$3'), // vin脱敏, 输出1HGB*****1234
  licensenum: (text) => text.replace(/^(.{2})(.*)(.{1})$/, '$1*****$3'), // 车牌号脱敏
  vinEncrypt: (text) => text.replace(/.{10}$/, '**********'), // 车辆唯一标识
  serialNo: (text) => text.replace(/.{10}$/, '**********'), // 发票流水号
  invoiceNo: (text) => {
    if (!text || text < 3) {
      return;
    }
    const leftPart = text.substring(0, 3);
    const rightPart = text.substring(3).replace(/./g, '*');
    return leftPart + rightPart;
  }, // 发票号码
  longitude: () => '******', // 经度坐标
  latitude: () => '******', // 纬度坐标
  email: (text) => {
    const atIndex = text.indexOf('@');
    const prefix = text.slice(0, atIndex);
    const suffix = text.slice(atIndex);
    const maskedPrefix = prefix.slice(0, 3) + '*'.repeat(prefix.length - 3);
    return maskedPrefix + suffix;
  }, // 邮箱脱敏
  notifySn: (text) => {
    if (!text || text < 3) {
      return;
    }
    const leftPart = text.substring(0, 3);
    const rightPart = text.substring(3).replace(/./g, '*');
    return leftPart + rightPart;
  }, // 支付记录号
  refundSn: (text) => {
    if (!text || text < 3) {
      return;
    }
    const leftPart = text.substring(0, 3);
    const rightPart = text.substring(3).replace(/./g, '*');
    return leftPart + rightPart;
  }, // 支付记录号
  address: () => '******', // 地址
};

freeman_Tian
12 声望2 粉丝