nomadro/app/vip/ebook/VipEbookShell.tsx
eric 9f8fec1723 Ship portal PC/H5 acceptance, VIP ScrollReader, admin analytics and ops anchors.
Adds /api/health, ntfy notify on config save, /admin/analytics charts, and deploy smoke for miniprogram config/API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 23:52:00 -05:00

68 lines
2.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { AntdRegistry } from "@ant-design/nextjs-registry";
import { Providers } from "@ebook/components/Providers";
import { BookRoutesProvider } from "@ebook/components/BookRoutes";
import { getSiteConfig } from "@ebook/lib/site-config.server";
import { getServerFeatures } from "@ebook/lib/features.server";
import { getLocale } from "@ebook/lib/i18n/server";
import "@ebook/app/globals.css";
/** VIP 电子书壳:与 /book layout 同能力,供 /vip/ebook 与阅读器复用(不跳转 /book) */
export async function VipEbookShell({
children,
readPath = "/vip/ebook/read",
}: {
children: React.ReactNode;
readPath?: string;
}) {
const locale = await getLocale();
const site = getSiteConfig();
const f = getServerFeatures();
return (
<div className="ebook-root vip-ebook-root" data-locale={locale}>
<AntdRegistry>
<Providers locale={locale}>
<BookRoutesProvider cover="/vip/ebook" read={readPath} home="/vip">
{f.analytics.enabled ? <AnalyticsLazy /> : null}
{f.ads.enabled && f.ads.clientId ? <AdSenseLazy /> : null}
{children}
{f.feedback.enabled ? (
<FeedbackLazy
title={f.feedback.title}
subtitle={f.feedback.subtitle}
contactEmail={site.brand.contactEmail}
xHandle={site.brand.xHandle}
/>
) : null}
</BookRoutesProvider>
</Providers>
</AntdRegistry>
<script
dangerouslySetInnerHTML={{
__html: `window.__EBOOK_FEATURES__=${JSON.stringify(f).replace(/</g, "\\u003c")};window.__LOCALE__=${JSON.stringify(locale)};(function(){try{var t=localStorage.getItem("nomadro-theme")||localStorage.getItem("ebook-theme");if(t==="light"||t==="sepia"||t==="dark"){document.documentElement.classList.remove("light","dark","sepia");document.documentElement.classList.add(t);}else{document.documentElement.classList.add("dark");}}catch(e){document.documentElement.classList.add("dark");}})();`,
}}
/>
</div>
);
}
function AnalyticsLazy() {
const { AnalyticsProvider } = require("@ebook/components/AnalyticsProvider");
return <AnalyticsProvider />;
}
function AdSenseLazy() {
const { AdSenseScript } = require("@ebook/components/AdSlot");
return <AdSenseScript />;
}
function FeedbackLazy(props: {
title: string;
subtitle: string;
contactEmail: string;
xHandle: string;
}) {
const { FeedbackPanel } = require("@ebook/components/FeedbackPanel");
return <FeedbackPanel {...props} />;
}