nextjs项目搭建——头部导航

news/2025/2/24 9:40:01

Header.tsx

在src/app/component路径下,创建Header.tsx

'use client';

import Link from 'next/link';
import { usePathname } from 'next/navigation';
import Logo from './Logo';

const Header = () => {
  const pathname = usePathname();

  const navItems = [
    { label: '首页', href: '/' },
    { label: '量表测试', href: '/test' },
    { label: 'AI咨询', href: '/ai-consultation' },
    { label: '名师咨询', href: '/expert-consultation' },
    { label: '直播', href: '/live' },
    { label: '团体方案', href: '/group-solutions' },
  ];

  return (
    <header className="w-full bg-white shadow-sm">
      <div className="max-w-7xl mx-auto px-4 h-16 flex items-center justify-between">
        <div className="flex items-center">
          <Link href="/" className="flex items-center">
            <Logo />
            <span className="text-[#40a9ff] text-lg font-medium ml-2">MindAI</span>
            <span className="text-gray-500 text-sm ml-2">您身边的心理医生</span>
          </Link>
        </div>

        <nav className="flex items-center space-x-8">
          {navItems.map((item) => (
            <Link
              key={item.href}
              href={item.href}
              className={`text-base ${
                pathname === item.href
                  ? 'text-[#40a9ff] font-medium'
                  : 'text-gray-600 hover:text-[#40a9ff]'
              }`}
            >
              {item.label}
            </Link>
          ))}
        </nav>

        <div className="flex items-center space-x-4">
          <div className="relative">
            <Link href="/notifications">
              <div className="text-gray-600 hover:text-[#40a9ff]">
                <svg
                  xmlns="http://www.w3.org/2000/svg"
                  className="h-6 w-6"
                  fill="none"
                  viewBox="0 0 24 24"
                  stroke="currentColor"
                >
                  <path
                    strokeLinecap="round"
                    strokeLinejoin="round"
                    strokeWidth={2}
                    d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"
                  />
                </svg>
              </div>
            </Link>
            <span className="absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full h-4 w-4 flex items-center justify-center">
              1
            </span>
          </div>

          <Link
            href="/login"
            className="px-4 py-2 rounded bg-[#40a9ff] text-white hover:bg-[#1890ff] transition-colors"
          >
            登录/注册
          </Link>
        </div>
      </div>
    </header>
  );
};

export default Header; 

logo

这里有我自己创建的logo

const Logo = () => {
  return (
    <svg
      width="40"
      height="40"
      viewBox="0 0 40 40"
      fill="none"
      xmlns="http://www.w3.org/2000/svg"
    >
      <path
        d="M20 35C20 35 33 26 33 16.7059C33 10.5882 28.0294 7 23.8235 7C21.0588 7 20 8.76471 20 8.76471C20 8.76471 18.9412 7 16.1765 7C11.9706 7 7 10.5882 7 16.7059C7 26 20 35 20 35Z"
        fill="#40a9ff"
        stroke="#40a9ff"
        strokeWidth="2"
        strokeLinecap="round"
        strokeLinejoin="round"
      />
      <circle
        cx="28"
        cy="28"
        r="8"
        fill="white"
        stroke="#40a9ff"
        strokeWidth="2"
      />
      <path
        d="M28 24V32M24 28H32"
        stroke="#40a9ff"
        strokeWidth="2"
        strokeLinecap="round"
      />
    </svg>
  );
};

export default Logo; 

login

这里面还涉及到login的页面


http://www.niftyadmin.cn/n/5864190.html

相关文章

本地部署Qwen2.5-VL-7B-Instruct多模态视觉大模型(Windows篇)

本文已首发于 秋码记录 如果你也想搭建一个与秋码记录一样的网站&#xff0c;可以浏览我的这篇 国内 gitee.com Pages 下线了&#xff0c;致使众多站长纷纷改用 github、gitlab Pages 托管平台 秋码记录网站使用的主题是开源的&#xff0c;目前只在github.com开源。 hugo-the…

Windows PyCharm的python项目移动存储位置后需要做的变更

项目使用的venv虚拟环境&#xff0c;因此项目移动存储位置后需要重新配置python解释器的位置&#xff0c;否则无法识别&#xff0c;若非虚拟环境中运行&#xff0c;则直接移动后打开即可&#xff0c;无需任何配置。 PyCharm版本为2021.3.3 (Professional Edition)&#xff0c;其…

选择排序和计数排序

选择排序和计数排序 选择排序 定义 选择排序是一种简单直观的排序算法。它的基本思想是在每一趟遍历中找到未排序部分中的最小元素&#xff0c;并将其放到正确的位置上。 操作步骤 初始化&#xff1a;设数组长度为 n。外层循环&#xff1a;控制需要选择的位置 i&#xff0c;从 …

java实现多图合并加字和画框等

java实现多图合并加字和画框等 在wutool中&#xff0c;封装了图片处理工具类&#xff0c;基于java自带的BufferedImage类&#xff0c;实现多图合并和加字、图片画框等。 关于wutool wutool是一个java代码片段收集库&#xff0c;针对特定场景提供轻量解决方案&#xff0c;只要…

系统讨论Qt的并发编程——逻辑上下文的分类

目录 前言 首先&#xff0c;讨论Qt里常见的三种上下文 同一线程的串行执行 同一线程的异步执行 多线程的执行 moveToThread办法 前言 笔者最近看了一个具备一定启发性质的Qt教程&#xff0c;在这里&#xff0c;笔者打算整理一下自己的笔记。分享在这里. 首先&#xff0c…

福昕阅读器方便快捷方法技巧

标题 福昕阅读器方便快捷 1 快捷键设置&#xff1a; 常用有&#xff1a;高亮、绘图矩形、打字机等

Visual Studio更新说明(关注:.NET+AI生产力)

Ver V0.0&#xff1a;Visual Studio 2022 v17.12更新:.NET9AI生产力 AI插件推荐 &#xff08;1&#xff09;腾讯云AI代码手&#xff08;内含了DeepSeek-R1&#xff09;&#xff0c;目前免费&#xff0c;但收费我也可能会买。 AI插件!推荐 &#xff08;1&#xff09;百度的…

BY组态:开启工业智能化的未来之钥

在工业自动化与数字化转型的浪潮中&#xff0c;组态软件&#xff08;SCADA&#xff09;作为工业控制系统的“大脑”&#xff0c;已成为企业提升效率、优化流程的核心工具。而BY组态&#xff0c;作为新一代智能化组态软件平台&#xff0c;凭借其高效、灵活、安全、智能的特性&am…