mirror of
https://gitlab.52pay.top/go/easygoadmin.git
synced 2025-09-27 03:48:27 +08:00
fix: 增加两种图片模式的兼容
增加两种图片模式的兼容
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -27,5 +27,5 @@ package.json
|
|||||||
package-lock.json
|
package-lock.json
|
||||||
webpack.config.js
|
webpack.config.js
|
||||||
.svn
|
.svn
|
||||||
|
/public/uploads/temp
|
||||||
go_build_main_go.exe
|
go_build_main_go.exe
|
||||||
|
@@ -9,6 +9,7 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gitlab.52pay.top/go/easygoadmin/app/service"
|
"gitlab.52pay.top/go/easygoadmin/app/service"
|
||||||
|
"gitlab.52pay.top/go/easygoadmin/library/cfg"
|
||||||
"gitlab.52pay.top/go/easygoadmin/utils"
|
"gitlab.52pay.top/go/easygoadmin/utils"
|
||||||
"gitlab.52pay.top/go/easygoadmin/utils/common"
|
"gitlab.52pay.top/go/easygoadmin/utils/common"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -20,6 +21,15 @@ var Upload = new(uploadCtl)
|
|||||||
type uploadCtl struct{}
|
type uploadCtl struct{}
|
||||||
|
|
||||||
func (u *uploadCtl) UploadImage(ctx *gin.Context) {
|
func (u *uploadCtl) UploadImage(ctx *gin.Context) {
|
||||||
|
config := cfg.Instance()
|
||||||
|
if config.EasyGoAdmin.Storage == "mongodb" {
|
||||||
|
u.UploadImage2Db(ctx)
|
||||||
|
} else {
|
||||||
|
u.UploadImage2Local(ctx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *uploadCtl) UploadImage2Local(ctx *gin.Context) {
|
||||||
// 调用上传方法
|
// 调用上传方法
|
||||||
result, err := service.Upload.UploadImage(ctx)
|
result, err := service.Upload.UploadImage(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -118,7 +118,7 @@ layui.use(['upload','croppers'],function(){
|
|||||||
,saveH:` + cropArr[1] + `
|
,saveH:` + cropArr[1] + `
|
||||||
,mark:` + cropRateStr + ` //选取比例
|
,mark:` + cropRateStr + ` //选取比例
|
||||||
,area:['750px','500px'] //弹窗宽度
|
,area:['750px','500px'] //弹窗宽度
|
||||||
,url: "/upload/uploadImage2Db/` + name + `"
|
,url: "/upload/uploadImage/` + name + `"
|
||||||
,done: function(url){
|
,done: function(url){
|
||||||
//上传完毕回调
|
//上传完毕回调
|
||||||
$('#` + name + `').val(url);
|
$('#` + name + `').val(url);
|
||||||
|
@@ -84,4 +84,5 @@ type easygoadmin struct {
|
|||||||
Debug bool
|
Debug bool
|
||||||
Image string
|
Image string
|
||||||
Uploads string
|
Uploads string
|
||||||
|
Storage string
|
||||||
}
|
}
|
||||||
|
@@ -49,15 +49,16 @@ func init() {
|
|||||||
|
|
||||||
// 设置静态资源路由
|
// 设置静态资源路由
|
||||||
router.Static("/resource", "./public/resource")
|
router.Static("/resource", "./public/resource")
|
||||||
|
router.Static("/temp", "./public/uploads/temp")
|
||||||
router.StaticFile("/favicon.ico", "./public/resource/images/favicon.ico")
|
router.StaticFile("/favicon.ico", "./public/resource/images/favicon.ico")
|
||||||
|
|
||||||
/* 文件上传 */
|
/* 文件上传 */
|
||||||
upload := router.Group("upload")
|
upload := router.Group("upload")
|
||||||
{
|
{
|
||||||
// 上传图片
|
// 上传图片
|
||||||
upload.POST("/uploadImage", controller.Upload.UploadImage)
|
upload.POST("/uploadImage/:typ", controller.Upload.UploadImage)
|
||||||
// 上传图片,存到mongoDb
|
// 上传图片,存到mongoDb
|
||||||
upload.POST("/uploadImage2Db/:typ", controller.Upload.UploadImage2Db)
|
//upload.POST("/uploadImage2Db/:typ", controller.Upload.UploadImage2Db)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mongodb图片 */
|
/* mongodb图片 */
|
||||||
|
Reference in New Issue
Block a user