// ============================================================
// display — 展示/格式化工具（金额、日期、Logo 资产、类型别名）
// 合并自 display.ts + logo.ts + type.ts
// ============================================================

import { isMacOS, isWindows } from './env';

// ========== 金额 & 日期格式化（原 display.ts）==========

export function centToYuan(cent: number): string {
    return (cent / 100).toFixed(2);
}

export function formatDate(date: Date | string | undefined): string {
    if (!date) return '—';
    const d = typeof date === 'string' ? new Date(date) : date;
    return d.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' });
}

// ========== Logo 资产（原 logo.ts）==========

import hxPng from "@/assets/logo/HX.png";
import hx2Png from "@/assets/logo/HX2.png";

export function getMainLogoUrl(): string { return hxPng; }
export function getAltLogoUrl(): string { return hx2Png; }

export function getFaviconPath(): string {
   if (isWindows()) return '/src/assets/logo/heixiu.ico';
   return hxPng;
}

export function getPlatformIconFormatInfo(): string {
   if (isMacOS()) return '.icns（当前使用 .png 回退）';
   if (isWindows()) return '.ico';
   return '.png';
}

// ========== 类型别名（原 type.ts）==========

export type Nullable<T> = T | null;
