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:
@@ -1,4 +1,5 @@
|
||||
import { useTranslations, type Lang } from "@/i18n/utils";
|
||||
import { useTranslations } from "@/i18n/utils";
|
||||
import type { Lang } from "@/types/i18n";
|
||||
import { personalInfo } from "@/lib/data";
|
||||
import { motion } from "framer-motion";
|
||||
import { useState, useEffect } from "react";
|
||||
@@ -7,11 +8,9 @@ import Container from "./ui/Container";
|
||||
import { type FooterProps } from "@/types";
|
||||
|
||||
export default function Footer({ lang: propLang }: FooterProps) {
|
||||
// 优先使用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);
|
||||
|
||||
Reference in New Issue
Block a user