AppNavbar.vue 5.9 KB

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