mirror of
https://github.com/beilunyang/moemail.git
synced 2026-09-08 00:36:37 +08:00
feat(sharing): add email and message sharing functionality
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { getTranslations } from "next-intl/server"
|
||||
import { getSharedEmail, getSharedEmailMessages } from "@/lib/shared-data"
|
||||
import { SharedErrorPage } from "@/components/emails/shared-error-page"
|
||||
import { SharedEmailPageClient } from "./page-client"
|
||||
|
||||
interface PageProps {
|
||||
params: Promise<{
|
||||
token: string
|
||||
locale: string
|
||||
}>
|
||||
}
|
||||
|
||||
export default async function SharedEmailPage({ params }: PageProps) {
|
||||
const { token } = await params
|
||||
const tShared = await getTranslations("emails.shared")
|
||||
|
||||
// 服务端获取数据
|
||||
const email = await getSharedEmail(token)
|
||||
|
||||
if (!email) {
|
||||
return (
|
||||
<SharedErrorPage
|
||||
title={tShared("emailNotFound")}
|
||||
subtitle={tShared("linkExpired")}
|
||||
error={tShared("linkInvalid")}
|
||||
description={tShared("linkInvalidDescription")}
|
||||
ctaText={tShared("createOwnEmail")}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
// 获取初始消息列表
|
||||
const messagesResult = await getSharedEmailMessages(token)
|
||||
|
||||
return (
|
||||
<SharedEmailPageClient
|
||||
email={{
|
||||
...email,
|
||||
createdAt: email.createdAt.toISOString(),
|
||||
expiresAt: email.expiresAt.toISOString()
|
||||
}}
|
||||
initialMessages={messagesResult.messages.map(msg => ({
|
||||
...msg,
|
||||
received_at: msg.received_at?.toISOString(),
|
||||
sent_at: msg.sent_at?.toISOString()
|
||||
}))}
|
||||
initialNextCursor={messagesResult.nextCursor}
|
||||
initialTotal={messagesResult.total}
|
||||
token={token}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user