NavigationCard.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <div class="navigation">
  3. <div
  4. v-for="(group, index) in sortedGroups"
  5. :key="group.name"
  6. class="group-container"
  7. :style="{ animationDelay: `${index * 0.1}s` }"
  8. >
  9. <div class="group-header">
  10. <h2 class="group-name">{{ group.name }}</h2>
  11. <p v-if="group.description" class="group-description">{{ group.description }}</p>
  12. </div>
  13. <div class="links-grid">
  14. <a
  15. v-for="(link, linkIndex) in sortedLinks(group.links)"
  16. :key="link.name"
  17. :href="link.autoLogin ? getAutoLoginUrl(link.autoLoginEndpoint) : (link.url.startsWith('http') ? link.url : `http://${link.url}`)"
  18. target="_blank"
  19. rel="noopener noreferrer"
  20. class="link-card"
  21. :style="{ animationDelay: `${(index * 0.1) + (linkIndex * 0.05)}s` }"
  22. @click="handleLinkClick($event, link)"
  23. >
  24. <div class="card-header">
  25. <div class="link-icon-wrapper">
  26. <img
  27. v-if="link.icon"
  28. :src="link.icon"
  29. :alt="link.name"
  30. class="link-icon"
  31. @error="handleImageError"
  32. />
  33. </div>
  34. <div class="link-name">{{ link.name }}</div>
  35. </div>
  36. <p v-if="link.description" class="link-description">{{ link.description }}</p>
  37. <div class="link-footer">
  38. <span class="link-arrow">访问 →</span>
  39. </div>
  40. </a>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script setup>
  46. import { ref, computed, onMounted } from 'vue'
  47. import navigationData from '../data/navigation.json'
  48. import { getAutoLoginUrl } from '../config/backend.js'
  49. const groups = ref([])
  50. onMounted(() => {
  51. groups.value = navigationData.groups || []
  52. })
  53. const sortedGroups = computed(() => {
  54. return [...groups.value].sort((a, b) => (a.sort || 0) - (b.sort || 0))
  55. })
  56. const sortedLinks = (links) => {
  57. if (!links) return []
  58. return [...links].sort((a, b) => (a.sort || 0) - (b.sort || 0))
  59. }
  60. const handleImageError = (event) => {
  61. event.target.style.display = 'none'
  62. }
  63. const handleLinkClick = (event, link) => {
  64. if (link.autoLogin) {
  65. console.log('自动登录链接:', link.name);
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. .navigation {
  71. display: flex;
  72. flex-direction: column;
  73. gap: 40px;
  74. }
  75. .group-container {
  76. background: rgba(255, 255, 255, 0.98);
  77. border-radius: 16px;
  78. padding: 35px;
  79. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  80. animation: fadeIn 0.5s ease-out both;
  81. }
  82. @keyframes fadeIn {
  83. from {
  84. opacity: 0;
  85. transform: translateY(20px);
  86. }
  87. to {
  88. opacity: 1;
  89. transform: translateY(0);
  90. }
  91. }
  92. .group-header {
  93. margin-bottom: 25px;
  94. padding-bottom: 20px;
  95. border-bottom: 2px solid #e2e8f0;
  96. }
  97. .group-name {
  98. font-size: 32px;
  99. color: #1a202c;
  100. margin-bottom: 8px;
  101. font-weight: 600;
  102. }
  103. .group-description {
  104. font-size: 18px;
  105. color: #718096;
  106. font-weight: 400;
  107. }
  108. .links-grid {
  109. display: grid;
  110. grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  111. gap: 20px;
  112. }
  113. .link-card {
  114. display: flex;
  115. flex-direction: column;
  116. background: #ffffff;
  117. border: 2px solid #e2e8f0;
  118. border-radius: 12px;
  119. padding: 25px;
  120. text-decoration: none;
  121. color: inherit;
  122. transition: all 0.3s ease;
  123. animation: fadeIn 0.5s ease-out both;
  124. min-height: 160px;
  125. }
  126. .link-card:hover {
  127. transform: translateY(-4px);
  128. border-color: #667eea;
  129. box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
  130. }
  131. .card-header {
  132. display: flex;
  133. align-items: center;
  134. gap: 15px;
  135. margin-bottom: 15px;
  136. }
  137. .link-icon-wrapper {
  138. width: 50px;
  139. height: 50px;
  140. border-radius: 10px;
  141. background: #f7fafc;
  142. display: flex;
  143. align-items: center;
  144. justify-content: center;
  145. padding: 10px;
  146. flex-shrink: 0;
  147. }
  148. .link-icon {
  149. width: 100%;
  150. height: 100%;
  151. object-fit: contain;
  152. }
  153. .link-name {
  154. font-size: 22px;
  155. color: #2d3748;
  156. font-weight: 600;
  157. flex: 1;
  158. }
  159. .link-description {
  160. font-size: 16px;
  161. color: #718096;
  162. line-height: 1.5;
  163. margin-bottom: 15px;
  164. flex: 1;
  165. }
  166. .link-footer {
  167. margin-top: auto;
  168. padding-top: 15px;
  169. border-top: 1px solid #e2e8f0;
  170. }
  171. .link-arrow {
  172. font-size: 14px;
  173. color: #667eea;
  174. font-weight: 500;
  175. transition: transform 0.3s ease;
  176. }
  177. .link-card:hover .link-arrow {
  178. transform: translateX(5px);
  179. }
  180. @media (max-width: 768px) {
  181. .links-grid {
  182. grid-template-columns: 1fr;
  183. }
  184. .group-container {
  185. padding: 25px 20px;
  186. }
  187. .group-name {
  188. font-size: 28px;
  189. }
  190. .link-card {
  191. min-height: 140px;
  192. padding: 20px;
  193. }
  194. }
  195. </style>