diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index e74f78eb..e4514462 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -225,13 +225,13 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe Debug: w.debug, } //qrcode不需要依赖合图组开关 - if switchInfo.SwitchInfo.QRcode.IfShow { + if switchInfo.SwitchInfo.QRcode.IfShow && switchInfo.SwitchInfo.QRcode.UserDisabled { combineReq.Qrcode = &switchInfo.SwitchInfo.QRcode.DefaultValue } //合图组开关开启 if switchInfo.CombineIsVisible { //开启slogan - if switchInfo.SwitchInfo.Slogan.IfShow { + if switchInfo.SwitchInfo.Slogan.IfShow && switchInfo.SwitchInfo.Slogan.UserDisabled { if renderImageData.RenderData.Slogan == "" { combineReq.Slogan = &switchInfo.SwitchInfo.Slogan.DefaultValue } else { @@ -239,7 +239,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe } } //开启website - if switchInfo.SwitchInfo.Website.IfShow { + if switchInfo.SwitchInfo.Website.IfShow && switchInfo.SwitchInfo.Website.UserDisabled { if renderImageData.RenderData.Website == "" { combineReq.Website = &switchInfo.SwitchInfo.Website.DefaultValue } else { @@ -247,7 +247,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe } } //开启address - if switchInfo.SwitchInfo.Address.IfShow { + if switchInfo.SwitchInfo.Address.IfShow && switchInfo.SwitchInfo.Address.UserDisabled { if renderImageData.RenderData.Address == "" { combineReq.Address = &switchInfo.SwitchInfo.Address.DefaultValue } else { @@ -255,7 +255,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe } } //开启Phone - if switchInfo.SwitchInfo.Phone.IfShow { + if switchInfo.SwitchInfo.Phone.IfShow && switchInfo.SwitchInfo.Phone.UserDisabled { if renderImageData.RenderData.Phone == "" { combineReq.Phone = &switchInfo.SwitchInfo.Phone.DefaultValue } else { diff --git a/utils/template_switch_info/template_switch.go b/utils/template_switch_info/template_switch.go index f359dc66..bec1b8cb 100644 --- a/utils/template_switch_info/template_switch.go +++ b/utils/template_switch_info/template_switch.go @@ -70,19 +70,32 @@ func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMa Id: templateId, Material: templateMaterialImg, SwitchInfo: SwitchInfo{ + QRcode: QRcode{ + UserDisabled: true, + DefaultValue: "your qrcode", + }, + Website: Website{ + UserDisabled: true, + DefaultValue: "your website", + }, + Address: Address{ + UserDisabled: true, + DefaultValue: "your address", + }, + Phone: Phone{ + UserDisabled: true, + DefaultValue: "your phone", + }, + Slogan: Slogan{ + UserDisabled: true, + DefaultValue: "your slogan", + }, Logo: Logo{ Material: "/image/logo/aHnT1_rzubdwax_scale.png", }, }, CombineIsVisible: false, } - defer func() { - returnData.SwitchInfo.QRcode.UserDisabled = true - returnData.SwitchInfo.Website.UserDisabled = true - returnData.SwitchInfo.Address.UserDisabled = true - returnData.SwitchInfo.Phone.UserDisabled = true - returnData.SwitchInfo.Slogan.UserDisabled = true - }() if templateJsonStr == nil || *templateJsonStr == "" { return returnData } @@ -98,35 +111,20 @@ func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMa } switch v.Tag { case "Phone": //电话 - returnData.SwitchInfo.Phone = Phone{ - IfShow: v.Visible, - Text: v.Text, - DefaultValue: "your phone", - } + returnData.SwitchInfo.Phone.IfShow = v.Visible + returnData.SwitchInfo.Phone.Text = v.Text case "Address": //地址 - returnData.SwitchInfo.Address = Address{ - IfShow: v.Visible, - Text: v.Text, - DefaultValue: "your address", - } + returnData.SwitchInfo.Address.IfShow = v.Visible + returnData.SwitchInfo.Address.Text = v.Text case "Website": - returnData.SwitchInfo.Website = Website{ - IfShow: v.Visible, - Text: v.Text, - DefaultValue: "your website", - } + returnData.SwitchInfo.Website.IfShow = v.Visible + returnData.SwitchInfo.Website.Text = v.Text case "QRcode": - returnData.SwitchInfo.QRcode = QRcode{ - IfShow: v.Visible, - Text: v.Text, - DefaultValue: "your qrcode content", - } + returnData.SwitchInfo.QRcode.IfShow = v.Visible + returnData.SwitchInfo.QRcode.Text = v.Text case "Slogan": - returnData.SwitchInfo.Slogan = Slogan{ - IfShow: v.Visible, - Text: v.Text, - DefaultValue: "your slogan", - } + returnData.SwitchInfo.Slogan.IfShow = v.Visible + returnData.SwitchInfo.Slogan.Text = v.Text } } return returnData