feat: 同步质量校验修复并精简工作台操作
This commit is contained in:
1 parent
771b66cafc
commit
13bb6dc83b
47 files changed
+2244
-260
No files matched your search
@@ -0,0 +1,76 @@
|
||||
<script setup lang="ts">
|
||||
import { onScopeDispose, ref, watch } from 'vue'
|
||||
import { NAlert, NButton } from 'naive-ui'
|
||||
import { qualityApi } from '../quality-api'
|
||||
import type { ImageProviderCapability, ShotProviderCapability } from '../quality.types'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
|
||||
/** 模型由后端配置;此入口只读公开能力,不提供无效的前端模型切换。 */
|
||||
const props = defineProps<{ shotId?: string }>()
|
||||
const providers = ref<ImageProviderCapability[] | null>(null)
|
||||
const capability = ref<ShotProviderCapability | null>(null)
|
||||
const error = ref('')
|
||||
const loading = ref(false)
|
||||
let revision = 0
|
||||
onScopeDispose(() => {
|
||||
revision++
|
||||
})
|
||||
watch(
|
||||
() => props.shotId,
|
||||
() => {
|
||||
revision++
|
||||
providers.value = null
|
||||
capability.value = null
|
||||
error.value = ''
|
||||
loading.value = false
|
||||
}
|
||||
)
|
||||
/** 按需检查,不自动生成图片;空上限表示未声明,不冒充无限制。 */
|
||||
async function inspect() {
|
||||
if (loading.value) return
|
||||
const version = ++revision
|
||||
const shotId = props.shotId
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const list = await qualityApi.providers()
|
||||
if (version !== revision) return
|
||||
const result = shotId ? await qualityApi.capability(shotId) : null
|
||||
if (version !== revision) return
|
||||
if (!Array.isArray(list) || list.some(item => !item.capabilities?.references))
|
||||
throw new Error('模型能力接口返回不完整。')
|
||||
providers.value = list
|
||||
capability.value = result
|
||||
} catch (cause) {
|
||||
if (version === revision) error.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (version === revision) loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<section class="mt-4 text-xs">
|
||||
<NButton size="small" :loading="loading" :disabled="loading" @click="inspect">查看后端模型能力</NButton>
|
||||
<NAlert v-if="error" type="error" :show-icon="false" class="mt-3">{{ error }}</NAlert>
|
||||
<template v-if="providers">
|
||||
<p v-if="!providers.some(item => item.active)" class="mt-2 text-danger">
|
||||
没有匹配的启用图片模型,请检查后端配置。
|
||||
</p>
|
||||
<p v-for="item in providers" :key="item.provider" class="mt-2">
|
||||
{{ item.provider }} · {{ item.active ? '当前启用' : '已注册' }} ·
|
||||
{{
|
||||
!item.capabilities.references.supported
|
||||
? '不支持参考图'
|
||||
: item.capabilities.references.maxReferenceImages === null
|
||||
? '参考图上限未声明'
|
||||
: `最多 ${item.capabilities.references.maxReferenceImages} 张参考图`
|
||||
}}
|
||||
</p>
|
||||
</template>
|
||||
<NAlert v-if="capability" :type="capability.valid ? 'info' : 'error'" :show-icon="false" class="mt-3">{{
|
||||
capability.valid
|
||||
? `当前镜头需要 ${capability.referenceCount} 张参考图,符合 ${capability.provider} 的已声明能力。`
|
||||
: capability.message || '当前镜头不满足模型能力限制。'
|
||||
}}</NAlert>
|
||||
</section>
|
||||
</template>
|
||||
Reference in new issue
Block a user