From 9e71d9a60fc0959c00e49e7e543eecd165e1474b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 10 Oct 2023 17:49:47 +0800 Subject: [PATCH] fix --- .../collection/internal/logic/testailogic.go | 1 + .../internal/logic/ws_render_image.go | 25 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/server/collection/internal/logic/testailogic.go b/server/collection/internal/logic/testailogic.go index aeaa29a6..e3600734 100644 --- a/server/collection/internal/logic/testailogic.go +++ b/server/collection/internal/logic/testailogic.go @@ -48,6 +48,7 @@ func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo) (res logx.Error("测试异常:", err) } }() + //lenAiHost := len(l.svcCtx.Config.) begin := time.Now().UTC().UnixMilli() errChan := make(chan string) w := sync.WaitGroup{} diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 441bc393..ae1e1417 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -34,10 +34,11 @@ type renderProcessor struct { // 云渲染属性 type extendRenderProperty struct { renderChan chan websocket_data.RenderImageReqMsg //渲染消息入口的缓冲队列 - renderCtx context.Context //渲染控制上下文(用于切换模板标签/颜色取消之前发送的不相同的任务) + renderCtx context.Context //渲染控制上下文(用于切换模板标签/颜色/logo取消之前发送的不相同的任务) renderCtxCancelFunc context.CancelFunc //渲染控制上下文取消方法 - selectColorIndex int //选择的颜色索引 - templateTag string //模板标签 + selectColorIndex int //选择的颜色索引(用于标记连接当前连接选择的颜色) + templateTag string //模板标签 (用于标记连接当前连接选择的模板标签) + Logo string //logo地址 (用于标记连接当前连接选择的logo) } // 处理分发到这里的数据 @@ -49,10 +50,22 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { logx.Error("invalid format of websocket render image message", err) return } - if renderImageData.RenderData.TemplateTag != w.extendRenderProperty.templateTag || renderImageData.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex { + //颜色/模板标签/logo变更 + ifCancelOldCtx := false + if renderImageData.RenderData.TemplateTag != w.extendRenderProperty.templateTag { + ifCancelOldCtx = true + } + if renderImageData.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex { + ifCancelOldCtx = true + } + if renderImageData.RenderData.Logo != w.extendRenderProperty.Logo { + ifCancelOldCtx = true + } + if ifCancelOldCtx { //赋值 w.extendRenderProperty.templateTag = renderImageData.RenderData.TemplateTag w.extendRenderProperty.selectColorIndex = renderImageData.RenderData.TemplateTagColor.SelectedColorIndex + w.extendRenderProperty.Logo = renderImageData.RenderData.Logo //让之前的失效 w.extendRenderProperty.renderCtxCancelFunc() //重新赋值 @@ -94,6 +107,10 @@ func (w *wsConnectItem) consumeRenderImageData() { //logx.Info("颜色不一致,丢弃消息") continue } + //logo不一样 + if data.RenderData.Logo != w.extendRenderProperty.Logo { + continue + } limitChan <- struct{}{} go func(d websocket_data.RenderImageReqMsg) { defer func() {