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>
68 lines
2.5 KiB
TypeScript
68 lines
2.5 KiB
TypeScript
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} />;
|
||
}
|