ARTEX — AI 自主渗透测试系统(Go 后端 + Next.js 前端,单二进制内嵌)。 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { type ClassValue, clsx } from "clsx";
|
|
import { twMerge } from "tailwind-merge";
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
export const getInitials = (str: string): string => {
|
|
if (typeof str !== "string" || !str.trim()) return "?";
|
|
|
|
return (
|
|
str
|
|
.trim()
|
|
.split(/\s+/)
|
|
.filter(Boolean)
|
|
.map((word) => word[0])
|
|
.join("")
|
|
.toUpperCase() || "?"
|
|
);
|
|
};
|
|
|
|
export function formatCurrency(
|
|
amount: number,
|
|
opts?: {
|
|
currency?: string;
|
|
locale?: string;
|
|
minimumFractionDigits?: number;
|
|
maximumFractionDigits?: number;
|
|
noDecimals?: boolean;
|
|
},
|
|
) {
|
|
const { currency = "USD", locale = "en-US", minimumFractionDigits, maximumFractionDigits, noDecimals } = opts ?? {};
|
|
|
|
const formatOptions: Intl.NumberFormatOptions = {
|
|
style: "currency",
|
|
currency,
|
|
minimumFractionDigits: noDecimals ? 0 : minimumFractionDigits,
|
|
maximumFractionDigits: noDecimals ? 0 : maximumFractionDigits,
|
|
};
|
|
|
|
return new Intl.NumberFormat(locale, formatOptions).format(amount);
|
|
}
|