全局美化 v2
This commit is contained in:
@@ -53,13 +53,15 @@ func TestGenPreview(t *testing.T) {
|
||||
// 提问箱主页:带背景图(渐变占位)+ 浅色文字,验证遮罩方向
|
||||
boxData := publicBaseData()
|
||||
boxData["VConsole"] = false
|
||||
boxData["Background"] = "data:image/svg+xml;utf8," +
|
||||
bgURI := "data:image/svg+xml;utf8," +
|
||||
strings.NewReplacer("#", "%23").Replace(
|
||||
`<svg xmlns='http://www.w3.org/2000/svg' width='900' height='500'><defs><linearGradient id='g' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='#3b6ea5'/><stop offset='1' stop-color='#d98b6a'/></linearGradient></defs><rect width='900' height='500' fill='url(#g)'/></svg>`)
|
||||
// 注意:模板读的是 .PageUser.Background,必须写进 PageUser 里,否则 {{ if .PageUser.Background }} 为假、遮罩类不会渲染
|
||||
boxData["PageUser"].(map[string]interface{})["Background"] = bgURI
|
||||
boxData["PageUser"].(map[string]interface{})["Usernamecolor"] = "#ffffff"
|
||||
boxData["PageUser"].(map[string]interface{})["Introcolor"] = "#ffffff"
|
||||
// 无头 Chrome 里 uk-img 的懒加载不一定触发,这里直接把背景图写进 CSS 便于核对遮罩
|
||||
coverCSS := `<style>.tb-profile-cover{background-image:url("` + boxData["Background"].(string) +
|
||||
coverCSS := `<style>.tb-profile-cover{background-image:url("` + bgURI +
|
||||
`");background-size:cover;background-position:center;}</style>`
|
||||
for _, theme := range []string{"light", "dark"} {
|
||||
box, err := renderToString(t, "question/list", boxData)
|
||||
|
||||
Reference in New Issue
Block a user