refactor: 废弃 rate_multiplier 字段,改进成本倍率回退逻辑

- 在前后端模型中为 rate_multiplier 添加 @deprecated 标记
- 修复 rate_multipliers 回退逻辑:当 rate_multipliers 存在但未配置当前格式时使用 1.0
- ModelMappingsTab: 删除映射后自动保存,简化空状态提示
- ModelManagement: 添加 refreshModel 事件在映射更新后刷新模型数据
- CacheAwareScheduler: 添加映射匹配调试日志,移除 candidate_models 限制
This commit is contained in:
fawney19
2026-01-14 21:07:28 +08:00
parent bec9c3a989
commit 0348b7d915
10 changed files with 67 additions and 22 deletions

View File

@@ -499,6 +499,7 @@ const emit = defineEmits<{
'editProvider': [provider: any]
'deleteProvider': [provider: any]
'toggleProviderStatus': [provider: any]
'refreshModel': []
}>()
const { success: showSuccess, error: showError } = useToast()
const { copyToClipboard } = useClipboard()
@@ -548,6 +549,8 @@ function handleMappingsUpdate(_mappings: string[]) {
// 映射已在 ModelMappingsTab 内部保存到服务器
// 刷新路由数据以反映可能的候选变化
refreshRoutingData()
// 通知父组件刷新模型数据
emit('refreshModel')
}
// 暴露刷新方法给父组件

View File

@@ -155,15 +155,12 @@
<!-- 空状态 -->
<div
v-else
class="text-center py-8"
class="text-center py-32"
>
<GitMerge class="w-10 h-10 mx-auto text-muted-foreground/30 mb-3" />
<p class="text-sm text-muted-foreground">
暂无映射规则
</p>
<p class="text-xs text-muted-foreground mt-1">
添加映射可匹配 Provider Key 白名单中的模型
</p>
</div>
</Card>
</template>
@@ -462,14 +459,15 @@ function addMapping() {
expandedIndex.value = localMappings.value.length - 1
}
function removeMapping(index: number) {
async function removeMapping(index: number) {
localMappings.value.splice(index, 1)
isDirty.value = true
if (expandedIndex.value === index) {
expandedIndex.value = null
} else if (expandedIndex.value !== null && expandedIndex.value > index) {
expandedIndex.value--
}
// 删除后自动保存
await saveMappings()
}
async function saveMappings() {