更新网站功能

This commit is contained in:
2026-08-28 00:50:08 +08:00
parent ae6b060c25
commit 9319427f67
12 changed files with 129 additions and 52 deletions
+9 -4
View File
@@ -136,7 +136,7 @@ func (c *TenantSiteController) rewriteStorageURLs(html string) string {
if err != nil || strings.TrimSpace(cfg.QiniuDomain) == "" {
return html
}
return rewriteLegacyQiniuURLs(html, storagePublicBaseURL(cfg.QiniuDomain))
return rewriteLegacyQiniuURLs(html, storagePublicBaseURL(cfg.QiniuDomain), cfg.QiniuDomain)
}
func storagePublicBaseURL(domain string) string {
@@ -147,13 +147,18 @@ func storagePublicBaseURL(domain string) string {
return "https://" + base
}
func rewriteLegacyQiniuURLs(html, targetBase string) string {
func rewriteLegacyQiniuURLs(html, targetBase, qiniuDomain string) string {
if targetBase == "" {
return html
}
for _, domain := range legacyQiniuDomains {
domains := append(legacyQiniuDomains, qiniuDomain)
for _, domain := range domains {
d := strings.TrimSpace(domain)
if d == "" {
continue
}
for _, scheme := range []string{"http://", "https://"} {
html = strings.ReplaceAll(html, scheme+domain+"/", targetBase+"/")
html = strings.ReplaceAll(html, scheme+d+"/", targetBase+"/")
}
}
return html