44 lines
937 B
Go
44 lines
937 B
Go
package systemconfig
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
)
|
|
|
|
const awRecycleConfigKey = "mobile.aw_recycle"
|
|
|
|
func defaultAWRecycle() AWRecycleConfig {
|
|
return AWRecycleConfig{
|
|
Title: "AW炫彩回收",
|
|
Subtitle: "点击查看回收说明",
|
|
ImageURL: "",
|
|
Enabled: true,
|
|
}
|
|
}
|
|
|
|
func defaultAWRecycleConfigValue() string {
|
|
raw, err := json.Marshal(defaultAWRecycle())
|
|
if err != nil {
|
|
return `{"title":"AW炫彩回收","subtitle":"点击查看回收说明","image_url":"","enabled":true}`
|
|
}
|
|
return string(raw)
|
|
}
|
|
|
|
func normalizeAWRecycle(item AWRecycleConfig) AWRecycleConfig {
|
|
def := defaultAWRecycle()
|
|
title := strings.TrimSpace(item.Title)
|
|
if title == "" {
|
|
title = def.Title
|
|
}
|
|
subtitle := strings.TrimSpace(item.Subtitle)
|
|
if subtitle == "" {
|
|
subtitle = def.Subtitle
|
|
}
|
|
return AWRecycleConfig{
|
|
Title: title,
|
|
Subtitle: subtitle,
|
|
ImageURL: strings.TrimSpace(item.ImageURL),
|
|
Enabled: item.Enabled,
|
|
}
|
|
}
|