{% load djacore_tags %}{% load default_tags %}
<nav class="navbar navbar-expand-lg bg-body-tertiary shadow-sm">
    <div class="container-fluid">
      <a class="fw-bold navbar-brand" href="{% url 'home' %}">{% if logo %}<img src="{{ uploadpath }}{{ logo }}" alt="{{ site_name }}">{% else %}{{ site_name }}{% endif %}</a><span>用户中心</span>
      
      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav me-auto mb-2 mb-lg-0 ms-auto me-auto">
          <li class="nav-item">
            <a class="nav-link active" aria-current="page" href="{% url 'users:user_index' %}">首页</a>
          </li>
          
          
        </ul>

        <div id="searchbox" class="position-relative ms-auto">
            <form action="/search" class="d-flex" role="search">
              <input class="form-control me-2" id="searchinput" onkeyup="search(this.value)" type="search" name="key" placeholder="请输入关键词" aria-label="Search">
              <button class="btn btn-outline-success flex-shrink-0" type="submit">搜索</button>  
            </form>
            <div id="result-box" class="text-start"><ul id="result" class="list-group"></ul></div>
          </div>
          <div class="me-auto ms-auto">
          {% if user.is_active %}
          <div class="dropdown">
            <a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
              {% if userinfo.nickname %}{{userinfo.nickname}}{% else %}{{user}}{% endif %}
            </a>
            <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
              <li><a class="dropdown-item" href="{% url 'users:user_index' %}">用户信息</a></li>
              <li><a class="dropdown-item" href="{% url 'users:change_password' %}">修改密码</a></li>
              <li class="border-top dropdown-item"><form action="{% url 'users:logout' %}" method="post" style="display: inline;">
                {% csrf_token %}
                <button type="submit" class="btn">退出登录</button>
            </form></li>
            </ul>
          </div>
          {% else %}
          <a href="{% url 'users:register' %}">注册</a>/ <a href="/user/login/">登录</a>
          {% endif  %}

        </div>
      </div>
    </div>
  </nav>