From 6a35779bd52ee875b83ec7502c7fa85baf034e12 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Sat, 7 Oct 2023 15:00:41 +0800 Subject: [PATCH] 11 --- .../internal/logic/ws_render_image.go | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 2d20f1e5..4888b8a9 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -85,18 +85,26 @@ func (w *wsConnectItem) consumeRenderImageData() { case <-w.closeChan: //已关闭 return case data := <-w.extendRenderProperty.renderChan: //消费数据 - logx.Info("准备执行任务。。。。。") limitChan <- struct{}{} - logx.Info("执行任务中。。。。。") go func(d websocket_data.RenderImageReqMsg) { defer func() { if err := recover(); err != nil { logx.Error("func renderImage panic:", err) } }() + tChan := make(chan struct{}, 1) + defer close(tChan) defer func() { <-limitChan }() + go func() { + select { + case <-w.extendRenderProperty.renderCtx.Done(): + panic("=========渲染取消旧的上下文=======") + case <-tChan: + return + } + }() w.renderImage(d) }(data) } @@ -159,25 +167,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe logx.Error("failed to get element ,", err) return } - //获取模板开关信息并且对于没有默认值的给赋值默认值(但凡DIY有一个是空的就要请求默认数据) - /*if renderImageData.RenderData.Website == "" || renderImageData.RenderData.Phone == "" || renderImageData.RenderData.Address == "" || renderImageData.RenderData.Qrcode == "" || renderImageData.RenderData.Slogan == "" { - templateSwitchInfo := template_switch_info.GetTemplateSwitchInfo(productTemplate.Id, productTemplate.TemplateInfo, *productTemplate.MaterialImg) - if renderImageData.RenderData.Website == "" && templateSwitchInfo.MaterialData.Website.IfShow { - renderImageData.RenderData.Website = templateSwitchInfo.MaterialData.Website.DefaultValue - } - if renderImageData.RenderData.Phone == "" && templateSwitchInfo.MaterialData.Phone.IfShow { - renderImageData.RenderData.Phone = templateSwitchInfo.MaterialData.Phone.DefaultValue - } - if renderImageData.RenderData.Address == "" && templateSwitchInfo.MaterialData.Address.IfShow { - renderImageData.RenderData.Address = templateSwitchInfo.MaterialData.Address.DefaultValue - } - if renderImageData.RenderData.Qrcode == "" && templateSwitchInfo.MaterialData.QRcode.IfShow { - renderImageData.RenderData.Qrcode = templateSwitchInfo.MaterialData.QRcode.DefaultValue - } - if renderImageData.RenderData.Slogan == "" && templateSwitchInfo.MaterialData.Slogan.IfShow { - renderImageData.RenderData.Slogan = templateSwitchInfo.MaterialData.Slogan.DefaultValue - } - }*/ + //获取刀版图 combineReq := repositories.LogoCombineReq{ UserId: renderImageData.RenderData.UserId,