From 5991fd66ce2c2906448ff54e39f202df47fd3fe3 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sat, 23 Nov 2019 16:38:43 +0800 Subject: [PATCH] Modify: reorganize project structure --- .gitmodules | 3 +++ assets | 1 + routers/controllers/directory.go | 1 + routers/controllers/general.go | 43 ------------------------------ routers/controllers/ping.go | 14 ---------- routers/controllers/site.go | 45 ++++++++++++++++++++++++++++++++ 6 files changed, 50 insertions(+), 57 deletions(-) create mode 100644 .gitmodules create mode 160000 assets create mode 100644 routers/controllers/directory.go delete mode 100644 routers/controllers/general.go delete mode 100644 routers/controllers/ping.go diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ea9b120 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "assets"] + path = assets + url = git@github.com:HFO4/frontend-pro.git diff --git a/assets b/assets new file mode 160000 index 0000000..fa3e709 --- /dev/null +++ b/assets @@ -0,0 +1 @@ +Subproject commit fa3e709238dcecf85320949cd9413b37b48177f1 diff --git a/routers/controllers/directory.go b/routers/controllers/directory.go new file mode 100644 index 0000000..2d32936 --- /dev/null +++ b/routers/controllers/directory.go @@ -0,0 +1 @@ +package controllers diff --git a/routers/controllers/general.go b/routers/controllers/general.go deleted file mode 100644 index 52c8dc9..0000000 --- a/routers/controllers/general.go +++ /dev/null @@ -1,43 +0,0 @@ -package controllers - -import ( - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" - "github.com/mojocn/base64Captcha" -) - -// Captcha 获取验证码 -func Captcha(c *gin.Context) { - // 验证码配置 - var configD = base64Captcha.ConfigCharacter{ - Height: conf.CaptchaConfig.Height, - Width: conf.CaptchaConfig.Width, - //const CaptchaModeNumber:数字,CaptchaModeAlphabet:字母,CaptchaModeArithmetic:算术,CaptchaModeNumberAlphabet:数字字母混合. - Mode: conf.CaptchaConfig.Mode, - ComplexOfNoiseText: conf.CaptchaConfig.ComplexOfNoiseText, - ComplexOfNoiseDot: conf.CaptchaConfig.ComplexOfNoiseDot, - IsShowHollowLine: conf.CaptchaConfig.IsShowHollowLine, - IsShowNoiseDot: conf.CaptchaConfig.IsShowNoiseDot, - IsShowNoiseText: conf.CaptchaConfig.IsShowNoiseText, - IsShowSlimeLine: conf.CaptchaConfig.IsShowSlimeLine, - IsShowSineLine: conf.CaptchaConfig.IsShowSineLine, - CaptchaLen: conf.CaptchaConfig.CaptchaLen, - } - - // 生成验证码 - idKeyD, capD := base64Captcha.GenerateCaptcha("", configD) - // 将验证码UID存入Session以便后续验证 - util.SetSession(c, map[string]interface{}{ - "captchaID": idKeyD, - }) - - // 将验证码图像编码为Base64 - base64stringD := base64Captcha.CaptchaWriteToBase64Encoding(capD) - - c.JSON(200, serializer.Response{ - Code: 0, - Data: base64stringD, - }) -} diff --git a/routers/controllers/ping.go b/routers/controllers/ping.go deleted file mode 100644 index f93a2bd..0000000 --- a/routers/controllers/ping.go +++ /dev/null @@ -1,14 +0,0 @@ -package controllers - -import ( - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/gin-gonic/gin" -) - -// Ping 状态检查页面 -func Ping(c *gin.Context) { - c.JSON(200, serializer.Response{ - Code: 0, - Msg: "Pong", - }) -} diff --git a/routers/controllers/site.go b/routers/controllers/site.go index 7512f95..8d1fa23 100644 --- a/routers/controllers/site.go +++ b/routers/controllers/site.go @@ -2,8 +2,11 @@ package controllers import ( model "github.com/HFO4/cloudreve/models" + "github.com/HFO4/cloudreve/pkg/conf" "github.com/HFO4/cloudreve/pkg/serializer" + "github.com/HFO4/cloudreve/pkg/util" "github.com/gin-gonic/gin" + "github.com/mojocn/base64Captcha" ) // SiteConfig 获取站点全局配置 @@ -22,3 +25,45 @@ func SiteConfig(c *gin.Context) { c.JSON(200, serializer.BuildSiteConfig(siteConfig)) } + +// Ping 状态检查页面 +func Ping(c *gin.Context) { + c.JSON(200, serializer.Response{ + Code: 0, + Msg: "Pong", + }) +} + +// Captcha 获取验证码 +func Captcha(c *gin.Context) { + // 验证码配置 + var configD = base64Captcha.ConfigCharacter{ + Height: conf.CaptchaConfig.Height, + Width: conf.CaptchaConfig.Width, + //const CaptchaModeNumber:数字,CaptchaModeAlphabet:字母,CaptchaModeArithmetic:算术,CaptchaModeNumberAlphabet:数字字母混合. + Mode: conf.CaptchaConfig.Mode, + ComplexOfNoiseText: conf.CaptchaConfig.ComplexOfNoiseText, + ComplexOfNoiseDot: conf.CaptchaConfig.ComplexOfNoiseDot, + IsShowHollowLine: conf.CaptchaConfig.IsShowHollowLine, + IsShowNoiseDot: conf.CaptchaConfig.IsShowNoiseDot, + IsShowNoiseText: conf.CaptchaConfig.IsShowNoiseText, + IsShowSlimeLine: conf.CaptchaConfig.IsShowSlimeLine, + IsShowSineLine: conf.CaptchaConfig.IsShowSineLine, + CaptchaLen: conf.CaptchaConfig.CaptchaLen, + } + + // 生成验证码 + idKeyD, capD := base64Captcha.GenerateCaptcha("", configD) + // 将验证码UID存入Session以便后续验证 + util.SetSession(c, map[string]interface{}{ + "captchaID": idKeyD, + }) + + // 将验证码图像编码为Base64 + base64stringD := base64Captcha.CaptchaWriteToBase64Encoding(capD) + + c.JSON(200, serializer.Response{ + Code: 0, + Data: base64stringD, + }) +}