From 393bfa137e116a6d1ff5e8fbb60c2463077f06f2 Mon Sep 17 00:00:00 2001 From: RockYang Date: Tue, 4 Mar 2025 21:21:28 +0800 Subject: [PATCH] fixed keling model selection --- api/handler/video_handler.go | 11 ++++-- web/src/views/KeLing.vue | 63 ++++++++++++++++++++++++---------- web/src/views/mobile/Login.vue | 4 ++- 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/api/handler/video_handler.go b/api/handler/video_handler.go index 2928fb98..73a8d389 100644 --- a/api/handler/video_handler.go +++ b/api/handler/video_handler.go @@ -123,7 +123,7 @@ func (h *VideoHandler) KeLingCreate(c *gin.Context) { var data struct { Channel string `json:"channel"` TaskType string `json:"task_type"` // 任务类型: text2video/image2video - Model string `json:"model"` // 模型: default/anime + Model string `json:"model"` // 模型: kling-v1-5,kling-v1-6 Prompt string `json:"prompt"` // 视频描述 NegPrompt string `json:"negative_prompt"` // 负面提示词 CfgScale float64 `json:"cfg_scale"` // 相关性系数(0-1) @@ -145,7 +145,14 @@ func (h *VideoHandler) KeLingCreate(c *gin.Context) { return } - if user.Power < h.App.SysConfig.LumaPower { + // 计算当前任务所需算力 + key := fmt.Sprintf("%s_%s_%s", data.Model, data.Mode, data.Duration) + power := h.App.SysConfig.KeLingPowers[key] + if power == 0 { + resp.ERROR(c, "当前模型暂不支持") + return + } + if user.Power < power { resp.ERROR(c, "您的算力不足,请充值后再试!") return } diff --git a/web/src/views/KeLing.vue b/web/src/views/KeLing.vue index d5602ce6..77cfd4e0 100644 --- a/web/src/views/KeLing.vue +++ b/web/src/views/KeLing.vue @@ -43,9 +43,8 @@
- - - + +
@@ -53,7 +52,7 @@
- + @@ -63,7 +62,7 @@
- + @@ -83,10 +82,10 @@
-
+
运镜控制: - + @@ -94,7 +93,7 @@
- +
- +
{ params.aspect_ratio = item.value; }; + // 状态变量 let pollTimer = null; const generating = ref(false); @@ -600,7 +613,6 @@ const availablePower = ref(100); const taskFilter = ref("all"); const runningTasks = ref([]); const finishedTasks = ref([]); -const total = ref(0); const pageSize = ref(4); const currentPage = ref(1); const previewVisible = ref(false); @@ -608,9 +620,17 @@ const currentVideo = ref(""); const isOver = ref(false); const pullTask = ref(true); const waterfallKey = ref(Date.now()); +const showCameraControl = ref(false); +const keLingPowers = ref({}); + +// 动态更新模型消耗的算力 +const updateModelPower = () => { + showCameraControl.value = params.model === "kling-v1-5" && params.mode === "pro"; + powerCost.value = keLingPowers.value[`${params.model}_${params.mode}_${params.duration}`]; +}; + // 方法定义 - const tabChange = (tab) => { params.task_type = tab; }; @@ -789,10 +809,10 @@ const fetchTasks = async () => { } }; -// 检测任务状态 -const checkAllCompleted = () => { - return runningTasks.value.length === 0; -}; +// // 检测任务状态 +// const checkAllCompleted = () => { +// return runningTasks.value.length === 0; +// }; const previewVideo = (task) => { currentVideo.value = task.video_url; @@ -830,8 +850,9 @@ const clipboard = ref(null); // 生命周期钩子 onMounted(async () => { checkSession() - .then(async () => { + .then(async (u) => { isLogin.value = true; + availablePower.value = u.power; console.log("mounted-isLogin-可以继续", isLogin.value); await fetchTasks(); @@ -854,6 +875,10 @@ onMounted(async () => { clipboard.value.on("error", () => { ElMessage.error("复制失败!"); }); + // 获取系统配置 + getSystemInfo().then((res) => { + keLingPowers.value = res.data.keling_powers; + }); }); onUnmounted(() => { clearInterval(pollTimer); diff --git a/web/src/views/mobile/Login.vue b/web/src/views/mobile/Login.vue index 35721d9d..753c5411 100644 --- a/web/src/views/mobile/Login.vue +++ b/web/src/views/mobile/Login.vue @@ -1,6 +1,6 @@