layout.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import type { Metadata } from "next";
  2. import { Geist, Geist_Mono } from "next/font/google";
  3. import "./globals.css";
  4. import MatomoTracker from "@/components/MatomoTracker";
  5. const geistSans = Geist({
  6. variable: "--font-geist-sans",
  7. subsets: ["latin"],
  8. });
  9. const geistMono = Geist_Mono({
  10. variable: "--font-geist-mono",
  11. subsets: ["latin"],
  12. });
  13. export const metadata: Metadata = {
  14. title: "AI-CS 智能客服系统",
  15. description: "融合 AI 技术与人工客服,为企业提供高效、智能的客户服务解决方案",
  16. };
  17. // Matomo 容器 URL(格式:container_*.js)
  18. const MATOMO_CONTAINER_URL = process.env.NEXT_PUBLIC_MATOMO_CONTAINER_URL || '';
  19. // 后端端口配置(用于 widget.js)
  20. const BACKEND_PORT = process.env.NEXT_PUBLIC_BACKEND_PORT || '18080';
  21. export default function RootLayout({
  22. children,
  23. }: Readonly<{
  24. children: React.ReactNode;
  25. }>) {
  26. return (
  27. <html lang="en">
  28. <head>
  29. <script
  30. dangerouslySetInnerHTML={{
  31. __html: `window.AICS_BACKEND_PORT = '${BACKEND_PORT}';`,
  32. }}
  33. />
  34. </head>
  35. <body
  36. className={`${geistSans.variable} ${geistMono.variable} antialiased`}
  37. >
  38. {children}
  39. {MATOMO_CONTAINER_URL && <MatomoTracker containerUrl={MATOMO_CONTAINER_URL} />}
  40. </body>
  41. </html>
  42. );
  43. }