"use client" import { solar2lunar, formatDate } from "@/lib/lunar-calendar" interface DualCalendarDisplayProps { date: Date className?: string size?: "sm" | "md" | "lg" showWeekday?: boolean compact?: boolean } export function DualCalendarDisplay({ date, className = "", size = "md", showWeekday = true, compact = false }: DualCalendarDisplayProps) { // 获取农历信息 const lunarInfo = solar2lunar(date) // 格式化显示 const solarStr = formatDate(date) const [year, monthNum, day] = solarStr.split('-') const weekDay = ['日', '一', '二', '三', '四', '五', '六'][date.getDay()] // 尺寸配置 const sizeConfig = { sm: { container: "h-[80px]", padding: "p-3", titleGap: "mb-2", contentGap: "space-y-1", solarText: "text-lg", weekText: "text-xs", lunarText: "text-sm", tagText: "text-[10px]", tagPadding: "px-1.5 py-0.5" }, md: { container: "h-[110px]", padding: "p-5", titleGap: "mb-3", contentGap: "space-y-2", solarText: "text-2xl", weekText: "text-sm", lunarText: "text-lg", tagText: "text-xs", tagPadding: "px-2 py-0.5" }, lg: { container: "h-[140px]", padding: "p-6", titleGap: "mb-4", contentGap: "space-y-3", solarText: "text-3xl", weekText: "text-base", lunarText: "text-xl", tagText: "text-sm", tagPadding: "px-3 py-1" } } const config = sizeConfig[size] if (compact) { // 紧凑模式:单行显示 return (
{year}年{parseInt(monthNum)}月{parseInt(day)}日 {lunarInfo && ( <> | {lunarInfo.monthName}{lunarInfo.dayName} )}
) } return (
{/* 公历信息 */}

公历

{year}年{parseInt(monthNum)}月{parseInt(day)}日
{showWeekday && (
星期{weekDay}
)}
{/* 农历信息 */} {lunarInfo ? (

农历

{lunarInfo.ganZhiYear}年 {lunarInfo.monthName}{lunarInfo.dayName} {lunarInfo.animal}年 {lunarInfo.isLeap && ( 闰月 )}
) : (
农历信息不可用
日期超出范围 (1900-2100)
)}
) }