refactor: clean up codebase by removing redundant comments

Remove unnecessary JSDoc comments and redundant explanations from components, types, and data files. Simplify code structure while maintaining functionality.

Clean up language handling logic in components by removing redundant comments and simplifying state management. Move type imports to dedicated type import statements where applicable.
This commit is contained in:
joyzhao
2025-06-21 09:28:10 +08:00
parent ea01dc6dd8
commit 67f713565a
15 changed files with 9 additions and 168 deletions

View File

@@ -2,21 +2,17 @@ import { personalInfo } from "@/lib/data";
import LanguageSwitcher from "./LanguageSwitcher";
import ThemeToggle from "./ui/theme-toggle";
import Container from "./ui/Container";
import { useTranslations, getLocalizedPath, type Lang } from "@/i18n/utils";
import { useTranslations, getLocalizedPath } from "@/i18n/utils";
import type { Lang } from "@/types/i18n";
import { useState, useEffect } from "react";
import { motion, AnimatePresence } from "framer-motion";
import { Menu, X } from "lucide-react";
import { defaultLang } from "@/i18n/ui";
import { type GlassHeaderProps } from "@/types";
// 从window.document.documentElement.lang获取当前语言
export default function GlassHeader({ lang: propLang }: GlassHeaderProps) {
// 优先使用props传入的语言如果没有则尝试从HTML lang属性获取
const [lang, setLang] = useState<Lang>(propLang || defaultLang);
useEffect(() => {
// 在客户端运行时从HTML lang属性获取当前语言
const htmlLang = document.documentElement.lang as Lang;
if (htmlLang && (!propLang || htmlLang !== lang)) {
setLang(htmlLang);