AppNavbar.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <div class="navbar-container">
  3. <div class="navbar-background">
  4. <div class="navbar-content">
  5. <div class="navbar-logo">
  6. <h1 class="logo-text">智能知识库</h1>
  7. </div>
  8. <el-menu
  9. :default-active="activeRoute"
  10. mode="horizontal"
  11. @select="handleSelect"
  12. class="custom-nav-menu"
  13. >
  14. <el-menu-item index="/" class="nav-item">
  15. <span class="nav-icon">📚</span>
  16. 知识库
  17. </el-menu-item>
  18. <el-menu-item index="/search" class="nav-item">
  19. <span class="nav-icon">🔍</span>
  20. 搜索
  21. </el-menu-item>
  22. <el-menu-item index="/qanda" class="nav-item">
  23. <span class="nav-icon">💬</span>
  24. 问答
  25. </el-menu-item>
  26. </el-menu>
  27. <!-- <div class="navbar-actions">-->
  28. <!-- <div class="user-info">-->
  29. <!-- <span class="user-avatar">👤</span>-->
  30. <!-- <span class="user-name">用户</span>-->
  31. <!-- </div>-->
  32. <!-- </div>-->
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script lang="ts">
  38. import { defineComponent, computed } from 'vue';
  39. import { useRoute, useRouter } from 'vue-router';
  40. export default defineComponent({
  41. name: 'AppNavbar',
  42. setup() {
  43. const route = useRoute();
  44. const router = useRouter();
  45. // 动态计算激活的路由
  46. const activeRoute = computed(() => {
  47. if (route.path.startsWith('/knowledge/content')) {
  48. return '/'; // 知识库页面时,设置为高亮 "知识库"
  49. }
  50. return route.path;
  51. });
  52. const handleSelect = (index: string) => {
  53. router.push(index);
  54. };
  55. return {
  56. activeRoute,
  57. handleSelect,
  58. };
  59. },
  60. });
  61. </script>
  62. <style scoped>
  63. .navbar-container {
  64. width: 100%;
  65. z-index: 1000;
  66. }
  67. .navbar-background {
  68. background: linear-gradient(135deg, #667eea 0%, rgba(118, 75, 162, 0.88) 100%);
  69. backdrop-filter: blur(20px);
  70. border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  71. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  72. }
  73. .navbar-content {
  74. max-width: 1400px;
  75. margin: 0 auto;
  76. padding: 0 24px;
  77. display: flex;
  78. align-items: center;
  79. justify-content: space-between;
  80. height: 70px;
  81. }
  82. .navbar-logo {
  83. display: flex;
  84. align-items: center;
  85. }
  86. .logo-text {
  87. color: white;
  88. font-size: 1.5rem;
  89. font-weight: 700;
  90. margin: 0;
  91. text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  92. background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
  93. -webkit-background-clip: text;
  94. -webkit-text-fill-color: transparent;
  95. background-clip: text;
  96. }
  97. /* 自定义导航菜单样式 */
  98. .custom-nav-menu {
  99. background: transparent !important;
  100. border: none !important;
  101. display: flex;
  102. align-items: center;
  103. gap: 8px;
  104. flex: 1;
  105. justify-content: center;
  106. }
  107. .custom-nav-menu :deep(.el-menu--horizontal) {
  108. border: none;
  109. background: transparent;
  110. }
  111. .custom-nav-menu :deep(.el-menu-item) {
  112. background: rgba(255, 255, 255, 0.1) !important;
  113. color: rgba(255, 255, 255, 0.9) !important;
  114. border: 1px solid rgba(255, 255, 255, 0.2) !important;
  115. border-radius: 12px !important;
  116. padding: 12px 24px !important;
  117. margin: 0 8px !important;
  118. font-size: 16px !important;
  119. font-weight: 500 !important;
  120. transition: all 0.3s ease !important;
  121. display: flex !important;
  122. align-items: center !important;
  123. gap: 8px !important;
  124. height: auto !important;
  125. line-height: 1.5 !important;
  126. }
  127. .custom-nav-menu :deep(.el-menu-item:hover) {
  128. background: rgba(255, 255, 255, 0.2) !important;
  129. color: white !important;
  130. border-color: rgba(255, 255, 255, 0.3) !important;
  131. transform: translateY(-2px) !important;
  132. box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2) !important;
  133. }
  134. .custom-nav-menu :deep(.el-menu-item.is-active) {
  135. background: rgba(255, 255, 255, 0.25) !important;
  136. color: white !important;
  137. border-color: rgba(255, 255, 255, 0.4) !important;
  138. box-shadow: 0 4px 20px rgba(255, 255, 255, 0.3) !important;
  139. }
  140. .nav-icon {
  141. font-size: 1.2rem;
  142. filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  143. }
  144. .navbar-actions {
  145. display: flex;
  146. align-items: center;
  147. }
  148. .user-info {
  149. display: flex;
  150. align-items: center;
  151. gap: 12px;
  152. background: rgba(255, 255, 255, 0.1);
  153. padding: 8px 16px;
  154. border-radius: 12px;
  155. border: 1px solid rgba(255, 255, 255, 0.2);
  156. color: white;
  157. transition: all 0.3s ease;
  158. }
  159. .user-info:hover {
  160. background: rgba(255, 255, 255, 0.2);
  161. transform: translateY(-1px);
  162. }
  163. .user-avatar {
  164. font-size: 1.2rem;
  165. }
  166. .user-name {
  167. font-weight: 500;
  168. font-size: 14px;
  169. }
  170. /* 响应式设计 */
  171. @media (max-width: 768px) {
  172. .navbar-content {
  173. padding: 0 16px;
  174. height: 60px;
  175. }
  176. .logo-text {
  177. font-size: 1.25rem;
  178. }
  179. .custom-nav-menu :deep(.el-menu-item) {
  180. padding: 10px 16px !important;
  181. font-size: 14px !important;
  182. margin: 0 4px !important;
  183. }
  184. .nav-icon {
  185. font-size: 1rem;
  186. }
  187. .user-info {
  188. padding: 6px 12px;
  189. }
  190. .user-name {
  191. display: none;
  192. }
  193. }
  194. @media (max-width: 480px) {
  195. .navbar-content {
  196. flex-wrap: wrap;
  197. height: auto;
  198. padding: 12px 16px;
  199. }
  200. .navbar-logo {
  201. order: 1;
  202. flex: 1;
  203. }
  204. .custom-nav-menu {
  205. order: 3;
  206. width: 100%;
  207. margin-top: 12px;
  208. justify-content: space-around;
  209. }
  210. .navbar-actions {
  211. order: 2;
  212. }
  213. .custom-nav-menu :deep(.el-menu-item) {
  214. flex: 1;
  215. justify-content: center;
  216. margin: 0 2px !important;
  217. padding: 8px 12px !important;
  218. }
  219. .nav-icon {
  220. margin-right: 4px;
  221. }
  222. }
  223. </style>