From bde2d35756d2243d8c17b733586d329be975ff83 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Mon, 15 Jun 2026 16:37:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E4=BF=AE=E5=A4=8D=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E5=8D=A1=E7=89=87=20=20=E5=9B=A0=E7=BC=A9?= =?UTF-8?q?=E8=BF=9B=E5=AF=BC=E8=87=B4=E6=9B=BF=E6=8D=A2=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --- CHANGELOG.md | 6 ++++++ backend/internal/handler/public.go | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 834daf8..32c5ab6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.45] - 2026-06-15 + +### 修复 +- 修复微信分享卡片标题仍显示"岩美"的问题(HTML 缩进导致字符串匹配失败) +- 微信分享卡片描述去掉"扫码验真"后缀 + ## [1.0.44] - 2026-06-15 ### 改进 diff --git a/backend/internal/handler/public.go b/backend/internal/handler/public.go index 3f61d3a..df544d4 100644 --- a/backend/internal/handler/public.go +++ b/backend/internal/handler/public.go @@ -6,6 +6,7 @@ import ( "html" "net/http" "os" + "regexp" "strconv" "strings" @@ -315,7 +316,9 @@ func (h *PublicHandler) ProductPage(c *gin.Context) { ogTags := buildProductOG(product, shopName, config.C.Storage.PublicURL) ogTitle := buildOGTitle(product) // 同时替换 <title> 标签,微信/飞书等平台有时优先读 <title> 而非 og:title - out := strings.Replace(idxHTML, "<title>岩美", ""+html.EscapeString(ogTitle)+"", 1) + // 用正则替换避免缩进空格导致字符串不匹配 + titleRe := regexp.MustCompile(`[^<]*`) + out := titleRe.ReplaceAllString(idxHTML, ""+html.EscapeString(ogTitle)+"") out = strings.Replace(out, "", ogTags+"", 1) // 禁止缓存,确保爬虫每次都能拿到最新 OG 标签 c.Header("Cache-Control", "no-store")