import { ReactNode } from 'react';
import { Header } from '@/components/front/Header';
import { Footer } from '@/components/front/Footer';
import { publicApi } from '@/lib/services';

export const revalidate = 60; // ISR：60 秒重新生成

async function getConfig() {
  try {
    return await publicApi.getSiteConfig();
  } catch {
    return null;
  }
}

export default async function FrontLayout({
  children,
}: {
  children: ReactNode;
}) {
  const config = await getConfig();
  return (
    <div className="flex min-h-screen flex-col">
      <Header siteName={config?.siteName ?? '企业官方网站'} />
      <main className="flex-1">{children}</main>
      <Footer config={config} />
    </div>
  );
}
