LogsBaseInfo.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div class="logs-base-info" :class="container_klass">
  3. <div class="base-info-content">
  4. <div>
  5. <div class="st-field-label">状态</div>
  6. <div class="st-field-value filed-text-status" :class="status_text_klass">{{info.status}}</div>
  7. </div>
  8. <div>
  9. <div class="st-field-label">运行时间</div>
  10. <div class="st-field-value">{{ time_display }}</div>
  11. </div>
  12. <div>
  13. <div class="st-field-label">总TOKEN数</div>
  14. <div class="st-field-value">{{ info.total_tokens }} Tokens</div>
  15. </div>
  16. </div>
  17. <div v-if="show_error" class="error-container">{{ info.error }}</div>
  18. </div>
  19. </template>
  20. <script setup>
  21. import { ref, inject, computed, nextTick } from "vue";
  22. /**
  23. * 文档报告相关的记录详情
  24. * 日志详情
  25. */
  26. const props = defineProps({
  27. info: Object
  28. });
  29. // "total_tokens": 100, // 花费token数
  30. // "created_at": 1735817402, // 开始时间
  31. // "finished_at": 1735817402, // 结束时间
  32. // "status": "succeeded", // 工作流状态
  33. // "error": "", // 错误日志
  34. const show_error = computed(() => {
  35. const info = props.info || {};
  36. if (info.error) {
  37. return true;
  38. }
  39. return false;
  40. });
  41. /**
  42. * 转换为秒
  43. */
  44. const time_display = computed(() => {
  45. const info = props.info || {};
  46. const dis = info.finished_at - info.created_at;
  47. const str = Number(dis/1000).toFixed(3);
  48. return `${str}s`;
  49. });
  50. const container_klass = computed(() => {
  51. const info = props.info || {};
  52. // return 'status-running'
  53. // return 'status-succeeded'
  54. // return 'status-partial_succeeded'
  55. // return 'status-exception'
  56. // return 'status-failed'
  57. // return 'status-stopped'
  58. return `status-${info.status}`;
  59. });
  60. const status_text_klass = computed(() => {
  61. const info = props.info || {};
  62. // return 'text-running'
  63. // return 'text-succeeded'
  64. // return 'text-partial_succeeded'
  65. // return 'text-exception'
  66. // return 'text-failed'
  67. // return 'text-stopped'
  68. return `text-${info.status}`;
  69. });
  70. </script>
  71. <style lang="scss" scoped>
  72. .logs-base-info{
  73. border-radius: 10px;
  74. padding: 10px;
  75. // color: #fff;
  76. color: #676f83;
  77. font-size: 14px;
  78. border-width: 2px;
  79. border-style: solid;
  80. }
  81. .base-info-content{
  82. display: flex;
  83. justify-content: space-between;
  84. align-items: center;
  85. }
  86. .status-running {
  87. background-color: #155aef;
  88. }
  89. .status-succeeded {
  90. // background-color: #079455;
  91. background-color: #ecfdf3;
  92. border-color: rgba(23, 178, 106, .8);
  93. }
  94. .status-partial_succeeded {
  95. background-color: #079455;
  96. }
  97. .status-exception {
  98. background-color: #f79009;
  99. }
  100. .status-failed {
  101. // background-color: #dc6803;
  102. background-color: #fef3f2;
  103. border-color: #dc6803;
  104. }
  105. .status-stopped {
  106. background-color: #f79009;
  107. }
  108. // ----------------------------------------------
  109. // ----------------------------------------------
  110. // ----------------------------------------------
  111. // ----------------------------------------------
  112. // ----------------------------------------------
  113. // ----------------------------------------------
  114. .st-field-label{
  115. font-size: 12px;
  116. }
  117. .st-field-value{
  118. font-weight: 500;
  119. }
  120. // ----------------------------------------------
  121. // ----------------------------------------------
  122. // ----------------------------------------------
  123. // ----------------------------------------------
  124. // ----------------------------------------------
  125. // ----------------------------------------------
  126. .filed-text-status {
  127. font-weight: bold;
  128. }
  129. .text-running {
  130. color: #155aef;
  131. }
  132. .text-succeeded {
  133. color: #079455;
  134. }
  135. .text-partial_succeeded {
  136. color: #079455;
  137. }
  138. .text-exception {
  139. color: #f79009;
  140. }
  141. .text-failed {
  142. // color: #dc6803;
  143. color: #dc6803;
  144. }
  145. .text-stopped {
  146. color: #f79009;
  147. }
  148. // ----------------------------------------------
  149. // ----------------------------------------------
  150. // ----------------------------------------------
  151. // ----------------------------------------------
  152. // ----------------------------------------------
  153. // ----------------------------------------------
  154. .error-container{
  155. font-size: 12px;
  156. color: #d92d20;
  157. }
  158. </style>