渠道: 远程候选按渠道过滤 + key 掩码 + 移除批量导入端点
- 远程模型候选只排除本渠道已允许的模型,同名模型可被多个渠道各自允许 - 渠道 key 掩码统一 xxxxxxx******Mq4Y(保留前 7 位与后 4 位) - 移除已弃用的批量导入端点 POST /channels/:id/models/import Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ const mappings = ref<ChannelModelMapping[]>([])
|
||||
const remote = ref<string[]>([])
|
||||
const selected = ref<string[]>([])
|
||||
const loading = ref(false)
|
||||
const fetched = ref(false)
|
||||
const addForm = reactive({ custom_name: '', upstream_model: '' })
|
||||
|
||||
async function load() {
|
||||
@@ -29,8 +30,8 @@ async function fetchRemote() {
|
||||
try {
|
||||
const { data } = await http.get(`/admin/channels/${props.channel.id}/models/remote`)
|
||||
remote.value = data.data.items
|
||||
const bound = new Set(mappings.value.map((m) => m.upstream_model))
|
||||
selected.value = remote.value.filter((r) => bound.has(r))
|
||||
selected.value = []
|
||||
fetched.value = true
|
||||
} catch (e) {
|
||||
toast.err(errMsg(e))
|
||||
} finally {
|
||||
@@ -39,10 +40,8 @@ async function fetchRemote() {
|
||||
}
|
||||
|
||||
async function addSelected() {
|
||||
const bound = new Set(mappings.value.map((m) => m.upstream_model))
|
||||
let added = 0
|
||||
for (const name of selected.value) {
|
||||
if (bound.has(name)) continue
|
||||
try {
|
||||
await http.post(`/admin/channels/${props.channel.id}/models`, { upstream_model: name })
|
||||
added++
|
||||
@@ -50,8 +49,11 @@ async function addSelected() {
|
||||
/* 单个失败不中断 */
|
||||
}
|
||||
}
|
||||
selected.value = []
|
||||
toast.ok(added ? `已添加 ${added} 个模型` : '所选均已添加')
|
||||
await load()
|
||||
// 已添加的模型已被渠道允许,从拉取候选中移除
|
||||
await fetchRemote()
|
||||
}
|
||||
|
||||
async function addManual() {
|
||||
@@ -98,9 +100,9 @@ onMounted(load)
|
||||
|
||||
<template>
|
||||
<div class="space-y-3">
|
||||
<!-- 当前支持的模型 -->
|
||||
<!-- 已允许的模型 -->
|
||||
<div>
|
||||
<p class="mb-1.5 text-xs font-medium text-muted">当前支持的模型({{ mappings.length }})</p>
|
||||
<p class="mb-1.5 text-xs font-medium text-muted">已允许的模型({{ mappings.length }})</p>
|
||||
<div v-if="mappings.length" class="flex flex-wrap gap-2">
|
||||
<div
|
||||
v-for="b in mappings"
|
||||
@@ -119,7 +121,7 @@ onMounted(load)
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="text-xs text-muted">尚未添加模型</p>
|
||||
<p v-else class="text-xs text-muted">尚未允许任何模型</p>
|
||||
</div>
|
||||
|
||||
<!-- 从接口拉取 + 勾选 -->
|
||||
@@ -135,8 +137,8 @@ onMounted(load)
|
||||
<label
|
||||
v-for="m in remote"
|
||||
:key="m"
|
||||
class="flex cursor-pointer items-center gap-1.5 rounded-md border border-edge2 px-2 py-1 font-mono text-[11px] text-muted transition select-none"
|
||||
:class="selected.includes(m) ? 'border-accent bg-accent-soft text-ink' : 'hover:border-edge'"
|
||||
class="flex cursor-pointer items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-[11px] text-muted transition select-none"
|
||||
:class="selected.includes(m) ? 'border-accent bg-accent-soft text-ink' : 'border-edge2 hover:border-edge'"
|
||||
>
|
||||
<input v-model="selected" type="checkbox" :value="m" class="size-3.5 accent-[var(--color-accent)]" />
|
||||
{{ m }}
|
||||
@@ -148,7 +150,9 @@ onMounted(load)
|
||||
添加所选({{ selected.length }})
|
||||
</Button>
|
||||
</div>
|
||||
<p v-else-if="!loading" class="text-xs text-muted">点「拉取」获取渠道接口返回的模型,勾选需要的加入</p>
|
||||
<p v-else-if="!loading" class="text-xs text-muted">
|
||||
{{ remote.length === 0 && fetched ? '接口返回的模型均已允许,无新增候选' : '点「拉取」获取渠道接口返回的新模型,勾选需要的加入' }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- 手动添加 -->
|
||||
|
||||
Reference in New Issue
Block a user