zhou zhou
2 天以前 aaf8a50511d77dbc209ca93bbba308c21179a8bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<template>
  <ElCard class="art-table-card ai-param-runtime-summary-card !mb-5" shadow="never">
    <div class="mb-3 flex items-start justify-between gap-4">
      <div>
        <h3 class="text-base font-semibold text-[var(--art-gray-900)]">运行时摘要</h3>
        <p class="mt-0.5 text-xs text-[var(--art-gray-500)]">当前生效的模型、Prompt 与 MCP 挂载概况</p>
      </div>
      <ElButton text :loading="loading" @click="loadSummary">刷新摘要</ElButton>
    </div>
 
    <ElAlert
      v-if="errorMessage"
      type="warning"
      :closable="false"
      class="!mb-5"
      :title="errorMessage"
    />
 
    <div class="grid gap-2.5 lg:grid-cols-3" v-loading="loading">
      <div class="rounded-2xl border border-[var(--art-border-color)] bg-[var(--art-main-bg-color)] px-3 py-3">
        <div class="flex items-center gap-2.5">
          <div class="flex size-8 items-center justify-center rounded-xl bg-sky-50 text-sky-600">
            <ArtSvgIcon icon="ri:robot-2-line" class="text-base" />
          </div>
          <div class="min-w-0 flex-1">
            <p class="text-[11px] text-[var(--art-gray-500)]">当前模型</p>
            <h4 class="truncate text-sm font-semibold text-[var(--art-gray-900)]">
              {{ summary.activeModel || '--' }}
            </h4>
          </div>
        </div>
        <div class="mt-2 flex items-center justify-between gap-3">
          <p class="truncate text-xs text-[var(--art-gray-700)]">{{ summary.activeParamName || '--' }}</p>
          <ElTag size="small" :type="validateMeta.type" effect="light">
            {{ validateMeta.text }}
          </ElTag>
        </div>
        <p class="mt-1 text-[11px] text-[var(--art-gray-500)]">{{ summary.activeParamValidatedAt || '未校验' }}</p>
      </div>
 
      <div class="rounded-2xl border border-[var(--art-border-color)] bg-[var(--art-main-bg-color)] px-3 py-3">
        <div class="flex items-center gap-2.5">
          <div class="flex size-8 items-center justify-center rounded-xl bg-violet-50 text-violet-600">
            <ArtSvgIcon icon="ri:lightbulb-flash-line" class="text-base" />
          </div>
          <div class="min-w-0 flex-1">
            <p class="text-[11px] text-[var(--art-gray-500)]">当前 Prompt</p>
            <h4 class="truncate text-sm font-semibold text-[var(--art-gray-900)]">
              {{ summary.promptName || '--' }}
            </h4>
          </div>
        </div>
        <p class="mt-2 truncate text-xs text-[var(--art-gray-700)]">
          {{ [summary.promptCode, summary.promptScene].filter(Boolean).join(' / ') || '--' }}
        </p>
        <p class="mt-1 text-[11px] text-[var(--art-gray-500)]">
          最近更新时间 {{ summary.activePromptUpdatedAt || '--' }}
        </p>
      </div>
 
      <div class="rounded-2xl border border-[var(--art-border-color)] bg-[var(--art-main-bg-color)] px-3 py-3">
        <div class="flex items-center gap-2.5">
          <div class="flex size-8 items-center justify-center rounded-xl bg-emerald-50 text-emerald-600">
            <ArtSvgIcon icon="ri:plug-2-line" class="text-base" />
          </div>
          <div class="min-w-0 flex-1">
            <p class="text-[11px] text-[var(--art-gray-500)]">已启用 MCP</p>
            <h4 class="text-sm font-semibold text-[var(--art-gray-900)]">
              {{ summary.enabledMcpCount ?? 0 }} 个
            </h4>
          </div>
        </div>
        <div class="mt-2 flex flex-wrap gap-1.5">
          <ElTag
            v-for="name in enabledMcpNames"
            :key="name"
            size="small"
            effect="plain"
          >
            {{ name }}
          </ElTag>
          <span v-if="!enabledMcpNames.length" class="text-xs text-[var(--art-gray-500)]">暂无挂载</span>
        </div>
      </div>
    </div>
  </ElCard>
</template>
 
<script setup>
  import { guardRequestWithMessage } from '@/utils/sys/requestGuard'
  import { fetchGetAiConfigSummary } from '@/api/ai-config'
  import { getAiParamValidateStatusMeta } from '../aiParamPage.helpers'
 
  const props = defineProps({
    promptCode: { type: String, default: '' }
  })
 
  const loading = ref(false)
  const summary = ref({})
  const errorMessage = ref('')
 
  const validateMeta = computed(() =>
    getAiParamValidateStatusMeta(summary.value?.activeParamValidateStatus)
  )
 
  const enabledMcpNames = computed(() =>
    Array.isArray(summary.value?.enabledMcpNames) ? summary.value.enabledMcpNames : []
  )
 
  async function loadSummary() {
    loading.value = true
    errorMessage.value = ''
    const data = await guardRequestWithMessage(
      fetchGetAiConfigSummary(props.promptCode),
      null,
      {
        timeoutMessage: '运行时摘要加载超时,已停止等待'
      }
    )
    loading.value = false
    if (!data) {
      errorMessage.value = '运行时摘要暂时不可用'
      summary.value = {}
      return
    }
    summary.value = data
  }
 
  onMounted(() => {
    loadSummary()
  })
</script>
 
<style scoped>
  .ai-param-runtime-summary-card {
    flex: none;
  }
 
  .ai-param-runtime-summary-card :deep(.el-card__body) {
    height: auto;
  }
</style>