feat: enhance TOTP formatting and improve responsive styles for TOTP codes display

This commit is contained in:
shuaiplus
2026-06-16 19:17:05 +08:00
parent 7b3be2c819
commit 9e0908f43c
5 changed files with 55 additions and 14 deletions
@@ -507,8 +507,9 @@ export function maskSecret(value: string): string {
export function formatTotp(code: string): string {
if (!code) return code;
if (code.length === 5) return `${code.slice(0, 2)} ${code.slice(2)}`;
if (code.length < 6) return code;
return `${code.slice(0, 3)} ${code.slice(3, 6)}`;
if (code.length <= 4) return code;
if (code.length === 8) return `${code.slice(0, 4)} ${code.slice(4)}`;
return code.replace(/(.{3})(?=.)/g, '$1 ');
}
export function formatHistoryTime(value: string | null | undefined): string {