暫無描述

base.html 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {% load static tailwind_tags %}
  2. {% load django_browser_reload %}
  3. <!DOCTYPE html>
  4. <html lang="en">
  5. <head>
  6. <meta charset="UTF-8">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>{% block title %}My Django App{% endblock %}</title>
  9. <!-- TailwindCSS -->
  10. <!--
  11. <script src="https://cdn.tailwindcss.com"></script> -->
  12. {% tailwind_css %}
  13. <script type="text/javascript" defer src="{% static "alpinejs/dist/cdn.min.js" %}"></script>
  14. <link href="https://cdn.jsdelivr.net/npm/flowbite@2.5.2/dist/flowbite.min.css" rel="stylesheet" />
  15. <script type="text/javascript" src="{% static "js/main.js" %}"></script>
  16. </head>
  17. <body class="bg-gray-100 text-gray-800">
  18. <!-- Navbar -->
  19. <nav class="fixed top-0 z-50 w-full bg-white border-b border-gray-200 dark:bg-gray-800 dark:border-gray-700">
  20. <div class="px-3 py-3 lg:px-5 lg:pl-3">
  21. <div class="flex items-center justify-between">
  22. <div class="flex items-center justify-start">
  23. <button data-drawer-target="logo-sidebar" data-drawer-toggle="logo-sidebar" aria-controls="logo-sidebar" type="button" class="inline-flex items-center p-2 text-sm text-gray-500 rounded-lg sm:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600">
  24. <span class="sr-only">Open sidebar</span>
  25. <svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
  26. <path clip-rule="evenodd" fill-rule="evenodd" d="M2 4.75A.75.75 0 012.75 4h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 4.75zm0 10.5a.75.75 0 01.75-.75h7.5a.75.75 0 010 1.5h-7.5a.75.75 0 01-.75-.75zM2 10a.75.75 0 01.75-.75h14.5a.75.75 0 010 1.5H2.75A.75.75 0 012 10z"></path>
  27. </svg>
  28. </button>
  29. <a href="/" class="flex items-center ml-2">
  30. <img src="https://flowbite.com/docs/images/logo.svg" class="h-8 mr-3" alt="Logo" />
  31. <span class="self-center text-xl font-semibold dark:text-white">My App</span>
  32. </a>
  33. </div>
  34. <div class="flex items-center space-x-4">
  35. {% if user.is_authenticated %}
  36. <!-- Logged-in User -->
  37. <span class="text-gray-600 dark:text-gray-300">Hello, {{ user.username }}</span>
  38. <a href="{% url 'sysadmin:logout' %}" class="text-blue-500 hover:underline">Logout</a>
  39. {% else %}
  40. <!-- Guest User -->
  41. <a href="{% url 'sysadmin:login' %}" class="text-blue-500 hover:underline">Login</a>
  42. <a href="{% url 'sysadmin:register' %}" class="text-blue-500 hover:underline">Register</a>
  43. {% endif %}
  44. <div class="ml-3">
  45. <button type="button" class="flex text-sm bg-gray-800 rounded-full focus:ring-4 focus:ring-gray-300 dark:focus:ring-gray-600">
  46. <span class="sr-only">Open user menu</span>
  47. <img class="w-8 h-8 rounded-full" src="https://flowbite.com/docs/images/people/profile-picture-5.jpg" alt="User">
  48. </button>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </nav>
  54. <!-- Sidebar -->
  55. {% if not hide_sidebar %}
  56. <aside id="logo-sidebar" class="fixed top-0 left-0 z-40 w-64 h-screen pt-20 transition-transform -translate-x-full bg-white border-r border-gray-200 sm:translate-x-0 dark:bg-gray-800 dark:border-gray-700">
  57. <div class="h-full px-3 pb-4 overflow-y-auto">
  58. <ul class="space-y-2">
  59. <li><a href="/dashboard/" class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"><span class="ml-3">Dashboard</span></a></li>
  60. <li><a href="/reports/" class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"><span class="ml-3">Reports</span></a></li>
  61. <li><a href="/settings/" class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"><span class="ml-3">Settings</span></a></li>
  62. </ul>
  63. </div>
  64. </aside>
  65. {% endif %}
  66. <!-- Main Content -->
  67. <div class="p-4 sm:ml-64">
  68. <div class="mt-14">{% block content %}{% endblock %}</div>
  69. </div>
  70. <!-- Footer -->
  71. <footer class="bg-gray-200 py-4 text-center">
  72. <p class="text-sm text-gray-600">&copy; 2024 My Django App. All rights reserved.</p>
  73. </footer>
  74. <script type="text/javascript" src="{% static "underscore/underscore-min.js" %}"></script>
  75. <script src="https://cdn.jsdelivr.net/npm/flowbite@2.5.2/dist/flowbite.min.js"></script>
  76. {% django_browser_reload_script %}
  77. </body>
  78. </html>