feat: 重构联系页面并增强安全性

refactor: 优化导航和路由逻辑

fix: 修复移动端样式问题

perf: 优化字体加载和性能

test: 添加安全性和可访问性测试

style: 调整按钮和表单样式

chore: 更新依赖版本

ci: 添加安全头配置

build: 优化构建配置

docs: 更新常量信息
This commit is contained in:
张翔
2026-03-01 10:56:54 +08:00
parent 13c4a2ca49
commit 9cbc80742a
24 changed files with 1087 additions and 440 deletions
+9 -9
View File
@@ -26,19 +26,19 @@ export function MobileMenu({ className }: MobileMenuProps) {
};
}, [isOpen]);
const handleNavClick = (href: string) => {
const handleNavClick = (id: string) => {
setIsOpen(false);
const element = document.querySelector(href);
const element = document.getElementById(id);
if (element) {
element.scrollIntoView({ behavior: 'smooth' });
}
};
const handleKeyDown = (event: React.KeyboardEvent, href?: string) => {
const handleKeyDown = (event: React.KeyboardEvent, id?: string) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
if (href) {
handleNavClick(href);
if (id) {
handleNavClick(id);
} else {
setIsOpen(!isOpen);
}
@@ -53,7 +53,7 @@ export function MobileMenu({ className }: MobileMenuProps) {
<button
onClick={() => setIsOpen(!isOpen)}
onKeyDown={(e) => handleKeyDown(e)}
className="p-2 rounded-md hover:bg-[#F5F5F5] transition-colors focus:outline-none focus:ring-2 focus:ring-[#C41E3A] focus:ring-offset-2"
className="p-3 rounded-md hover:bg-[#F5F5F5] transition-colors focus:outline-none focus:ring-2 focus:ring-[#C41E3A] focus:ring-offset-2 min-w-[48px] min-h-[48px] flex items-center justify-center"
aria-label={isOpen ? '关闭菜单' : '打开菜单'}
aria-expanded={isOpen}
aria-controls="mobile-menu-panel"
@@ -84,9 +84,9 @@ export function MobileMenu({ className }: MobileMenuProps) {
{NAVIGATION.map((item) => (
<li key={item.id}>
<button
onClick={() => handleNavClick(item.href)}
onKeyDown={(e) => handleKeyDown(e, item.href)}
className="block w-full text-left px-4 py-3 text-[#171717] hover:bg-[#FEF2F4] hover:text-[#C41E3A] rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-[#C41E3A] focus:ring-inset"
onClick={() => handleNavClick(item.id)}
onKeyDown={(e) => handleKeyDown(e, item.id)}
className="block w-full text-left px-4 py-4 text-[#171717] hover:bg-[#FEF2F4] hover:text-[#C41E3A] rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-[#C41E3A] focus:ring-inset min-h-[48px]"
>
{item.label}
</button>