增加默认图片

This commit is contained in:
yml2213
2026-07-23 17:19:44 +08:00
parent 5668eb745f
commit 95f3857470
2 changed files with 8 additions and 3 deletions
@@ -1,6 +1,7 @@
package listing
import (
_ "embed"
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
@@ -18,6 +19,9 @@ import (
"github.com/gin-gonic/gin"
)
//go:embed assets/default_upload_screenshot.webp
var defaultUploadScreenshotWebP []byte
func (h *Handler) ImportExternalUpload(c *gin.Context) {
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, maxExternalUploadBodyBytes)
raw, err := io.ReadAll(c.Request.Body)
@@ -123,7 +127,8 @@ func writeExternalUploadAuthError(c *gin.Context, err error) {
}
func (h *Handler) DefaultUploadScreenshot(c *gin.Context) {
c.Header("Content-Type", "image/svg+xml; charset=utf-8")
c.Header("Cache-Control", "public, max-age=86400")
c.String(http.StatusOK, `<svg xmlns="http://www.w3.org/2000/svg" width="960" height="540" viewBox="0 0 960 540"><rect width="960" height="540" fill="#f3f4f6"/><rect x="72" y="72" width="816" height="396" rx="24" fill="#ffffff" stroke="#d1d5db" stroke-width="4"/><text x="480" y="248" text-anchor="middle" font-family="Arial, sans-serif" font-size="42" font-weight="700" fill="#374151">账号资料默认图</text><text x="480" y="310" text-anchor="middle" font-family="Arial, sans-serif" font-size="28" fill="#6b7280">开放接口上传,待后台补充审核</text></svg>`)
c.Header("Content-Type", "image/webp")
c.Header("Cache-Control", "public, max-age=604800")
c.Header("Content-Length", strconv.Itoa(len(defaultUploadScreenshotWebP)))
c.Data(http.StatusOK, "image/webp", defaultUploadScreenshotWebP)
}