Compare commits

..

2 Commits

Author SHA1 Message Date
wangjia bde2d35756 fix(backend): 修复分享卡片 <title> 因缩进导致替换失效的问题
Deploy / build-linux-web (push) Successful in 47s
Deploy / build-windows (push) Successful in 1m45s
Deploy / build-macos (push) Successful in 1m27s
Deploy / build-android (push) Successful in 1m0s
Deploy / build-ios (push) Successful in 7s
Deploy / release-deploy (push) Successful in 1m48s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-15 16:37:20 +08:00
wangjia 4ac5adac3e chore: release v1.0.44
Deploy / build-linux-web (push) Successful in 47s
Deploy / build-windows (push) Successful in 1m44s
Deploy / build-macos (push) Successful in 1m24s
Deploy / build-android (push) Successful in 1m0s
Deploy / build-ios (push) Successful in 6s
Deploy / release-deploy (push) Successful in 1m56s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-15 16:31:47 +08:00
2 changed files with 18 additions and 3 deletions
+12
View File
@@ -5,6 +5,18 @@ 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
### 改进
- 微信分享卡片标题改为商品名称(之前仍显示"岩美")
- 微信分享卡片描述去掉"扫码验真"后缀
## [1.0.43] - 2026-06-15
### 修复
+6 -3
View File
@@ -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>岩美</title>", "<title>"+html.EscapeString(ogTitle)+"</title>", 1)
// 用正则替换避免缩进空格导致字符串不匹配
titleRe := regexp.MustCompile(`<title>[^<]*</title>`)
out := titleRe.ReplaceAllString(idxHTML, "<title>"+html.EscapeString(ogTitle)+"</title>")
out = strings.Replace(out, "</head>", ogTags+"</head>", 1)
// 禁止缓存,确保爬虫每次都能拿到最新 OG 标签
c.Header("Cache-Control", "no-store")
@@ -340,9 +343,9 @@ func buildOGTitle(product model.Product) string {
func buildProductOG(product model.Product, shopName, publicURL string) string {
title := buildOGTitle(product)
// og:description:规格(度数/香型/容量)| 门店名正品 · 扫码验真
// og:description:规格(度数/香型/容量)| 门店名正品
desc := product.Spec
suffix := "正品 · 扫码验真"
suffix := "正品"
if shopName != "" {
suffix = shopName + suffix
}