当前位置: 首页 > article >正文

nextjs项目搭建——头部导航

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.kler.cn/a/559555.html

相关文章:

  • 如何使用Python快速开发一个带管理系统界面的网站-解析方案
  • 【DeepSeek-R1背后的技术】系列十一:RAG原理介绍和本地部署(DeepSeek+RAGFlow构建个人知识库)
  • 游戏开发 游戏项目介绍
  • 深入解析浏览器渲染全流程:从URL输入到页面渲染的底层原理与性能优化(附实战代码)
  • seacms V9 SQL报错注入
  • Obsidian·Copilot 插件配置(让AI根据Obsidian笔记内容进行对话)
  • 【GPU驱动】OpenGLES图形管线渲染机制
  • PHP脚本示例
  • 【CSS】---- CSS 变量,实现样式和动画函数复用
  • 一种简单有效的分析qnx+android智能座舱项目中的画面闪烁的方法(8155平台)
  • vscode无法预览Markdown在线图片链接
  • 跟着李沐老师学习深度学习(十三)
  • 国产芯片汽车气压表pcba方案
  • AI学习之-阿里天池
  • React fiber架构中 优先级是如何确定的?
  • 【Bluedroid】AVRCP 连接源码分析(三)
  • 【NLP算法面经】本科双非,头条+腾讯 NLP 详细面经(★附面题整理★)
  • SOME/IP--协议英文原文讲解10
  • c++———————————————c++11
  • 小型字符级语言模型的改进方向和策略