From 80dc90be027ee26869c63860b7d6a0759a03546b Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期二, 20 五月 2025 17:33:53 +0800
Subject: [PATCH] fix: 修改首页ui

---
 packages/components/src/utils/common.ts |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/packages/components/src/utils/common.ts b/packages/components/src/utils/common.ts
index 5b055b6..1d761af 100644
--- a/packages/components/src/utils/common.ts
+++ b/packages/components/src/utils/common.ts
@@ -54,6 +54,10 @@
   return addStarForString(str, 2, end);
 }
 
+export function addStarForPhone(str: string) {
+  return `*${str.substring(str.length - 4)}`;
+}
+
 export function formatTimeAgo(date: string, format = 'YYYY-MM-DD HH:mm') {
   const diff = dayjs().diff(date, 'seconds'); // 璁$畻鏃堕棿宸紝鍗曚綅涓虹
 
@@ -185,3 +189,33 @@
   }
   return LifeRechargeConstants.LifePayOrderFrontStatusEnum.鏀粯鎴愬姛;
 }
+
+export class StringUtils {
+  static insertSpaces(str: string, space = 4) {
+    if (!str) return '';
+    const regex = new RegExp(`(.{${space}})`, 'g');
+    return str.replace(regex, '$1 ');
+  }
+
+  static societyCreditCodeInsertSpaces(str: string) {
+    if (!str) return '';
+    return str.replace(/(.{4})(.{4})(.{4})(.{6})/g, '$1 $2 $3 $4');
+  }
+
+  static idNumberInsertSpaces(str: string) {
+    if (!str) return '';
+    return str.replace(/(.{3})(.{3})(.{4})(.{4})(.{4})/g, '$1 $2 $3 $4 $5');
+  }
+
+  static phoneNumberAddSpace(realPhoneNumber: string) {
+    if (!realPhoneNumber) return '';
+    return realPhoneNumber.replace(/^(\d{3})(\d*)(\d{4})$/, '$1 $2 $3');
+  }
+
+  static formatterNumber(str: string) {
+    const cleanedValue = str.replace(/[^\d.]/g, '');
+    const singleDotValue = cleanedValue.replace(/(\..*)\./g, '$1');
+    const numberValue = parseFloat(singleDotValue);
+    return isNaN(numberValue) ? '' : singleDotValue;
+  }
+}

--
Gitblit v1.9.1