diff --git a/conf/config.dev.yaml b/conf/config.dev.yaml index eb0a692..6a11aeb 100644 --- a/conf/config.dev.yaml +++ b/conf/config.dev.yaml @@ -28,4 +28,5 @@ mysql: sonic: mode: "development" 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) \ No newline at end of file + log_dir: "./logs" # 不填则使用work_dir 路径下的log路径 (If it is empty, use the "log" path under work_dir) + admin_url_path: admin_random \ No newline at end of file diff --git a/config/model.go b/config/model.go index a25657c..44ec967 100644 --- a/config/model.go +++ b/config/model.go @@ -49,5 +49,5 @@ type Sonic struct { TemplateDir string `mapstructure:"template_dir"` ThemeDir string AdminResourcesDir string - AdminUrlPath string `mapstructure:"admin_url_path"` + AdminURLPath string `mapstructure:"admin_url_path"` } diff --git a/event/listener/start.go b/event/listener/start.go index 209de4e..a2e0049 100644 --- a/event/listener/start.go +++ b/event/listener/start.go @@ -87,11 +87,11 @@ func (s *StartListener) printStartInfo(ctx context.Context) error { log.Info(site) fmt.Println(site) - adminUrlPath, err := s.optionService.GetAdminUrlPath(ctx) + adminURLPath, err := s.optionService.GetAdminURLPath(ctx) if err != nil { 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) fmt.Println(adminSite) return nil diff --git a/handler/content/view.go b/handler/content/view.go index ed4c0c4..a617593 100644 --- a/handler/content/view.go +++ b/handler/content/view.go @@ -60,7 +60,8 @@ func (v *ViewHandler) Install(ctx *gin.Context) { if isInstall { 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) { diff --git a/handler/router.go b/handler/router.go index 2d39c5b..6484ed9 100644 --- a/handler/router.go +++ b/handler/router.go @@ -36,7 +36,7 @@ func (s *Server) RegisterRouters() { }) { 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("/js", gin.Dir(filepath.Join(s.Config.Sonic.AdminResourcesDir, "js"), false)) staticRouter.StaticFS("/images", gin.Dir(filepath.Join(s.Config.Sonic.AdminResourcesDir, "images"), false)) diff --git a/service/impl/option.go b/service/impl/option.go index b2b96c1..3186049 100644 --- a/service/impl/option.go +++ b/service/impl/option.go @@ -470,6 +470,6 @@ func (o *optionServiceImpl) GetAttachmentType(ctx context.Context) consts.Attach } } -func (o *optionServiceImpl) GetAdminUrlPath(ctx context.Context) (string, error) { - return o.Config.Sonic.AdminUrlPath, nil +func (o *optionServiceImpl) GetAdminURLPath(ctx context.Context) (string, error) { + return o.Config.Sonic.AdminURLPath, nil } diff --git a/service/option.go b/service/option.go index 4a46fb5..60afc02 100644 --- a/service/option.go +++ b/service/option.go @@ -32,7 +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) + GetAdminURLPath(ctx context.Context) (string, error) } type ClientOptionService interface {