重新构建路由和配置样式文件
This commit is contained in:
+93
-27
@@ -1,45 +1,111 @@
|
||||
import {
|
||||
Links,
|
||||
Meta,
|
||||
Outlet,
|
||||
Scripts,
|
||||
// import React from 'react';
|
||||
import {
|
||||
Links,
|
||||
LiveReload,
|
||||
Meta,
|
||||
Outlet,
|
||||
Scripts,
|
||||
ScrollRestoration,
|
||||
isRouteErrorResponse,
|
||||
useRouteError,
|
||||
type MetaFunction
|
||||
} from "@remix-run/react";
|
||||
import type { LinksFunction } from "@remix-run/node";
|
||||
import { Layout } from "~/components/layout/Layout";
|
||||
import { ErrorBoundary as AppErrorBoundary } from "~/components/error/ErrorBoundary";
|
||||
import "remixicon/fonts/remixicon.css";
|
||||
// 不使用import导入样式
|
||||
|
||||
import "./tailwind.css";
|
||||
// 添加客户端hydration错误处理
|
||||
// if (typeof window !== "undefined") {
|
||||
// window.addEventListener("error", (event) => {
|
||||
// if (event.message && event.message.includes("Hydration failed")) {
|
||||
// console.warn("Hydration error detected, refreshing page...");
|
||||
// setTimeout(() => {
|
||||
// window.location.reload();
|
||||
// }, 100);
|
||||
// event.preventDefault();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
export const links: LinksFunction = () => [
|
||||
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
|
||||
{
|
||||
rel: "preconnect",
|
||||
href: "https://fonts.gstatic.com",
|
||||
crossOrigin: "anonymous",
|
||||
},
|
||||
{
|
||||
rel: "stylesheet",
|
||||
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
|
||||
},
|
||||
];
|
||||
export const meta: MetaFunction = () => {
|
||||
return [
|
||||
{ charSet: "utf-8" },
|
||||
{ name: "viewport", content: "width=device-width,initial-scale=1" },
|
||||
{ title: "中国烟草AI合同及卷宗审核系统" },
|
||||
{ name: "description", content: "专业的AI合同及卷宗评查系统,提供智能审核、风险评估和规范化建议" },
|
||||
{ name: "robots", content: "noindex,nofollow" } // 内部系统,防止被搜索引擎索引
|
||||
];
|
||||
};
|
||||
|
||||
export function Layout({ children }: { children: React.ReactNode }) {
|
||||
export function links() {
|
||||
return [
|
||||
{ rel: "stylesheet", href: "/tailwind.css" }, // 使用构建后的Tailwind CSS
|
||||
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
|
||||
{ rel: "preconnect", href: "https://fonts.gstatic.com", crossOrigin: "anonymous" },
|
||||
{ rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap" }
|
||||
];
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<html lang="en">
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charSet="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<Meta />
|
||||
<Links />
|
||||
</head>
|
||||
<body>
|
||||
{children}
|
||||
<body className="font-sans">
|
||||
<Layout>
|
||||
<Outlet />
|
||||
</Layout>
|
||||
<ScrollRestoration />
|
||||
<Scripts />
|
||||
<LiveReload />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return <Outlet />;
|
||||
}
|
||||
export function ErrorBoundary() {
|
||||
const error = useRouteError();
|
||||
|
||||
if (isRouteErrorResponse(error)) {
|
||||
return (
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<Meta />
|
||||
<Links />
|
||||
<title>错误 {error.status}</title>
|
||||
</head>
|
||||
<body>
|
||||
<AppErrorBoundary
|
||||
status={error.status}
|
||||
statusText={error.statusText}
|
||||
message={error.data?.message || "发生了一个错误,请稍后重试"}
|
||||
/>
|
||||
<Scripts />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<Meta />
|
||||
<Links />
|
||||
<title>意外错误</title>
|
||||
</head>
|
||||
<body>
|
||||
<AppErrorBoundary
|
||||
status={500}
|
||||
statusText="服务器错误"
|
||||
message="服务器发生了意外错误,请稍后重试"
|
||||
/>
|
||||
<Scripts />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user