AgentNode.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div :class="['agent-node', type, { active: status === 'active' || status === 'processing' }]" @click="$emit('node-click', type)">
  3. <div class="node-header">
  4. <span class="node-icon">{{ icon }}</span>
  5. <span class="node-title">{{ label }}</span>
  6. <span v-if="status === 'active' || status === 'processing'" class="header-pulse"></span>
  7. </div>
  8. <div class="node-body">
  9. <p class="node-desc">{{ description }}</p>
  10. <div class="node-status">
  11. <span class="status-dot" :class="status"></span>
  12. <span class="status-text">{{ statusText }}</span>
  13. </div>
  14. <div class="node-stats">
  15. <span class="stat">
  16. <span class="stat-icon">💬</span>
  17. <span class="stat-value">{{ messageCount }}</span>
  18. </span>
  19. <span class="stat">
  20. <span class="stat-icon">🕐</span>
  21. <span class="stat-value">{{ lastUsedText }}</span>
  22. </span>
  23. </div>
  24. </div>
  25. <div class="node-handles">
  26. <div class="handle handle-left"></div>
  27. <div class="handle handle-right"></div>
  28. </div>
  29. </div>
  30. </template>
  31. <script setup lang="ts">
  32. import { computed } from 'vue'
  33. defineEmits<{
  34. (e: 'node-click', type: string): void
  35. }>()
  36. const props = withDefaults(defineProps<{
  37. type: 'orchestrator' | 'tutor' | 'debug' | 'review' | 'arch' | 'coach'
  38. label: string
  39. description?: string
  40. status?: 'active' | 'idle' | 'error' | 'processing'
  41. messageCount?: number
  42. lastUsed?: number | null
  43. }>(), {
  44. status: 'idle',
  45. messageCount: 0,
  46. lastUsed: null
  47. })
  48. const icon = computed(() => {
  49. const icons: Record<string, string> = {
  50. orchestrator: '🧠',
  51. tutor: '👨‍🏫',
  52. debug: '🐛',
  53. review: '🔍',
  54. arch: '🏗️',
  55. coach: '🎯',
  56. }
  57. return icons[props.type] || '🤖'
  58. })
  59. const description = computed(() => {
  60. const descs: Record<string, string> = {
  61. orchestrator: '路由和协调',
  62. tutor: '概念讲解答疑',
  63. debug: '错误分析修复',
  64. review: '代码质量审查',
  65. arch: '架构设计咨询',
  66. coach: '学习路径规划',
  67. }
  68. return props.description || descs[props.type] || ''
  69. })
  70. const statusText = computed(() => {
  71. const texts: Record<string, string> = {
  72. active: '运行中',
  73. processing: '处理中',
  74. idle: '空闲',
  75. error: '错误',
  76. }
  77. return texts[props.status || 'idle'] || '空闲'
  78. })
  79. const lastUsedText = computed(() => {
  80. if (!props.lastUsed) return '-'
  81. const diff = Date.now() - props.lastUsed
  82. if (diff < 60000) return '刚刚'
  83. if (diff < 3600000) return `${Math.floor(diff / 60000)}m`
  84. if (diff < 86400000) return `${Math.floor(diff / 3600000)}h`
  85. return `${Math.floor(diff / 86400000)}d`
  86. })
  87. </script>
  88. <style scoped>
  89. .agent-node {
  90. min-width: 180px;
  91. border-radius: 12px;
  92. background: white;
  93. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  94. overflow: hidden;
  95. border: 2px solid transparent;
  96. transition: all 0.3s;
  97. cursor: pointer;
  98. }
  99. .agent-node:hover {
  100. box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  101. transform: translateY(-2px);
  102. }
  103. .agent-node.active {
  104. box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  105. }
  106. .agent-node.orchestrator { border-color: #667eea; }
  107. .agent-node.orchestrator.active { box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2), 0 6px 24px rgba(102, 126, 234, 0.3); }
  108. .agent-node.tutor { border-color: #764ba2; }
  109. .agent-node.tutor.active { box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.2), 0 6px 24px rgba(118, 75, 162, 0.3); }
  110. .agent-node.debug { border-color: #f5222d; }
  111. .agent-node.debug.active { box-shadow: 0 0 0 3px rgba(245, 34, 45, 0.2), 0 6px 24px rgba(245, 34, 45, 0.3); }
  112. .agent-node.review { border-color: #52c41a; }
  113. .agent-node.review.active { box-shadow: 0 0 0 3px rgba(82, 196, 26, 0.2), 0 6px 24px rgba(82, 196, 26, 0.3); }
  114. .agent-node.arch { border-color: #fa8c16; }
  115. .agent-node.arch.active { box-shadow: 0 0 0 3px rgba(250, 140, 22, 0.2), 0 6px 24px rgba(250, 140, 22, 0.3); }
  116. .agent-node.coach { border-color: #722ed1; }
  117. .agent-node.coach.active { box-shadow: 0 0 0 3px rgba(114, 46, 209, 0.2), 0 6px 24px rgba(114, 46, 209, 0.3); }
  118. .node-header {
  119. display: flex;
  120. align-items: center;
  121. gap: 8px;
  122. padding: 12px 16px;
  123. color: white;
  124. position: relative;
  125. overflow: hidden;
  126. }
  127. .orchestrator .node-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
  128. .tutor .node-header { background: linear-gradient(135deg, #764ba2 0%, #9b59b6 100%); }
  129. .debug .node-header { background: linear-gradient(135deg, #f5222d 0%, #cf1322 100%); }
  130. .review .node-header { background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%); }
  131. .arch .node-header { background: linear-gradient(135deg, #fa8c16 0%, #d46b08 100%); }
  132. .coach .node-header { background: linear-gradient(135deg, #722ed1 0%, #531dab 100%); }
  133. .header-pulse {
  134. position: absolute;
  135. right: 12px;
  136. width: 10px;
  137. height: 10px;
  138. background: white;
  139. border-radius: 50%;
  140. animation: header-pulse 1.5s infinite;
  141. }
  142. @keyframes header-pulse {
  143. 0%, 100% { opacity: 1; transform: scale(1); }
  144. 50% { opacity: 0.6; transform: scale(1.2); }
  145. }
  146. .node-icon {
  147. font-size: 20px;
  148. }
  149. .node-title {
  150. font-size: 14px;
  151. font-weight: 600;
  152. }
  153. .node-body {
  154. padding: 12px 16px;
  155. }
  156. .node-desc {
  157. margin: 0 0 8px 0;
  158. font-size: 12px;
  159. color: #666;
  160. }
  161. .node-status {
  162. display: flex;
  163. align-items: center;
  164. gap: 6px;
  165. margin-bottom: 8px;
  166. }
  167. .status-dot {
  168. width: 8px;
  169. height: 8px;
  170. border-radius: 50%;
  171. background: #d9d9d9;
  172. }
  173. .status-dot.active {
  174. background: #52c41a;
  175. animation: dot-pulse 1.5s infinite;
  176. }
  177. .status-dot.processing {
  178. background: #1890ff;
  179. animation: dot-pulse 1s infinite;
  180. }
  181. .status-dot.idle {
  182. background: #d9d9d9;
  183. }
  184. .status-dot.error {
  185. background: #f5222d;
  186. }
  187. @keyframes dot-pulse {
  188. 0%, 100% { opacity: 1; transform: scale(1); }
  189. 50% { opacity: 0.5; transform: scale(1.3); }
  190. }
  191. .status-text {
  192. font-size: 12px;
  193. font-weight: 500;
  194. color: #666;
  195. }
  196. .node-stats {
  197. display: flex;
  198. gap: 12px;
  199. padding-top: 8px;
  200. border-top: 1px solid #f0f0f0;
  201. }
  202. .stat {
  203. display: flex;
  204. align-items: center;
  205. gap: 4px;
  206. font-size: 11px;
  207. color: #999;
  208. }
  209. .stat-icon {
  210. font-size: 12px;
  211. }
  212. .stat-value {
  213. font-weight: 500;
  214. }
  215. .node-handles {
  216. position: relative;
  217. }
  218. .handle {
  219. position: absolute;
  220. width: 12px;
  221. height: 12px;
  222. background: #667eea;
  223. border: 2px solid white;
  224. border-radius: 50%;
  225. top: 50%;
  226. transform: translateY(-50%);
  227. }
  228. .handle-left {
  229. left: -6px;
  230. }
  231. .handle-right {
  232. right: -6px;
  233. }
  234. </style>