merge: merge master

pull/345/head
textworld 1 year ago
commit 8abb450d18

@ -29,3 +29,4 @@ sonic:
mode: "development" mode: "development"
work_dir: "./" # 不填默认为当前路径,用来存放日志文件、数据库文件、模板、上传的附件等(The default is the current directory. Used to store log files, database files, templates, upload files) work_dir: "./" # 不填默认为当前路径,用来存放日志文件、数据库文件、模板、上传的附件等(The default is the current directory. Used to store log files, database files, templates, upload files)
log_dir: "./logs" # 不填则使用work_dir 路径下的log路径 (If it is empty, use the "log" path under work_dir) log_dir: "./logs" # 不填则使用work_dir 路径下的log路径 (If it is empty, use the "log" path under work_dir)
admin_url_path: admin_random

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

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

@ -60,7 +60,8 @@ func (v *ViewHandler) Install(ctx *gin.Context) {
if isInstall { if isInstall {
return return
} }
ctx.Redirect(http.StatusTemporaryRedirect, "admin/#install") adminURLPath, _ := v.OptionService.GetAdminURLPath(ctx)
ctx.Redirect(http.StatusTemporaryRedirect, adminURLPath+"/#install")
} }
func (v *ViewHandler) Logo(ctx *gin.Context) (interface{}, error) { func (v *ViewHandler) Logo(ctx *gin.Context) (interface{}, error) {

@ -36,7 +36,7 @@ func (s *Server) RegisterRouters() {
}) })
{ {
staticRouter := router.Group("/") staticRouter := router.Group("/")
staticRouter.StaticFS("admin", gin.Dir(s.Config.Sonic.AdminResourcesDir, false)) staticRouter.StaticFS(s.Config.Sonic.AdminURLPath, gin.Dir(s.Config.Sonic.AdminResourcesDir, false))
staticRouter.StaticFS("/css", gin.Dir(filepath.Join(s.Config.Sonic.AdminResourcesDir, "css"), false)) staticRouter.StaticFS("/css", gin.Dir(filepath.Join(s.Config.Sonic.AdminResourcesDir, "css"), false))
staticRouter.StaticFS("/js", gin.Dir(filepath.Join(s.Config.Sonic.AdminResourcesDir, "js"), false)) staticRouter.StaticFS("/js", gin.Dir(filepath.Join(s.Config.Sonic.AdminResourcesDir, "js"), false))
staticRouter.StaticFS("/images", gin.Dir(filepath.Join(s.Config.Sonic.AdminResourcesDir, "images"), false)) staticRouter.StaticFS("/images", gin.Dir(filepath.Join(s.Config.Sonic.AdminResourcesDir, "images"), false))

@ -470,6 +470,6 @@ func (o *optionServiceImpl) GetAttachmentType(ctx context.Context) consts.Attach
} }
} }
func (o *optionServiceImpl) GetAdminUrlPath(ctx context.Context) (string, error) { func (o *optionServiceImpl) GetAdminURLPath(ctx context.Context) (string, error) {
return o.Config.Sonic.AdminUrlPath, nil return o.Config.Sonic.AdminURLPath, nil
} }

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

Loading…
Cancel
Save