nomadro/components/module-gate.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

72 lines
2.0 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.

"use client";
import Link from "next/link";
import type { ReactNode } from "react";
import { useRemoteConfig } from "~/lib/use-remote-config";
import type { NomadroRemoteConfig } from "~/lib/remote-config";
type ModuleKey = keyof NomadroRemoteConfig["modules"];
/**
* 远程配置模块闸门:首屏直接渲染内容,不挡用户;仅确认关闭后才换友好占位。
*/
export function ModuleGate({
moduleKey,
children,
}: {
moduleKey: ModuleKey;
children: ReactNode;
}) {
const { config, ready } = useRemoteConfig();
const mod = config.modules[moduleKey];
// 未就绪时默认放行(用包内默认可开),避免闪「加载配置」
const enabled = !ready || mod?.enabled !== false;
if (!enabled) {
return (
<div
style={{
minHeight: "100vh",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
gap: 12,
padding: 24,
background:
"radial-gradient(ellipse 60% 40% at 50% 0%, rgba(78,205,196,0.12), transparent), #0a0e17",
color: "#f1f5f9",
fontFamily: "ui-sans-serif, system-ui, sans-serif",
textAlign: "center",
}}
>
<h1 style={{ margin: 0, fontSize: "1.35rem", fontWeight: 700 }}>
暂时无法打开
</h1>
<p style={{ margin: 0, color: "#94a3b8", maxWidth: 320, lineHeight: 1.5 }}>
该内容暂未开放,稍后再来看看吧。
</p>
<Link
href="/"
style={{
marginTop: 8,
color: "#0a0e17",
background: "linear-gradient(135deg,#ff6b6b,#ffe66d,#4ecdc4)",
padding: "12px 20px",
borderRadius: 999,
fontWeight: 700,
textDecoration: "none",
minHeight: 44,
display: "inline-flex",
alignItems: "center",
}}
>
返回首页
</Link>
</div>
);
}
return <>{children}</>;
}