From 6b669fc540457ef766dead3391dfdfd9fbdc796c Mon Sep 17 00:00:00 2001 From: yusing Date: Sat, 4 Jan 2025 03:37:51 +0800 Subject: [PATCH] api: homepage config json not longer include default url --- internal/config/query.go | 21 ++------------------- internal/homepage/homepage.go | 3 ++- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/internal/config/query.go b/internal/config/query.go index 0730849..4634b7a 100644 --- a/internal/config/query.go +++ b/internal/config/query.go @@ -1,10 +1,8 @@ package config import ( - "fmt" "strings" - "github.com/yusing/go-proxy/internal/common" "github.com/yusing/go-proxy/internal/homepage" route "github.com/yusing/go-proxy/internal/route" "github.com/yusing/go-proxy/internal/route/entry" @@ -33,17 +31,6 @@ func DumpProviders() map[string]*proxy.Provider { } func HomepageConfig() homepage.Config { - var proto, port string - domains := instance.value.MatchDomains - cert, _ := instance.autocertProvider.GetCert(nil) - if cert != nil { - proto = "https" - port = common.ProxyHTTPSPort - } else { - proto = "http" - port = common.ProxyHTTPPort - } - hpCfg := homepage.NewHomePageConfig() routes.GetHTTPRoutes().RangeAll(func(alias string, r types.HTTPRoute) { en := r.RawEntry() @@ -61,6 +48,8 @@ func HomepageConfig() homepage.Config { return } + item.Alias = alias + if item.Name == "" { item.Name = strutils.Title( strings.ReplaceAll( @@ -102,13 +91,7 @@ func HomepageConfig() homepage.Config { item.SourceType = string(proxy.ProviderTypeFile) } - if item.URL == "" { - if len(domains) > 0 { - item.URL = fmt.Sprintf("%s://%s%s:%s", proto, strings.ToLower(alias), domains[0], port) - } - } item.AltURL = r.TargetURL().String() - hpCfg.Add(item) }) return hpCfg diff --git a/internal/homepage/homepage.go b/internal/homepage/homepage.go index 45c4c32..a96df4c 100644 --- a/internal/homepage/homepage.go +++ b/internal/homepage/homepage.go @@ -7,13 +7,14 @@ type ( Item struct { Show bool `json:"show"` - Name string `json:"name"` + Name string `json:"name"` // display name Icon string `json:"icon"` URL string `json:"url"` // alias + domain Category string `json:"category"` Description string `json:"description" aliases:"desc"` WidgetConfig map[string]any `json:"widget_config" aliases:"widget"` + Alias string `json:"alias"` // proxy alias SourceType string `json:"source_type"` AltURL string `json:"alt_url"` // original proxy target }