sidebar.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <div class="w-64 tech-panel flex flex-col transition-all duration-300 transform -translate-x-full md:translate-x-0 fixed md:relative z-30 h-full border-r-0 md:border-r border-blue-900/30" id="sidebar">
  2. <div class="p-6 flex items-center justify-between transition-all duration-300" id="sidebar-header">
  3. <span class="text-xl font-bold tech-title tracking-wider flex items-center gap-2 whitespace-nowrap overflow-hidden" id="sidebar-brand">
  4. <i class="fas fa-globe-asia text-blue-500 min-w-[1.5rem] text-center"></i>
  5. <span class="sidebar-text transition-opacity duration-300">政企瞭望</span>
  6. </span>
  7. <button class="md:hidden text-gray-300 hover:text-white focus:outline-none" id="close-sidebar">
  8. <i class="fas fa-times"></i>
  9. </button>
  10. <button class="hidden md:block text-gray-400 hover:text-white focus:outline-none transition-transform duration-300" id="toggle-sidebar">
  11. <i class="fas fa-chevron-left"></i>
  12. </button>
  13. </div>
  14. <nav class="flex-1 overflow-y-auto px-3 py-2">
  15. <ul class="space-y-1">
  16. <li>
  17. <a class="flex items-center px-4 py-3 rounded-lg {% if request.endpoint == 'main.dashboard' %}bg-gradient-to-r from-blue-600 to-blue-800 text-white shadow-lg{% else %}text-gray-400 hover:bg-gray-800 hover:text-white{% endif %} transition-all duration-200 group" href="{{ url_for('main.dashboard') }}">
  18. <i class="fas fa-tachometer-alt w-6 text-center {% if request.endpoint == 'main.dashboard' %}text-white{% else %}text-gray-500 group-hover:text-blue-400{% endif %} transition-colors"></i>
  19. <span class="ml-2 font-medium sidebar-text whitespace-nowrap">后台主页</span>
  20. </a>
  21. </li>
  22. <li>
  23. <a class="flex items-center px-4 py-3 rounded-lg {% if request.endpoint == 'collection.dashboard' %}bg-gradient-to-r from-blue-600 to-blue-800 text-white shadow-lg{% else %}text-gray-400 hover:bg-gray-800 hover:text-white{% endif %} transition-all duration-200 group" href="{{ url_for('collection.dashboard') }}">
  24. <i class="fas fa-tasks w-6 text-center {% if request.endpoint == 'collection.dashboard' %}text-white{% else %}text-gray-500 group-hover:text-blue-400{% endif %} transition-colors"></i>
  25. <span class="ml-2 font-medium sidebar-text whitespace-nowrap">采集管理</span>
  26. </a>
  27. </li>
  28. <li>
  29. <a class="flex items-center px-4 py-3 rounded-lg {% if request.endpoint == 'source.dashboard' %}bg-gradient-to-r from-blue-600 to-blue-800 text-white shadow-lg{% else %}text-gray-400 hover:bg-gray-800 hover:text-white{% endif %} transition-all duration-200 group" href="{{ url_for('source.dashboard') }}">
  30. <i class="fas fa-spider w-6 text-center {% if request.endpoint == 'source.dashboard' %}text-white{% else %}text-gray-500 group-hover:text-blue-400{% endif %} transition-colors"></i>
  31. <span class="ml-2 font-medium sidebar-text whitespace-nowrap">爬虫管理</span>
  32. </a>
  33. </li>
  34. <li>
  35. <a class="flex items-center px-4 py-3 rounded-lg {% if request.endpoint == 'data.dashboard' %}bg-gradient-to-r from-blue-600 to-blue-800 text-white shadow-lg{% else %}text-gray-400 hover:bg-gray-800 hover:text-white{% endif %} transition-all duration-200 group" href="{{ url_for('data.dashboard') }}">
  36. <i class="fas fa-database w-6 text-center {% if request.endpoint == 'data.dashboard' %}text-white{% else %}text-gray-500 group-hover:text-blue-400{% endif %} transition-colors"></i>
  37. <span class="ml-2 font-medium sidebar-text whitespace-nowrap">数据管理</span>
  38. </a>
  39. </li>
  40. <li>
  41. <a class="flex items-center px-4 py-3 rounded-lg {% if request.endpoint == 'deep.dashboard' %}bg-gradient-to-r from-blue-600 to-blue-800 text-white shadow-lg{% else %}text-gray-400 hover:bg-gray-800 hover:text-white{% endif %} transition-all duration-200 group" href="{{ url_for('deep.dashboard') }}">
  42. <i class="fas fa-search-plus w-6 text-center {% if request.endpoint == 'deep.dashboard' %}text-white{% else %}text-gray-500 group-hover:text-blue-400{% endif %} transition-colors"></i>
  43. <span class="ml-2 font-medium sidebar-text whitespace-nowrap">深采管理</span>
  44. </a>
  45. </li>
  46. <li>
  47. <a class="flex items-center px-4 py-3 rounded-lg {% if request.endpoint == 'ai.dashboard' %}bg-gradient-to-r from-blue-600 to-blue-800 text-white shadow-lg{% else %}text-gray-400 hover:bg-gray-800 hover:text-white{% endif %} transition-all duration-200 group" href="{{ url_for('ai.dashboard') }}">
  48. <i class="fas fa-robot w-6 text-center {% if request.endpoint == 'ai.dashboard' %}text-white{% else %}text-gray-500 group-hover:text-blue-400{% endif %} transition-colors"></i>
  49. <span class="ml-2 font-medium sidebar-text whitespace-nowrap">AI模型管理</span>
  50. </a>
  51. </li>
  52. <li>
  53. <a class="flex items-center px-4 py-3 rounded-lg {% if request.endpoint == 'ai.analysis' %}bg-gradient-to-r from-blue-600 to-blue-800 text-white shadow-lg{% else %}text-gray-400 hover:bg-gray-800 hover:text-white{% endif %} transition-all duration-200 group" href="{{ url_for('ai.analysis') }}">
  54. <i class="fas fa-chart-line w-6 text-center {% if request.endpoint == 'ai.analysis' %}text-white{% else %}text-gray-500 group-hover:text-blue-400{% endif %} transition-colors"></i>
  55. <span class="ml-2 font-medium sidebar-text whitespace-nowrap">AI分析报告</span>
  56. </a>
  57. </li>
  58. <li>
  59. <a class="flex items-center px-4 py-3 rounded-lg text-gray-400 hover:bg-gray-800 hover:text-white transition-all duration-200 group" href="{{ url_for('main.screen_page') }}" target="_blank">
  60. <i class="fas fa-tv w-6 text-center text-gray-500 group-hover:text-blue-400 transition-colors"></i>
  61. <span class="ml-2 font-medium sidebar-text whitespace-nowrap">AI数智大屏</span>
  62. </a>
  63. </li>
  64. </ul>
  65. </nav>
  66. <div class="p-4 mx-3 mb-4 mt-auto rounded-xl bg-gray-800/50 backdrop-blur-sm transition-all duration-300">
  67. <a href="{{ url_for('main.logout') }}" class="flex items-center justify-center text-gray-400 hover:text-red-400 transition duration-200 group">
  68. <i class="fas fa-sign-out-alt w-5 text-center group-hover:scale-110 transition-transform"></i>
  69. <span class="ml-2 text-sm font-medium sidebar-text whitespace-nowrap">退出登录</span>
  70. </a>
  71. </div>
  72. </div>
  73. <script>
  74. document.addEventListener('DOMContentLoaded', function() {
  75. const sidebar = document.getElementById('sidebar');
  76. const sidebarHeader = document.getElementById('sidebar-header');
  77. const toggleBtn = document.getElementById('toggle-sidebar');
  78. const toggleIcon = toggleBtn.querySelector('i');
  79. const sidebarTexts = document.querySelectorAll('.sidebar-text');
  80. const sidebarBrand = document.getElementById('sidebar-brand');
  81. const brandText = sidebarBrand.querySelector('.sidebar-text');
  82. // Load state
  83. const isCollapsed = localStorage.getItem('sidebar-collapsed') === 'true';
  84. if (isCollapsed) {
  85. collapseSidebar(false);
  86. }
  87. toggleBtn.addEventListener('click', function() {
  88. const collapsed = sidebar.classList.contains('w-20');
  89. if (collapsed) {
  90. expandSidebar();
  91. } else {
  92. collapseSidebar(true);
  93. }
  94. });
  95. function collapseSidebar(animate) {
  96. if(animate) sidebar.classList.add('transition-all', 'duration-300');
  97. sidebar.classList.remove('w-64');
  98. sidebar.classList.add('w-20');
  99. // Adjust Header Layout
  100. sidebarHeader.classList.remove('p-6', 'justify-between');
  101. sidebarHeader.classList.add('p-4', 'flex-col', 'justify-center', 'gap-4');
  102. sidebarTexts.forEach(text => {
  103. text.classList.add('opacity-0', 'w-0', 'ml-0', 'overflow-hidden');
  104. text.classList.remove('ml-2');
  105. });
  106. toggleIcon.classList.add('rotate-180');
  107. localStorage.setItem('sidebar-collapsed', 'true');
  108. }
  109. function expandSidebar() {
  110. sidebar.classList.add('transition-all', 'duration-300');
  111. sidebar.classList.remove('w-20');
  112. sidebar.classList.add('w-64');
  113. // Restore Header Layout
  114. sidebarHeader.classList.add('p-6', 'justify-between');
  115. sidebarHeader.classList.remove('p-4', 'flex-col', 'justify-center', 'gap-4');
  116. sidebarTexts.forEach(text => {
  117. text.classList.remove('opacity-0', 'w-0', 'ml-0', 'overflow-hidden');
  118. text.classList.add('ml-2');
  119. });
  120. toggleIcon.classList.remove('rotate-180');
  121. localStorage.setItem('sidebar-collapsed', 'false');
  122. }
  123. });
  124. </script>