From 80ad0067ece998e478e116eafcf57b22158261fb Mon Sep 17 00:00:00 2001 From: creamlike1024 Date: Fri, 5 Dec 2025 12:15:06 +0800 Subject: [PATCH] feat: add remixGenerate const --- constant/task.go | 1 + relay/channel/task/sora/adaptor.go | 5 +++-- relay/relay_task.go | 6 +++--- .../components/table/task-logs/TaskLogsColumnDefs.jsx | 10 +++++++++- web/src/constants/common.constant.js | 1 + 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/constant/task.go b/constant/task.go index e174fd60e..ecccf4dfe 100644 --- a/constant/task.go +++ b/constant/task.go @@ -15,6 +15,7 @@ const ( TaskActionTextGenerate = "textGenerate" TaskActionFirstTailGenerate = "firstTailGenerate" TaskActionReferenceGenerate = "referenceGenerate" + TaskActionRemix = "remixGenerate" ) var SunoModel2Action = map[string]string{ diff --git a/relay/channel/task/sora/adaptor.go b/relay/channel/task/sora/adaptor.go index 8486abf23..429edfcfd 100644 --- a/relay/channel/task/sora/adaptor.go +++ b/relay/channel/task/sora/adaptor.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/QuantumNous/new-api/common" + "github.com/QuantumNous/new-api/constant" "github.com/QuantumNous/new-api/dto" "github.com/QuantumNous/new-api/model" "github.com/QuantumNous/new-api/relay/channel" @@ -82,14 +83,14 @@ func validateRemixRequest(c *gin.Context) *dto.TaskError { } func (a *TaskAdaptor) ValidateRequestAndSetAction(c *gin.Context, info *relaycommon.RelayInfo) (taskErr *dto.TaskError) { - if info.Action == "remix" { + if info.Action == constant.TaskActionRemix { return validateRemixRequest(c) } return relaycommon.ValidateMultipartDirect(c, info) } func (a *TaskAdaptor) BuildRequestURL(info *relaycommon.RelayInfo) (string, error) { - if info.Action == "remix" { + if info.Action == constant.TaskActionRemix { return fmt.Sprintf("%s/v1/videos/%s/remix", a.baseURL, info.OriginTaskID), nil } return fmt.Sprintf("%s/v1/videos", a.baseURL), nil diff --git a/relay/relay_task.go b/relay/relay_task.go index 13d5e83bd..21045aa2f 100644 --- a/relay/relay_task.go +++ b/relay/relay_task.go @@ -34,11 +34,11 @@ func RelayTaskSubmit(c *gin.Context, info *relaycommon.RelayInfo) (taskErr *dto. } path := c.Request.URL.Path if strings.Contains(path, "/v1/videos/") && strings.HasSuffix(path, "/remix") { - info.Action = "remix" + info.Action = constant.TaskActionRemix } // 提取 remix 任务的 video_id - if info.Action == "remix" { + if info.Action == constant.TaskActionRemix { videoID := c.Param("video_id") if strings.TrimSpace(videoID) == "" { return service.TaskErrorWrapperLocal(fmt.Errorf("video_id is required"), "invalid_request", http.StatusBadRequest) @@ -93,7 +93,7 @@ func RelayTaskSubmit(c *gin.Context, info *relaycommon.RelayInfo) (taskErr *dto. } // 使用原始任务的参数 - if info.Action == "remix" { + if info.Action == constant.TaskActionRemix { var taskData map[string]interface{} _ = json.Unmarshal(originTask.Data, &taskData) secondsStr, _ := taskData["seconds"].(string) diff --git a/web/src/components/table/task-logs/TaskLogsColumnDefs.jsx b/web/src/components/table/task-logs/TaskLogsColumnDefs.jsx index 530518d18..c9d1705c5 100644 --- a/web/src/components/table/task-logs/TaskLogsColumnDefs.jsx +++ b/web/src/components/table/task-logs/TaskLogsColumnDefs.jsx @@ -39,6 +39,7 @@ import { TASK_ACTION_GENERATE, TASK_ACTION_REFERENCE_GENERATE, TASK_ACTION_TEXT_GENERATE, + TASK_ACTION_REMIX_GENERATE, } from '../../../constants/common.constant'; import { CHANNEL_OPTIONS } from '../../../constants/channel.constants'; @@ -125,6 +126,12 @@ const renderType = (type, t) => { {t('参照生视频')} ); + case TASK_ACTION_REMIX_GENERATE: + return ( + }> + {t('remix生视频')} + + ); default: return ( }> @@ -359,7 +366,8 @@ export const getTaskLogsColumns = ({ record.action === TASK_ACTION_GENERATE || record.action === TASK_ACTION_TEXT_GENERATE || record.action === TASK_ACTION_FIRST_TAIL_GENERATE || - record.action === TASK_ACTION_REFERENCE_GENERATE; + record.action === TASK_ACTION_REFERENCE_GENERATE || + record.action === TASK_ACTION_REMIX_GENERATE; const isSuccess = record.status === 'SUCCESS'; const isUrl = typeof text === 'string' && /^https?:\/\//.test(text); if (isSuccess && isVideoTask && isUrl) { diff --git a/web/src/constants/common.constant.js b/web/src/constants/common.constant.js index 57fbbbde5..a142a0eb5 100644 --- a/web/src/constants/common.constant.js +++ b/web/src/constants/common.constant.js @@ -42,3 +42,4 @@ export const TASK_ACTION_GENERATE = 'generate'; export const TASK_ACTION_TEXT_GENERATE = 'textGenerate'; export const TASK_ACTION_FIRST_TAIL_GENERATE = 'firstTailGenerate'; export const TASK_ACTION_REFERENCE_GENERATE = 'referenceGenerate'; +export const TASK_ACTION_REMIX_GENERATE = 'remixGenerate';