From 100cc1e86d61edcf6354068f898dc55fcbf73df1 Mon Sep 17 00:00:00 2001 From: yesmore <3224266014@qq.com> Date: Sat, 6 Apr 2024 17:03:29 +0800 Subject: [PATCH] add random separator --- apps/remix/app/routes/_h._index.tsx | 3 ++- apps/remix/lib/hooks/utlis.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 apps/remix/lib/hooks/utlis.ts diff --git a/apps/remix/app/routes/_h._index.tsx b/apps/remix/app/routes/_h._index.tsx index 9a95464..a7f7005 100644 --- a/apps/remix/app/routes/_h._index.tsx +++ b/apps/remix/app/routes/_h._index.tsx @@ -25,6 +25,7 @@ import Info from "~/components/icons/Info"; import { useTranslation } from "react-i18next"; import { useSenderModal } from "~/components/sender"; +import { getRandomCharacter } from "lib/hooks/utlis"; export const meta: MetaFunction = () => { return [ @@ -116,7 +117,7 @@ export const action: ActionFunction = async ({ request }) => { }; } - const mailbox = `${randomName("", ".")}@${domain}`; + const mailbox = `${randomName("", getRandomCharacter())}@${domain}`; const userMailbox = await userMailboxCookie.serialize(mailbox); return redirect("/", { headers: { diff --git a/apps/remix/lib/hooks/utlis.ts b/apps/remix/lib/hooks/utlis.ts new file mode 100644 index 0000000..8ebcb00 --- /dev/null +++ b/apps/remix/lib/hooks/utlis.ts @@ -0,0 +1,4 @@ +export function getRandomCharacter(): string { + const characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ."; + return characters.charAt(Math.floor(Math.random() * characters.length)); +}