fix: use theme background as default

This commit is contained in:
hexxa 2022-04-11 21:07:40 +08:00 committed by Hexxa
parent 71ea41cb07
commit 7e5f3995b4
5 changed files with 22 additions and 28 deletions

View file

@ -52,7 +52,7 @@
}
.theme-dark #bg {
/* background: url("/static/img/textured_paper.png") repeat fixed center; */
background: url("/static/img/px_by_Gre3g.webp") repeat fixed center;
background-color: rgb(22 22 24);
color: #ccc;
position: fixed;

View file

@ -45,20 +45,22 @@ export class RootFrame extends React.Component<Props, State, {}> {
}
makeBgStyle = (): Object => {
if (
this.props.login.preferences != null &&
this.props.login.preferences.bg.url !== ""
) {
const bgConfig = this.props.login.preferences.bg;
return {
background: `url("${bgConfig.url}") ${bgConfig.repeat} ${bgConfig.position} ${bgConfig.align}`,
};
}
if (this.props.ui.clientCfg.allowSetBg) {
if (
this.props.login.preferences != null &&
this.props.login.preferences.bg.url !== ""
) {
const bgConfig = this.props.login.preferences.bg;
return {
background: `url("${bgConfig.url}") ${bgConfig.repeat} ${bgConfig.position} ${bgConfig.align}`,
};
}
if (this.props.login.preferences.bg.bgColor !== "") {
return {
backgroundColor: this.props.login.preferences.bg.bgColor,
};
if (this.props.login.preferences.bg.bgColor !== "") {
return {
backgroundColor: this.props.login.preferences.bg.bgColor,
};
}
}
if (this.props.ui.clientCfg.bg.url !== "") {

View file

@ -38,10 +38,11 @@ var (
DefaultSiteName = "Quickshare"
DefaultSiteDesc = "Quickshare"
DefaultBgConfig = &BgConfig{
Url: "",
Repeat: "repeat",
Position: "top",
Align: "fixed",
BgColor: "#ccc",
BgColor: "",
}
DefaultAllowSetBg = false
DefaultAutoTheme = true
@ -266,12 +267,6 @@ func CheckPreferences(prefers *Preferences, fillDefault bool) error {
}
func CheckBgConfig(cfg *BgConfig, fillDefault bool) error {
if cfg.Url == "" && cfg.BgColor == "" {
if !fillDefault {
return errors.New("one of Bg.Url or Bg.BgColor must be defined")
}
cfg.BgColor = DefaultBgConfig.BgColor
}
if !BgRepeatValues[cfg.Repeat] {
return fmt.Errorf("invalid repeat value (%s)", cfg.Repeat)
}
@ -291,9 +286,6 @@ func CheckBgConfig(cfg *BgConfig, fillDefault bool) error {
if cfg.Align == "" {
cfg.Align = DefaultBgConfig.Align
}
if cfg.BgColor == "" {
cfg.BgColor = DefaultBgConfig.BgColor
}
return nil
}

View file

@ -123,11 +123,11 @@ func DefaultConfigStruct() *Config {
SiteName: "Quickshare",
SiteDesc: "Quick and simple file sharing",
Bg: &db.BgConfig{
Url: "/static/img/textured_paper.png",
Url: "",
Repeat: "repeat",
Position: "center",
Align: "fixed",
BgColor: "#ccc",
BgColor: "",
},
AllowSetBg: false,
AutoTheme: true,

View file

@ -167,11 +167,11 @@ func initDeps(cfg gocfg.ICfg) *depidx.Deps {
SiteName: cfg.StringOr("Site.ClientCfg.SiteName", "Quickshare"),
SiteDesc: cfg.StringOr("Site.ClientCfg.SiteDesc", "Quick and simple file sharing"),
Bg: &db.BgConfig{
Url: cfg.StringOr("Site.ClientCfg.Bg.Url", "/static/img/textured_paper.png"),
Url: cfg.StringOr("Site.ClientCfg.Bg.Url", ""),
Repeat: cfg.StringOr("Site.ClientCfg.Bg.Repeat", "repeat"),
Position: cfg.StringOr("Site.ClientCfg.Bg.Position", "center"),
Align: cfg.StringOr("Site.ClientCfg.Bg.Align", "fixed"),
BgColor: cfg.StringOr("Site.ClientCfg.Bg.BgColor", "#ccc"),
BgColor: cfg.StringOr("Site.ClientCfg.Bg.BgColor", ""),
},
},
})