This commit is contained in:
parent
c8426f4559
commit
d2f01fcb1a
|
|
@ -45,9 +45,15 @@ import { ThemeSwitcher } from "./theme-switcher"
|
||||||
|
|
||||||
import { usePathname } from "next/navigation" // 导入 usePathname
|
import { usePathname } from "next/navigation" // 导入 usePathname
|
||||||
|
|
||||||
|
import { useTranslation } from "react-i18next"; // 引入useTranslation用于国际化
|
||||||
|
|
||||||
|
|
||||||
interface ProfileSettingsProps {}
|
interface ProfileSettingsProps {}
|
||||||
|
|
||||||
export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
|
|
||||||
|
const { t } = useTranslation(); // 使用t函数来获取翻译文本
|
||||||
|
|
||||||
const {
|
const {
|
||||||
profile,
|
profile,
|
||||||
setProfile,
|
setProfile,
|
||||||
|
|
@ -309,7 +315,8 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
src={profile.image_url + "?" + new Date().getTime()}
|
src={profile.image_url + "?" + new Date().getTime()}
|
||||||
height={34}
|
height={34}
|
||||||
width={34}
|
width={34}
|
||||||
alt={"Image"}
|
alt={t("profile.imageAlt")}
|
||||||
|
//alt={"Image"}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Button size="icon" variant="ghost">
|
<Button size="icon" variant="ghost">
|
||||||
|
|
@ -326,7 +333,7 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
<div className="grow overflow-auto">
|
<div className="grow overflow-auto">
|
||||||
<SheetHeader>
|
<SheetHeader>
|
||||||
<SheetTitle className="flex items-center justify-between space-x-2">
|
<SheetTitle className="flex items-center justify-between space-x-2">
|
||||||
<div>User Settings</div>
|
<div>{t("profile.settingsTitle")}</div>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
|
|
@ -335,28 +342,28 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
onClick={handleSignOut}
|
onClick={handleSignOut}
|
||||||
>
|
>
|
||||||
<IconLogout className="mr-1" size={20} />
|
<IconLogout className="mr-1" size={20} />
|
||||||
Logout
|
{t("profile.logout")}
|
||||||
</Button>
|
</Button>
|
||||||
</SheetTitle>
|
</SheetTitle>
|
||||||
</SheetHeader>
|
</SheetHeader>
|
||||||
|
|
||||||
<Tabs defaultValue="profile">
|
<Tabs defaultValue="profile">
|
||||||
<TabsList className="mt-4 grid w-full grid-cols-2">
|
<TabsList className="mt-4 grid w-full grid-cols-2">
|
||||||
<TabsTrigger value="profile">Profile</TabsTrigger>
|
<TabsTrigger value="profile">{t("profile.profileTab")}</TabsTrigger>
|
||||||
<TabsTrigger value="keys">API Keys</TabsTrigger>
|
<TabsTrigger value="keys">{t("profile.apiKeysTab")}</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
|
|
||||||
<TabsContent className="mt-4 space-y-4" value="profile">
|
<TabsContent className="mt-4 space-y-4" value="profile">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Label>Username</Label>
|
<Label>{t("profile.usernameLabel")}</Label>
|
||||||
|
|
||||||
<div className="text-xs">
|
<div className="text-xs">
|
||||||
{username !== profile.username ? (
|
{username !== profile.username ? (
|
||||||
usernameAvailable ? (
|
usernameAvailable ? (
|
||||||
<div className="text-green-500">AVAILABLE</div>
|
<div className="text-green-500">{t("profile.available")}</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="text-red-500">UNAVAILABLE</div>
|
<div className="text-red-500">{t("profile.unavailable")}</div>
|
||||||
)
|
)
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -365,7 +372,7 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Input
|
<Input
|
||||||
className="pr-10"
|
className="pr-10"
|
||||||
placeholder="Username..."
|
placeholder={t("profile.usernamePlaceholder")}
|
||||||
value={username}
|
value={username}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
setUsername(e.target.value)
|
setUsername(e.target.value)
|
||||||
|
|
@ -395,7 +402,7 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<Label>Profile Image</Label>
|
<Label>{t("profile.profileImageLabel")}</Label>
|
||||||
|
|
||||||
<ImagePicker
|
<ImagePicker
|
||||||
src={profileImageSrc}
|
src={profileImageSrc}
|
||||||
|
|
@ -408,10 +415,10 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<Label>Chat Display Name</Label>
|
<Label>{t("profile.chatDisplayNameLabel")}</Label>
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
placeholder="Chat display name..."
|
placeholder={t("profile.chatDisplayNamePlaceholder")}
|
||||||
value={displayName}
|
value={displayName}
|
||||||
onChange={e => setDisplayName(e.target.value)}
|
onChange={e => setDisplayName(e.target.value)}
|
||||||
maxLength={PROFILE_DISPLAY_NAME_MAX}
|
maxLength={PROFILE_DISPLAY_NAME_MAX}
|
||||||
|
|
@ -420,14 +427,13 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
|
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<Label className="text-sm">
|
<Label className="text-sm">
|
||||||
What would you like the AI to know about you to provide better
|
{t("profile.instructionsLabel")}
|
||||||
responses?
|
|
||||||
</Label>
|
</Label>
|
||||||
|
|
||||||
<TextareaAutosize
|
<TextareaAutosize
|
||||||
value={profileInstructions}
|
value={profileInstructions}
|
||||||
onValueChange={setProfileInstructions}
|
onValueChange={setProfileInstructions}
|
||||||
placeholder="Profile context... (optional)"
|
placeholder={t("profile.instructionsPlaceholder")}
|
||||||
minRows={6}
|
minRows={6}
|
||||||
maxRows={10}
|
maxRows={10}
|
||||||
/>
|
/>
|
||||||
|
|
@ -756,11 +762,11 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
|
||||||
|
|
||||||
<div className="ml-auto space-x-2">
|
<div className="ml-auto space-x-2">
|
||||||
<Button variant="ghost" onClick={() => setIsOpen(false)}>
|
<Button variant="ghost" onClick={() => setIsOpen(false)}>
|
||||||
Cancel
|
{t("profile.cancel")} {/* 取消按钮 */}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button ref={buttonRef} onClick={handleSave}>
|
<Button ref={buttonRef} onClick={handleSave}>
|
||||||
Save
|
{t("profile.save")} {/* 保存按钮 */}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,24 @@
|
||||||
|
|
||||||
"chat": {
|
"chat": {
|
||||||
"defaultChatTitle": "Chat"
|
"defaultChatTitle": "Chat"
|
||||||
}
|
},
|
||||||
|
|
||||||
|
"profile": {
|
||||||
|
"settingsTitle": "User Settings",
|
||||||
|
"logout": "Logout",
|
||||||
|
"profileTab": "Profile",
|
||||||
|
"apiKeysTab": "API Keys",
|
||||||
|
"usernameLabel": "Username",
|
||||||
|
"usernamePlaceholder": "Enter username",
|
||||||
|
"available": "AVAILABLE",
|
||||||
|
"unavailable": "UNAVAILABLE",
|
||||||
|
"usernameError": "Username must be letters, numbers, or underscores only - no other characters or spacing allowed.",
|
||||||
|
"chatDisplayName": "Chat Display Name",
|
||||||
|
"chatDisplayNamePlaceholder": "Your Name",
|
||||||
|
"instructionsLabel": "What would you like the AI to know about you to provide better responses?",
|
||||||
|
"instructionsPlaceholder": "Profile context... (optional)",
|
||||||
|
"profileImageLabel": "Profile Image",
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"save": "Save"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,25 @@
|
||||||
|
|
||||||
"chat": {
|
"chat": {
|
||||||
"defaultChatTitle": "会話"
|
"defaultChatTitle": "会話"
|
||||||
}
|
},
|
||||||
|
|
||||||
|
"profile": {
|
||||||
|
"settingsTitle": "ユーザー設定",
|
||||||
|
"logout": "ログアウト",
|
||||||
|
"profileTab": "プロフィール",
|
||||||
|
"apiKeysTab": "APIキー",
|
||||||
|
"usernameLabel": "ユーザー名",
|
||||||
|
"usernamePlaceholder": "ユーザー名を入力してください",
|
||||||
|
"available": "利用可能",
|
||||||
|
"unavailable": "利用不可",
|
||||||
|
"usernameError": "ユーザー名は文字、数字、またはアンダースコアのみで、その他の文字やスペースは使用できません。",
|
||||||
|
"chatDisplayName": "チャット表示名",
|
||||||
|
"chatDisplayNamePlaceholder": "あなたの名前",
|
||||||
|
"instructionsLabel": "AIにあなたに関するどのような情報を知ってもらいたいですか?",
|
||||||
|
"instructionsPlaceholder": "プロフィールの説明...(オプション)",
|
||||||
|
"profileImageLabel": "プロフィール画像",
|
||||||
|
"cancel": "キャンセル",
|
||||||
|
"save": "保存"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,5 +34,24 @@
|
||||||
|
|
||||||
"chat": {
|
"chat": {
|
||||||
"defaultChatTitle": "对话"
|
"defaultChatTitle": "对话"
|
||||||
|
},
|
||||||
|
|
||||||
|
"profile": {
|
||||||
|
"settingsTitle": "用户设置",
|
||||||
|
"logout": "注销",
|
||||||
|
"profileTab": "个人资料",
|
||||||
|
"apiKeysTab": "API 密钥",
|
||||||
|
"usernameLabel": "用户名",
|
||||||
|
"usernamePlaceholder": "请输入用户名",
|
||||||
|
"available": "可用",
|
||||||
|
"unavailable": "不可用",
|
||||||
|
"usernameError": "用户名只能包含字母、数字或下划线,不能包含其他字符或空格。",
|
||||||
|
"chatDisplayName": "聊天显示名称",
|
||||||
|
"chatDisplayNamePlaceholder": "您的名称",
|
||||||
|
"instructionsLabel": "你希望 AI 知道关于你的哪些信息以便提供更好的回答?",
|
||||||
|
"instructionsPlaceholder": "个人资料描述...(可选)",
|
||||||
|
"profileImageLabel": "个人资料图片",
|
||||||
|
"cancel": "取消",
|
||||||
|
"save": "保存"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue