From 6d321caad1b9ead33377cc96a54510715ea725de Mon Sep 17 00:00:00 2001 From: Dogtiti <499960698@qq.com> Date: Wed, 19 Apr 2023 23:21:34 +0800 Subject: [PATCH] fix: types error --- public/locales/en/common.json | 5 +++-- public/locales/zh/common.json | 4 +++- src/components/ChatWindow.tsx | 4 ++-- src/pages/agent/index.tsx | 24 +++++++++++++++++++----- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 34acde9a..b458bd9c 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -23,6 +23,7 @@ "current-tasks": "Current tasks", "coming-soon": " Coming Soon!", "back": "Back", - "image":"Image" - + "image": "Image", + "delete": "Delete", + "share": "Share" } diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json index d49b2aa7..7400ab2c 100644 --- a/public/locales/zh/common.json +++ b/public/locales/zh/common.json @@ -23,5 +23,7 @@ "current-tasks": "当前任务", "coming-soon": "即将到来!", "back": "返回", - "image":"图片" + "image": "图片", + "delete": "删除", + "share": "分享" } diff --git a/src/components/ChatWindow.tsx b/src/components/ChatWindow.tsx index f1037faa..42b94461 100644 --- a/src/components/ChatWindow.tsx +++ b/src/components/ChatWindow.tsx @@ -33,7 +33,7 @@ interface ChatWindowProps extends HeaderProps { showDonation: boolean; fullscreen?: boolean; scrollToBottom?: boolean; - showWeChatPay: () => void; + showWeChatPay?: () => void; } const messageListId = "chat-window-message-list"; @@ -282,7 +282,7 @@ const ChatMessage = ({ message }: { message: Message }) => { ); }; -const DonationMessage = ({ showWeChatPay }: { showWeChatPay: () => void }) => { +const DonationMessage = ({ showWeChatPay }: { showWeChatPay?: () => void }) => { const { t } = useTranslation(["chat", "common"]); return (
diff --git a/src/pages/agent/index.tsx b/src/pages/agent/index.tsx index 91a39bf0..86fefa06 100644 --- a/src/pages/agent/index.tsx +++ b/src/pages/agent/index.tsx @@ -1,4 +1,4 @@ -import { type NextPage } from "next"; +import { type NextPage, type GetStaticProps } from "next"; import DefaultLayout from "../../layout/default"; import Button from "../../components/Button"; @@ -10,10 +10,13 @@ import type { Message } from "../../types/agentTypes"; import Toast from "../../components/toast"; import { FaTrash, FaShare, FaBackspace } from "react-icons/fa"; import { env } from "../../env/client.mjs"; +import { useTranslation } from "next-i18next"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; const AgentPage: NextPage = () => { const [showCopied, setShowCopied] = useState(false); const router = useRouter(); + const { t } = useTranslation(); const agentId = typeof router.query.id === "string" ? router.query.id : ""; @@ -55,7 +58,7 @@ const AgentPage: NextPage = () => { }} enabledClassName={"bg-green-600 hover:bg-green-400"} > - Share + {t("share")}
@@ -80,3 +83,14 @@ const AgentPage: NextPage = () => { }; export default AgentPage; + +export const getStaticProps: GetStaticProps = async ({ locale }) => ({ + props: { + ...(await serverSideTranslations(locale ?? "zh", [ + "common", + "help", + "settings", + "chat", + ])), + }, +});