fix: 收口渠道源迁移与测试页合并

This commit is contained in:
JianFeeeee
2026-10-19 17:21:22 +08:00
parent 25970a2135
commit 12bfd53f16
3 changed files with 209 additions and 124 deletions

View File

@ -4363,7 +4363,16 @@ local function syncProviderSource(provider)
-- 只在真正要写源时才扫一遍(低频)。
do
local ls = __llmsproxy_kernel.call("list_sources", {})
local arr = (ls and ls.json and ls.json.sources) or (ls and ls.sources) or {}
-- ★ 内核 `list_sources` 返回的是**裸数组**(kernel_actions.go 的
-- actionListSources 直接 return out),不是 {sources=[...]} 信封。
-- 此前这里取 ls.json.sources ⇒ 恒 nil ⇒ 循环一次都不跑 ⇒ 旧版按账号
-- 拆的源永远清不掉,同一个渠道的模型于是在列表里出现两遍(靠 12 位
-- hex 区分),用户看到的就是"同一个模型两个名字"。
-- 三种形态都认,但**裸数组必须优先** —— 它才是内核的现行契约。
local arr = ls
if type(arr) == "table" and arr.json then arr = arr.json end
if type(arr) == "table" and arr.sources then arr = arr.sources end
if type(arr) ~= "table" then arr = {} end
if type(arr) ~= "table" then arr = {} end
local legacyPrefix = "channels-" .. provider .. "-"
for _, exist in ipairs(arr) do
@ -12774,7 +12783,16 @@ function plugin.__sync_source_probe(args)
local found, ad = false, nil
-- 一通道一源之后,同步的目标是**通道级**源名;account_id 只用于选号。
local want = providerSourceName(args.platform)
local arr = (ls and ls.json and ls.json.sources) or (ls and ls.sources) or {}
-- ★ 内核 `list_sources` 返回的是**裸数组**(kernel_actions.go 的
-- actionListSources 直接 return out),不是 {sources=[...]} 信封。
-- 此前这里取 ls.json.sources ⇒ 恒 nil ⇒ 循环一次都不跑 ⇒ 旧版按账号
-- 拆的源永远清不掉,同一个渠道的模型于是在列表里出现两遍(靠 12 位
-- hex 区分),用户看到的就是"同一个模型两个名字"。
-- 三种形态都认,但**裸数组必须优先** —— 它才是内核的现行契约。
local arr = ls
if type(arr) == "table" and arr.json then arr = arr.json end
if type(arr) == "table" and arr.sources then arr = arr.sources end
if type(arr) ~= "table" then arr = {} end
for _, x in ipairs(arr) do
if x.name == want then found = true ad = x.adapter end
end