feat: 添加 H5 登录调试面板,显示初始 URL 信息并修复布尔值渲染问题

This commit is contained in:
2026-05-27 03:07:38 +08:00
parent 5a0f1f4f8e
commit 6dc6258c19
3 changed files with 203 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
</head>
<body>
<script>window.__INITIAL_URL__ = document.URL;</script>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

View File

@@ -33,6 +33,7 @@ const INIT_DEBUG: DebugInfo = {
};
function DebugPanel({ info }: { info: DebugInfo }) {
const [initialUrl] = useState(() => (window as any).__INITIAL_URL__ || '(N/A)');
return (
<div className="absolute top-0 left-0 right-0 z-50 bg-black/80 text-white text-xs font-mono p-3 text-left max-h-[60vh] overflow-auto">
<div className="font-bold text-yellow-400 mb-1">🐞 调试信息 (关闭需去掉 ?debug=1)</div>
@@ -41,9 +42,13 @@ function DebugPanel({ info }: { info: DebugInfo }) {
{Object.entries(info).map(([k, v]) => (
<tr key={k} className="border-b border-white/10">
<td className="pr-2 text-gray-400 w-28 align-top whitespace-nowrap">{k}</td>
<td className="break-all text-green-300">{v || <span className="text-gray-500">(空)</span>}</td>
<td className="break-all text-green-300">{v === false ? 'false' : v === true ? 'true' : v || <span className="text-gray-500">(空)</span>}</td>
</tr>
))}
<tr className="border-b border-yellow-400/50">
<td className="pr-2 text-yellow-400 w-28 align-top whitespace-nowrap font-bold">initialUrl</td>
<td className="break-all text-yellow-300">{initialUrl}</td>
</tr>
</tbody>
</table>
</div>