feat: make admin path configurable

pull/344/head
zhangwenbing.zwb 1 year ago
parent 98d43b885d
commit a95d9dda76

@ -30,6 +30,8 @@ func NewConfig() *Config {
viper.SetConfigName("config")
}
viper.SetDefault("sonic.admin_url_path", "admin")
conf := &Config{}
if err := viper.ReadInConfig(); err != nil {
panic(err)

@ -49,4 +49,5 @@ type Sonic struct {
TemplateDir string `mapstructure:"template_dir"`
ThemeDir string
AdminResourcesDir string
AdminUrlPath string `mapstructure:"admin_url_path"`
}

@ -86,7 +86,12 @@ func (s *StartListener) printStartInfo(ctx context.Context) error {
site := logger.BlueBold + "Sonic started at " + blogURL + logger.Reset
log.Info(site)
fmt.Println(site)
adminSite := logger.BlueBold + "Sonic admin started at " + blogURL + "/admin" + logger.Reset
adminUrlPath, err := s.optionService.GetAdminUrlPath(ctx)
if err != nil {
return err
}
adminSite := logger.BlueBold + "Sonic admin started at " + blogURL + "/" + adminUrlPath + logger.Reset
log.Info(adminSite)
fmt.Println(adminSite)
return nil

@ -469,3 +469,7 @@ func (o *optionServiceImpl) GetAttachmentType(ctx context.Context) consts.Attach
return consts.AttachmentTypeLocal
}
}
func (o *optionServiceImpl) GetAdminUrlPath(ctx context.Context) (string, error) {
return o.Config.Sonic.AdminUrlPath, nil
}

@ -32,6 +32,7 @@ type OptionService interface {
GetLinkPrefix(ctx context.Context) (string, error)
GetSheetPrefix(ctx context.Context) (string, error)
GetAttachmentType(ctx context.Context) consts.AttachmentType
GetAdminUrlPath(ctx context.Context) (string, error)
}
type ClientOptionService interface {

Loading…
Cancel
Save