feat(protocol): /v1 协议去除 fixed 时长模式,统一 options/range

- /v1/models:单值时长也输出 {"mode":"options","options":[N]},不再发 fixed
- 导入/同步校验只接受 options / range,fixed 分支删除,报错「时长模式仅支持 options / range」
- 渠道模型预览的 fixed 展示分支去掉
- 内部存储不变(durations 数组),历史模型与下单逻辑不受影响

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
2026-10-27 21:16:22 +08:00
co-authored by Devin
parent 1753e03898
commit 76510d34c9
4 changed files with 26 additions and 20 deletions
+14 -14
View File
@@ -342,8 +342,9 @@ type V1ModelItem struct {
RefAudioSeconds int64 `json:"refAudioSeconds,omitempty"`
}
// V1ModelDur exposes a video model's duration capability: fixed=locked seconds,
// options=discrete list, range=continuous interval.
// V1ModelDur exposes a video model's duration capability: options=discrete
// list (single-choice models too — "fixed" is never emitted), range=continuous
// interval.
type V1ModelDur struct {
Mode string `json:"mode"`
Seconds int64 `json:"seconds,omitempty"`
@@ -433,20 +434,19 @@ func modelDurationSpec(item *model.ModelConfig) *V1ModelDur {
return &V1ModelDur{Mode: "range", Min: int64(item.DurationMin), Max: int64(item.DurationMax)}
}
opts := repo.JSONStrings(item.Durations)
switch len(opts) {
case 0:
if len(opts) == 0 {
return nil
case 1:
return &V1ModelDur{Mode: "fixed", Seconds: int64(parseDurationSeconds(opts[0]))}
default:
vals := make([]int64, 0, len(opts))
for _, d := range opts {
if n := parseDurationSeconds(d); n > 0 {
vals = append(vals, int64(n))
}
}
return &V1ModelDur{Mode: "options", Options: vals}
}
vals := make([]int64, 0, len(opts))
for _, d := range opts {
if n := parseDurationSeconds(d); n > 0 {
vals = append(vals, int64(n))
}
}
if len(vals) == 0 {
return nil
}
return &V1ModelDur{Mode: "options", Options: vals}
}
// UserBalance — GET /v1/balance. Re-reads the user row so the number is live.