2025-06-05 20:38:10 +08:00
|
|
|
|
"use client";
|
2025-05-10 17:02:57 +08:00
|
|
|
|
import Image from "next/image";
|
|
|
|
|
import Link from "next/link";
|
2025-06-05 20:38:10 +08:00
|
|
|
|
import { useEffect, useState } from "react";
|
2025-05-10 17:02:57 +08:00
|
|
|
|
|
2025-03-31 19:43:56 +08:00
|
|
|
|
import { HeaderNav } from "./headerNav";
|
2025-04-19 12:46:08 +08:00
|
|
|
|
import { HeaderTools } from "./headerTools";
|
2024-11-04 16:15:49 +08:00
|
|
|
|
|
2025-06-05 20:38:10 +08:00
|
|
|
|
//导航
|
|
|
|
|
|
2024-10-29 11:59:38 +08:00
|
|
|
|
export const Header = () => {
|
2025-06-05 20:38:10 +08:00
|
|
|
|
const [opacity, setOpacity] = useState(1); // 初始透明度为1(完全不透明)
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const handleScroll = () => {
|
|
|
|
|
// 根据滚动位置计算透明度
|
|
|
|
|
const newOpacity = 1 - Math.min(window.scrollY / 200, 1);
|
|
|
|
|
setOpacity(newOpacity);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 添加滚动事件监听器
|
|
|
|
|
window.addEventListener("scroll", handleScroll);
|
|
|
|
|
|
|
|
|
|
// 移除滚动事件监听器
|
|
|
|
|
return () => {
|
|
|
|
|
window.removeEventListener("scroll", handleScroll);
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
2025-03-31 19:43:56 +08:00
|
|
|
|
return (
|
2025-06-05 20:38:10 +08:00
|
|
|
|
<header
|
|
|
|
|
className=" tw-py-5 lg:tw-px-40 tw-fixed tw-top-0 tw-left-0 tw-w-full tw-z-50"
|
|
|
|
|
style={{
|
|
|
|
|
backgroundColor: `rgba(248 ,250 ,252, ${opacity})`, // 使用rgba格式设置背景色和透明度
|
|
|
|
|
transition: "background-color 0.3s ease", // 添加过渡效果
|
|
|
|
|
}}
|
|
|
|
|
>
|
2025-05-10 17:02:57 +08:00
|
|
|
|
<div className="tw-flex tw-justify-between tw-items-center ">
|
|
|
|
|
<div className=" tw-flex-1 tw-flex tw-flex-row tw-ml-8 ">
|
|
|
|
|
<Link href={"/"}>
|
2025-06-12 20:48:51 +08:00
|
|
|
|
<Image
|
|
|
|
|
src={"/logo.png"}
|
|
|
|
|
alt="logo"
|
|
|
|
|
width={174}
|
|
|
|
|
height={40}
|
|
|
|
|
priority
|
|
|
|
|
></Image>
|
2025-05-10 17:02:57 +08:00
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
<div className=" tw-flex tw-flex-auto tw-flex-col tw-w-3/5 tw-justify-center tw-items-center ">
|
|
|
|
|
<HeaderNav></HeaderNav>
|
|
|
|
|
</div>
|
|
|
|
|
<div className=" tw-flex-1 tw-flex tw-flex-row-reverse tw-mr-8 ">
|
|
|
|
|
<HeaderTools></HeaderTools>
|
|
|
|
|
</div>
|
2025-03-31 19:43:56 +08:00
|
|
|
|
</div>
|
2025-04-19 12:46:08 +08:00
|
|
|
|
</header>
|
2025-03-31 19:43:56 +08:00
|
|
|
|
);
|
2024-10-29 11:59:38 +08:00
|
|
|
|
};
|