lingjing/components/Shell.jsx
2026-02-23 09:51:43 +00:00

41 lines
1.3 KiB
JavaScript
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 { useEffect, useState } from 'react';
export default function Shell({ title, subtitle, children }) {
const [showInstall, setShowInstall] = useState(false);
useEffect(() => {
// 检测是否已在PWA模式不是则提示安装
const isStandalone =
window.matchMedia('(display-mode: standalone)').matches ||
window.navigator.standalone;
if (!isStandalone) {
const timer = setTimeout(() => setShowInstall(true), 3000);
return () => clearTimeout(timer);
}
}, []);
return (
<main className="flex min-h-screen min-h-dvh flex-col px-4 py-10 pb-safe">
<div className="mx-auto w-full max-w-lg">
<header className="mb-8 text-center">
<p className="mb-3 inline-block rounded-full border border-white/10 px-3 py-1 text-xs tracking-[0.2em] text-white/30">
LINGJING
</p>
<h1 className="text-2xl font-semibold tracking-tight text-white/90">{title}</h1>
{subtitle && (
<p className="mt-2 text-sm text-white/40">{subtitle}</p>
)}
</header>
{children}
</div>
{showInstall && (
<div className="install-hint" onClick={() => setShowInstall(false)}>
📲 添加到主屏幕获得沉浸式体验 &nbsp;
</div>
)}
</main>
);
}