diff --git a/conf/enumerate.go b/conf/enumerate.go index caf76e89..9be28e28 100644 --- a/conf/enumerate.go +++ b/conf/enumerate.go @@ -212,6 +212,25 @@ func URLFor(endpoint string, values ...interface{}) string { baseUrl := beego.AppConfig.DefaultString("baseurl", "") pathUrl := beego.URLFor(endpoint, values ...) + if baseUrl == "" { + baseUrl = BaseUrl + } + if strings.HasPrefix(pathUrl, "http://") { + return pathUrl + } + if strings.HasPrefix(pathUrl, "/") && strings.HasSuffix(baseUrl, "/") { + return baseUrl + pathUrl[1:] + } + if !strings.HasPrefix(pathUrl, "/") && !strings.HasSuffix(baseUrl, "/") { + return baseUrl + "/" + pathUrl + } + return baseUrl + beego.URLFor(endpoint, values ...) +} + +func URLForNotHost(endpoint string,values ...interface{}) string { + baseUrl := beego.AppConfig.DefaultString("baseurl", "") + pathUrl := beego.URLFor(endpoint, values ...) + if baseUrl == "" { baseUrl = "/" } diff --git a/controllers/BlogController.go b/controllers/BlogController.go index 85f0fa70..315eaa49 100644 --- a/controllers/BlogController.go +++ b/controllers/BlogController.go @@ -533,14 +533,14 @@ func (c *BlogController) Upload() { if err := attachment.Insert(); err != nil { os.Remove(filePath) - beego.Error("保存文件附件失败 => ", err) + beego.Error("保存文件附件失败 -> ", err) c.JsonResult(6006, "文件保存失败") } if attachment.HttpPath == "" { - attachment.HttpPath = conf.URLFor("BlogController.Download", ":id", blogId, ":attach_id", attachment.AttachmentId) + attachment.HttpPath = conf.URLForNotHost("BlogController.Download", ":id", blogId, ":attach_id", attachment.AttachmentId) if err := attachment.Update(); err != nil { - beego.Error("SaveToFile => ", err) + beego.Error("保存文件失败 -> ",attachment.FilePath, err) c.JsonResult(6005, "保存文件失败") } } diff --git a/controllers/DocumentController.go b/controllers/DocumentController.go index cf461f1c..89ad79c6 100644 --- a/controllers/DocumentController.go +++ b/controllers/DocumentController.go @@ -470,7 +470,7 @@ func (c *DocumentController) Upload() { } if attachment.HttpPath == "" { - attachment.HttpPath = conf.URLFor("DocumentController.DownloadAttachment", ":key", identify, ":attach_id", attachment.AttachmentId) + attachment.HttpPath = conf.URLForNotHost("DocumentController.DownloadAttachment", ":key", identify, ":attach_id", attachment.AttachmentId) if err := attachment.Update(); err != nil { beego.Error("保存文件失败 ->", err) diff --git a/controllers/ManagerController.go b/controllers/ManagerController.go index 7469c89a..4c26ada8 100644 --- a/controllers/ManagerController.go +++ b/controllers/ManagerController.go @@ -413,7 +413,7 @@ func (c *ManagerController) DeleteBook() { c.JsonResult(6002, "项目不存在") } if err != nil { - logs.Error("DeleteBook => ", err) + logs.Error("删除失败 -> ", err) c.JsonResult(6003, "删除失败") } c.JsonResult(0, "ok") diff --git a/views/book/setting.tpl b/views/book/setting.tpl index 5d877305..c5a7e027 100644 --- a/views/book/setting.tpl +++ b/views/book/setting.tpl @@ -58,6 +58,7 @@
项目标识用来标记项目的唯一性,不可修改。
开启后,每次保存会自动发布到最新版本
开启导出前请先配置导出程序,并在配置文件中同时开启导出功能
+分享只对公开项目生效,私有项目不支持分享
开启后每隔30秒会自动保存
点击图片可修改项目封面