diff --git a/app/routes.ts b/app/routes.ts index 6077f9a..7736766 100644 --- a/app/routes.ts +++ b/app/routes.ts @@ -20,4 +20,6 @@ export default [ route("/sitemap.xml", "routes/sitemap[.]xml.tsx"), route("/robots.txt", "routes/robots[.]txt.tsx"), route("/site.webmanifest", "routes/site[.]webmanifest.tsx"), + // 捕获所有未匹配的路径,自动跳转到首页 + route("*", "routes/$.ts"), ] satisfies RouteConfig; diff --git a/app/routes/$.ts b/app/routes/$.ts new file mode 100644 index 0000000..f0fd809 --- /dev/null +++ b/app/routes/$.ts @@ -0,0 +1,6 @@ +import { redirect } from "react-router"; + +export async function loader() { + // 404页面自动跳转到首页 + return redirect("/"); +} diff --git a/app/routes/dev.email-handler.tsx b/app/routes/dev.email-handler.tsx index 0f542f9..c124535 100644 --- a/app/routes/dev.email-handler.tsx +++ b/app/routes/dev.email-handler.tsx @@ -119,12 +119,22 @@ export function meta() { { title: "开发环境邮件处理器 - Smail" }, { name: "description", - content: "开发环境专用的邮件处理路由,用于模拟 Cloudflare Workers 的 email handler 功能。", + content: + "开发环境专用的邮件处理路由,用于模拟 Cloudflare Workers 的 email handler 功能。", }, // 开发页面不应该被搜索引擎索引 - { name: "robots", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" }, - { name: "googlebot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" }, - { name: "bingbot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" }, + { + name: "robots", + content: "noindex, nofollow, noarchive, nosnippet, noimageindex", + }, + { + name: "googlebot", + content: "noindex, nofollow, noarchive, nosnippet, noimageindex", + }, + { + name: "bingbot", + content: "noindex, nofollow, noarchive, nosnippet, noimageindex", + }, ]; } diff --git a/app/routes/mail.$id.tsx b/app/routes/mail.$id.tsx index b267a8e..fbb9a60 100644 --- a/app/routes/mail.$id.tsx +++ b/app/routes/mail.$id.tsx @@ -163,9 +163,18 @@ export function meta({ data }: Route.MetaArgs) { content: "查看您在Smail临时邮箱中收到的邮件详情。", }, // 即使是404页面也要阻止索引 - { name: "robots", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" }, - { name: "googlebot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" }, - { name: "bingbot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" }, + { + name: "robots", + content: "noindex, nofollow, noarchive, nosnippet, noimageindex", + }, + { + name: "googlebot", + content: "noindex, nofollow, noarchive, nosnippet, noimageindex", + }, + { + name: "bingbot", + content: "noindex, nofollow, noarchive, nosnippet, noimageindex", + }, ]; } @@ -180,11 +189,23 @@ export function meta({ data }: Route.MetaArgs) { content: `查看来自${email.fromAddress}的邮件"${email.subject || "无主题"}"。接收时间:${new Date(email.receivedAt).toLocaleDateString("zh-CN")}。`, }, // 阻止搜索引擎索引邮件内容页面 - { name: "robots", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" }, - { name: "googlebot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" }, - { name: "bingbot", content: "noindex, nofollow, noarchive, nosnippet, noimageindex" }, + { + name: "robots", + content: "noindex, nofollow, noarchive, nosnippet, noimageindex", + }, + { + name: "googlebot", + content: "noindex, nofollow, noarchive, nosnippet, noimageindex", + }, + { + name: "bingbot", + content: "noindex, nofollow, noarchive, nosnippet, noimageindex", + }, // 阻止缓存 - { "http-equiv": "cache-control", content: "no-cache, no-store, must-revalidate" }, + { + "http-equiv": "cache-control", + content: "no-cache, no-store, must-revalidate", + }, { "http-equiv": "pragma", content: "no-cache" }, { "http-equiv": "expires", content: "0" }, ];