experimental homepage labels support

This commit is contained in:
yusing
2024-10-03 10:10:14 +08:00
parent 90bababd38
commit e6b4630ce9
7 changed files with 43 additions and 24 deletions

View File

@@ -35,10 +35,10 @@ func (cfg *Config) HomepageConfig() H.HomePageConfig {
cert, _ := cfg.autocertProvider.GetCert(nil)
if cert != nil {
proto = "https"
port = common.ProxyHTTPPort
port = common.ProxyHTTPSPort
} else {
proto = "http"
port = common.ProxyHTTPSPort
port = common.ProxyHTTPPort
}
hpCfg := H.NewHomePageConfig()
@@ -49,8 +49,13 @@ func (cfg *Config) HomepageConfig() H.HomePageConfig {
entry := r.Entry()
item := entry.Homepage
if item == nil {
item = &H.HomePageItem{}
if !item.Initialized {
item.Show = r.Entry().IsExplicit || !p.IsExplicitOnly()
}
if !item.Show || r.Type() != R.RouteTypeReverseProxy {
return
}
if item.Name == "" {
@@ -61,20 +66,27 @@ func (cfg *Config) HomepageConfig() H.HomePageConfig {
if item.Category == "" {
item.Category = "Docker"
}
if item.Icon == "" {
item.Icon = "🐳"
}
item.SourceType = string(PR.ProviderTypeDocker)
} else if p.GetType() == PR.ProviderTypeFile {
if item.Category == "" {
item.Category = "Others"
}
if item.Icon == "" {
item.Icon = "🔗"
}
item.SourceType = string(PR.ProviderTypeFile)
}
if item.URL == "" && r.Type() == R.RouteTypeReverseProxy {
if item.URL == "" {
if len(domains) > 0 {
item.URL = fmt.Sprintf("%s://%s.%s:%s", proto, strings.ToLower(alias), domains[0], port)
}
}
hpCfg.Add(item)
hpCfg.Add(&item)
})
return hpCfg
}