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:
SpecialX
2026-06-22 16:15:36 +08:00
parent 21c7e65fee
commit 5d42495480
29 changed files with 2445 additions and 1094 deletions

View File

@@ -0,0 +1,280 @@
{
"title": "Settings",
"backToDashboard": "Back to dashboard",
"tabs": {
"general": "General",
"notifications": "Notifications",
"appearance": "Appearance",
"security": "Security",
"ai": "AI"
},
"profile": {
"title": "Profile Information",
"description": "Update your personal information.",
"fields": {
"name": "Full Name",
"namePlaceholder": "Your name",
"email": "Email",
"emailDisabled": "Email cannot be changed.",
"phone": "Phone",
"phonePlaceholder": "+1 234 567 890",
"address": "Address",
"addressPlaceholder": "123 Main St, City, Country",
"gender": "Gender",
"genderPlaceholder": "Select gender",
"age": "Age",
"role": "Role"
},
"save": "Save Changes",
"saving": "Saving...",
"success": "Profile updated successfully",
"failure": "Failed to update profile"
},
"notifications": {
"title": "Notification Preferences",
"description": "Choose how and when you want to be notified.",
"channels": {
"title": "Delivery Channels",
"subtitle": "Select the channels through which you want to receive notifications.",
"push": "Push Notifications",
"pushDesc": "Receive in-app and browser push notifications.",
"email": "Email",
"emailDesc": "Send notifications to my registered email address.",
"sms": "SMS",
"smsDesc": "Send critical notifications via SMS (charges may apply)."
},
"categories": {
"title": "Notification Categories",
"subtitle": "Choose which types of events should trigger notifications.",
"messages": "Messages",
"messagesDesc": "New direct messages and replies.",
"announcements": "Announcements",
"announcementsDesc": "School, grade, and class announcements.",
"homework": "Homework",
"homeworkDesc": "New assignments and submission reminders.",
"grades": "Grades",
"gradesDesc": "Exam and assignment grade releases.",
"attendance": "Attendance",
"attendanceDesc": "Attendance records and absence alerts."
},
"quietHours": {
"title": "Quiet Hours",
"subtitle": "Suppress non-urgent notifications during a specified time period each day.",
"enable": "Enable Quiet Hours",
"enableDesc": "When enabled, only urgent notifications will be delivered during the specified hours.",
"start": "Start Time",
"end": "End Time"
},
"save": "Save Preferences",
"saving": "Saving...",
"success": "Preferences updated",
"failure": "Failed to update preferences"
},
"appearance": {
"theme": {
"title": "Theme",
"description": "Choose how the interface looks on this device.",
"label": "Color theme",
"system": "System",
"light": "Light",
"dark": "Dark"
},
"language": {
"title": "Language",
"description": "Choose the interface language.",
"label": "Interface language"
}
},
"security": {
"changePassword": {
"title": "Change Password",
"description": "Choose a strong password to keep your account secure.",
"current": "Current Password",
"currentPlaceholder": "Enter current password",
"new": "New Password",
"newPlaceholder": "Enter new password",
"confirm": "Confirm New Password",
"confirmPlaceholder": "Re-enter new password",
"strength": "Password strength",
"strengthWeak": "Weak",
"strengthMedium": "Medium",
"strengthStrong": "Strong",
"requirements": "Password requirements:",
"submit": "Update Password",
"updating": "Updating..."
},
"session": {
"title": "Session",
"description": "Account access and session controls.",
"signOut": "Log out",
"signOutDesc": "Return to the login screen.",
"confirmTitle": "Confirm sign out",
"confirmDesc": "Are you sure you want to sign out? You will be returned to the login screen.",
"cancel": "Cancel",
"confirm": "Sign out"
},
"tips": {
"title": "Security Tips",
"description": "Best practices to keep your account safe.",
"tip1": "Use a unique password that you don't reuse across other sites.",
"tip2": "Avoid common words, names, or sequential patterns.",
"tip3": "Change your password periodically.",
"tip4": "Your account will be temporarily locked after multiple failed login attempts."
}
},
"ai": {
"providers": {
"title": "AI Providers",
"description": "Manage AI vendors and default model configuration.",
"existing": "Existing Providers",
"selectPlaceholder": "Create new or select existing",
"createNew": "Create new",
"keyStatus": "Key Status",
"stored": "Stored",
"noKey": "No key stored",
"id": "ID",
"idDesc": "Auto-generated for each provider.",
"provider": "Provider",
"providerPlaceholder": "Select provider",
"baseUrl": "API URL",
"baseUrlPlaceholder": "https://open.bigmodel.cn/api/paas/v4",
"baseUrlDesc": "Enter base URL without /chat/completions suffix.",
"model": "Model",
"modelPlaceholder": "gpt-4o-mini",
"apiKey": "API Key",
"apiKeyPlaceholder": "Paste new key to replace",
"apiKeyDesc": "Existing key won't be displayed. Leave blank to keep current.",
"setDefault": "Set as default",
"test": "Test",
"testing": "Testing...",
"save": "Save Changes",
"saving": "Saving...",
"testSuccess": "Test passed",
"testFailure": "Test failed",
"saveSuccess": "Saved",
"saveFailure": "Failed to save",
"loadFailure": "Failed to load AI providers",
"needKey": "Please enter API key to test",
"needTest": "Please test the configuration before saving"
}
},
"quickLinks": {
"title": "Quick links",
"description": "Common places you may want to visit.",
"profile": "Profile",
"dashboard": "Dashboard",
"children": "Children",
"grades": "Grades",
"attendance": "Attendance",
"assignments": "Assignments",
"schedule": "Schedule",
"textbooks": "Textbooks",
"exams": "Exams",
"homework": "Homework"
},
"roleDescriptions": {
"admin": "Manage your account and system configuration.",
"teacher": "Manage your profile, notifications, and teaching preferences.",
"student": "Manage your profile, notifications, and learning preferences.",
"parent": "Manage your profile, notifications, and child follow-up preferences."
},
"errors": {
"loadFailed": "Page load failed",
"loadFailedDesc": "Sorry, an unexpected error occurred while loading the page. Please try again later.",
"retry": "Retry",
"sectionLoadFailed": "This section failed to load",
"sectionLoadFailedDesc": "Please try again later."
},
"admin": {
"title": "System Settings",
"description": "Manage system basics and runtime parameters.",
"schoolInfo": {
"title": "School Information",
"description": "Basic school information displayed throughout the system.",
"name": "School Name",
"namePlaceholder": "Enter school name",
"code": "School Code",
"codePlaceholder": "Enter school code",
"phone": "Contact Phone",
"phonePlaceholder": "Enter contact phone",
"email": "Contact Email",
"emailPlaceholder": "Enter contact email",
"address": "School Address",
"addressPlaceholder": "Enter school address",
"description2": "School Description",
"descriptionPlaceholder": "Enter school description"
},
"securityPolicy": {
"title": "Security Policy",
"description": "Password policy and session management.",
"passwordMinLength": "Minimum Password Length",
"sessionTimeout": "Session Timeout (minutes)",
"requireSpecialChar": "Require special characters in passwords",
"requireSpecialCharDesc": "Require at least one special character in user passwords",
"requireUppercase": "Require uppercase letters in passwords",
"requireUppercaseDesc": "Require at least one uppercase letter in user passwords",
"forcePasswordChange": "Force password change on first login",
"forcePasswordChangeDesc": "New users or after password reset must change password on first login"
},
"fileUpload": {
"title": "File Upload",
"description": "File upload limits and storage configuration.",
"maxFileSize": "Max File Size (MB)",
"allowedTypes": "Allowed File Types",
"allowedTypesPlaceholder": "e.g. jpg,png,pdf,docx"
},
"notificationConfig": {
"title": "Notification Configuration",
"description": "How and when system notifications are sent.",
"notifyNewUser": "Notify admins on new user registration",
"notifyNewUserDesc": "Send notification to admins when a new user registers",
"notifyScheduleChange": "Notify teachers on schedule changes",
"notifyScheduleChangeDesc": "Notify relevant teachers when schedule change is approved",
"notifyAnnouncement": "Notify target users on announcement publish",
"notifyAnnouncementDesc": "Push notification to target users when announcement is published"
},
"save": "Save Settings",
"saving": "Saving...",
"reset": "Reset",
"saveSuccess": "Settings saved",
"saveFailure": "Failed to save settings",
"loadFailure": "Failed to load system settings"
},
"profilePage": {
"title": "Profile",
"description": "Manage your personal and account information.",
"editProfile": "Edit Profile",
"personalInfo": {
"title": "Personal Information",
"description": "Basic personal details.",
"fullName": "Full Name",
"gender": "Gender",
"age": "Age",
"phone": "Phone",
"address": "Address"
},
"accountInfo": {
"title": "Account Information",
"description": "System account details.",
"email": "Email",
"role": "Role",
"memberSince": "Member Since",
"onboardedAt": "Onboarded At"
},
"studentOverview": {
"title": "Student Overview",
"description": "Your academic performance and schedule."
},
"teacherOverview": {
"title": "Teacher Overview",
"description": "Your teaching subjects and classes.",
"teachingSubjects": "Teaching Subjects",
"teachingSubjectsDesc": "Subjects you are currently assigned to teach.",
"noSubjects": "No subjects assigned yet.",
"teachingClasses": "Teaching Classes",
"teachingClassesDesc": "Classes you are currently managing.",
"noClasses": "No classes assigned yet.",
"view": "View"
}
}
}

View File

@@ -0,0 +1,280 @@
{
"title": "设置",
"backToDashboard": "返回仪表盘",
"tabs": {
"general": "通用",
"notifications": "通知",
"appearance": "外观",
"security": "安全",
"ai": "AI"
},
"profile": {
"title": "个人信息",
"description": "更新您的个人资料。",
"fields": {
"name": "姓名",
"namePlaceholder": "您的姓名",
"email": "邮箱",
"emailDisabled": "邮箱不可修改。",
"phone": "电话",
"phonePlaceholder": "+86 138 0000 0000",
"address": "地址",
"addressPlaceholder": "省市区街道",
"gender": "性别",
"genderPlaceholder": "选择性别",
"age": "年龄",
"role": "角色"
},
"save": "保存修改",
"saving": "保存中...",
"success": "个人资料更新成功",
"failure": "个人资料更新失败"
},
"notifications": {
"title": "通知偏好",
"description": "选择您希望接收通知的方式和时间。",
"channels": {
"title": "通知渠道",
"subtitle": "选择您希望接收通知的渠道。",
"push": "推送通知",
"pushDesc": "接收应用内和浏览器推送通知。",
"email": "邮件",
"emailDesc": "将通知发送到我的注册邮箱。",
"sms": "短信",
"smsDesc": "通过短信发送重要通知(可能产生费用)。"
},
"categories": {
"title": "通知类别",
"subtitle": "选择哪些事件应触发通知。",
"messages": "消息",
"messagesDesc": "新的私信和回复。",
"announcements": "公告",
"announcementsDesc": "学校、年级和班级公告。",
"homework": "作业",
"homeworkDesc": "新作业和提交提醒。",
"grades": "成绩",
"gradesDesc": "考试和作业成绩发布。",
"attendance": "考勤",
"attendanceDesc": "考勤记录和缺勤提醒。"
},
"quietHours": {
"title": "免打扰时段",
"subtitle": "每天在指定时段内暂停非紧急通知。",
"enable": "启用免打扰时段",
"enableDesc": "启用后,仅在指定时段内发送紧急通知。",
"start": "开始时间",
"end": "结束时间"
},
"save": "保存偏好",
"saving": "保存中...",
"success": "通知偏好已更新",
"failure": "通知偏好更新失败"
},
"appearance": {
"theme": {
"title": "主题",
"description": "选择此设备上的界面外观。",
"label": "配色主题",
"system": "跟随系统",
"light": "浅色",
"dark": "深色"
},
"language": {
"title": "语言",
"description": "选择界面语言。",
"label": "界面语言"
}
},
"security": {
"changePassword": {
"title": "修改密码",
"description": "使用强密码保护您的账户安全。",
"current": "当前密码",
"currentPlaceholder": "输入当前密码",
"new": "新密码",
"newPlaceholder": "输入新密码",
"confirm": "确认新密码",
"confirmPlaceholder": "再次输入新密码",
"strength": "密码强度",
"strengthWeak": "弱",
"strengthMedium": "中",
"strengthStrong": "强",
"requirements": "密码要求:",
"submit": "更新密码",
"updating": "更新中..."
},
"session": {
"title": "会话",
"description": "账户访问与会话管理。",
"signOut": "退出登录",
"signOutDesc": "返回登录页面。",
"confirmTitle": "确认退出",
"confirmDesc": "确定要退出登录吗?您将返回登录页面。",
"cancel": "取消",
"confirm": "确认退出"
},
"tips": {
"title": "安全提示",
"description": "保护账户安全的最佳实践。",
"tip1": "使用不与其他网站重复的独立密码。",
"tip2": "避免使用常见词汇、姓名或连续模式。",
"tip3": "定期更换密码。",
"tip4": "多次登录失败后账户将被临时锁定。"
}
},
"ai": {
"providers": {
"title": "AI 服务商",
"description": "管理 AI 供应商和默认模型配置。",
"existing": "已有服务商",
"selectPlaceholder": "新建或选择已有",
"createNew": "新建",
"keyStatus": "密钥状态",
"stored": "已存储",
"noKey": "未存储密钥",
"id": "ID",
"idDesc": "每个服务商自动生成。",
"provider": "服务商",
"providerPlaceholder": "选择服务商",
"baseUrl": "API 地址",
"baseUrlPlaceholder": "https://open.bigmodel.cn/api/paas/v4",
"baseUrlDesc": "输入基础地址,无需 /chat/completions 后缀。",
"model": "模型",
"modelPlaceholder": "gpt-4o-mini",
"apiKey": "API 密钥",
"apiKeyPlaceholder": "粘贴新密钥以替换",
"apiKeyDesc": "已有密钥不会显示。留空则保留当前密钥。",
"setDefault": "设为默认",
"test": "测试",
"testing": "测试中...",
"save": "保存修改",
"saving": "保存中...",
"testSuccess": "测试通过",
"testFailure": "测试失败",
"saveSuccess": "保存成功",
"saveFailure": "保存失败",
"loadFailure": "加载 AI 服务商失败",
"needKey": "请输入 API 密钥进行测试",
"needTest": "保存前请先测试配置"
}
},
"quickLinks": {
"title": "快捷链接",
"description": "您可能想访问的常用页面。",
"profile": "个人资料",
"dashboard": "仪表盘",
"children": "孩子",
"grades": "成绩",
"attendance": "考勤",
"assignments": "作业",
"schedule": "课表",
"textbooks": "教材",
"exams": "考试",
"homework": "作业"
},
"roleDescriptions": {
"admin": "管理您的账户和系统配置。",
"teacher": "管理您的个人信息、通知和教学偏好。",
"student": "管理您的个人信息、通知和学习偏好。",
"parent": "管理您的个人信息、通知和孩子关注偏好。"
},
"errors": {
"loadFailed": "页面加载失败",
"loadFailedDesc": "抱歉,页面加载时发生了意外错误。请稍后重试。",
"retry": "重试",
"sectionLoadFailed": "该区块加载失败",
"sectionLoadFailedDesc": "请稍后重试。"
},
"admin": {
"title": "系统设置",
"description": "管理系统基础信息与运行参数。",
"schoolInfo": {
"title": "学校信息",
"description": "学校的基础信息,将显示在系统各处。",
"name": "学校名称",
"namePlaceholder": "请输入学校名称",
"code": "学校代码",
"codePlaceholder": "请输入学校代码",
"phone": "联系电话",
"phonePlaceholder": "请输入联系电话",
"email": "联系邮箱",
"emailPlaceholder": "请输入联系邮箱",
"address": "学校地址",
"addressPlaceholder": "请输入学校地址",
"description2": "学校简介",
"descriptionPlaceholder": "请输入学校简介"
},
"securityPolicy": {
"title": "安全策略",
"description": "密码策略与会话管理。",
"passwordMinLength": "密码最小长度",
"sessionTimeout": "会话超时(分钟)",
"requireSpecialChar": "密码必须包含特殊字符",
"requireSpecialCharDesc": "要求用户密码中包含至少一个特殊字符",
"requireUppercase": "密码必须包含大写字母",
"requireUppercaseDesc": "要求用户密码中包含至少一个大写字母",
"forcePasswordChange": "首次登录强制修改密码",
"forcePasswordChangeDesc": "新用户或重置密码后首次登录时必须修改密码"
},
"fileUpload": {
"title": "文件上传",
"description": "文件上传限制与存储配置。",
"maxFileSize": "单文件最大大小MB",
"allowedTypes": "允许的文件类型",
"allowedTypesPlaceholder": "如jpg,png,pdf,docx"
},
"notificationConfig": {
"title": "通知配置",
"description": "系统通知的发送方式与触发条件。",
"notifyNewUser": "新用户注册通知管理员",
"notifyNewUserDesc": "有新用户注册时向管理员发送通知",
"notifyScheduleChange": "课表变更通知教师",
"notifyScheduleChangeDesc": "课表变更审批通过后通知相关教师",
"notifyAnnouncement": "公告发布通知目标用户",
"notifyAnnouncementDesc": "公告发布时向目标用户推送通知"
},
"save": "保存设置",
"saving": "保存中...",
"reset": "重置",
"saveSuccess": "设置已保存",
"saveFailure": "设置保存失败",
"loadFailure": "加载系统设置失败"
},
"profilePage": {
"title": "个人资料",
"description": "管理您的个人和账户信息。",
"editProfile": "编辑资料",
"personalInfo": {
"title": "个人信息",
"description": "基本个人资料。",
"fullName": "姓名",
"gender": "性别",
"age": "年龄",
"phone": "电话",
"address": "地址"
},
"accountInfo": {
"title": "账户信息",
"description": "系统账户详情。",
"email": "邮箱",
"role": "角色",
"memberSince": "注册时间",
"onboardedAt": "入职时间"
},
"studentOverview": {
"title": "学生概览",
"description": "您的学业表现和课表。"
},
"teacherOverview": {
"title": "教师概览",
"description": "您任教的科目和班级。",
"teachingSubjects": "任教科目",
"teachingSubjectsDesc": "您当前被分配教授的科目。",
"noSubjects": "暂无分配科目。",
"teachingClasses": "任教班级",
"teachingClassesDesc": "您当前管理的班级。",
"noClasses": "暂无分配班级。",
"view": "查看"
}
}
}