feat(settings): 设置与个人信息模块审计重构 — i18n + 服务注入解耦 + Error Boundary + 流式渲染
- 新增 SettingsService 接口 + Context 注入,组件层不再直接 import users/messaging actions - 新增 resolveRoleSettingsConfig 配置驱动角色路由,删除 parent/student/teacher-settings-view 冗余文件 - 新增 SettingsSectionErrorBoundary,每个 TabsContent + profile 角色概览区块均包裹 - 新增 ProfileStudentOverview/ProfileTeacherOverview 异步 Server Component + 骨架屏,支持流式渲染 - 抽取 buildStudentOverviewData 等纯函数到 lib/student-overview-data.ts,便于单元测试 - 新增 settings.json 翻译文件(zh-CN + en),所有组件改用 useTranslations/getTranslations - 重构 profile/page.tsx:i18n 适配 + Suspense 分区加载 + 业务逻辑抽离 - 同步更新架构图 004/005
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
"use client"
|
||||
|
||||
import { AlertCircle } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
|
||||
export default function SecuritySettingsError({ reset }: { error: Error & { digest?: string }; reset: () => void }) {
|
||||
const t = useTranslations("settings.errors")
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center space-y-4 p-8">
|
||||
<EmptyState
|
||||
icon={AlertCircle}
|
||||
title="页面加载失败"
|
||||
description="抱歉,安全设置页面加载时发生了意外错误。请稍后重试。"
|
||||
title={t("loadFailed")}
|
||||
description={t("loadFailedDesc")}
|
||||
action={{
|
||||
label: "重试",
|
||||
label: t("retry"),
|
||||
onClick: () => reset(),
|
||||
}}
|
||||
className="border-none shadow-none h-auto"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Lock } from "lucide-react"
|
||||
import { getTranslations } from "next-intl/server"
|
||||
|
||||
import { requireAuth } from "@/shared/lib/auth-guard"
|
||||
import { PasswordChangeForm } from "@/modules/settings/components/password-change-form"
|
||||
@@ -13,12 +14,13 @@ export const metadata = {
|
||||
|
||||
export default async function SecuritySettingsPage() {
|
||||
await requireAuth()
|
||||
const t = await getTranslations("settings")
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col gap-8 p-8">
|
||||
<PageHeader
|
||||
title="Security"
|
||||
description="Manage your password and account security settings."
|
||||
title={t("tabs.security")}
|
||||
description={t("security.changePassword.description")}
|
||||
icon={Lock}
|
||||
/>
|
||||
|
||||
@@ -27,15 +29,15 @@ export default async function SecuritySettingsPage() {
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Security Tips</CardTitle>
|
||||
<CardDescription>Best practices to keep your account safe.</CardDescription>
|
||||
<CardTitle>{t("security.tips.title")}</CardTitle>
|
||||
<CardDescription>{t("security.tips.description")}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ul className="space-y-2 text-sm text-muted-foreground">
|
||||
<li>Use a unique password that you don't reuse across other sites.</li>
|
||||
<li>Avoid common words, names, or sequential patterns.</li>
|
||||
<li>Change your password periodically.</li>
|
||||
<li>Your account will be temporarily locked after multiple failed login attempts.</li>
|
||||
<li>{t("security.tips.tip1")}</li>
|
||||
<li>{t("security.tips.tip2")}</li>
|
||||
<li>{t("security.tips.tip3")}</li>
|
||||
<li>{t("security.tips.tip4")}</li>
|
||||
</ul>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user