Feat: creat uri aria2 download task

This commit is contained in:
HFO4
2020-02-04 15:29:52 +08:00
parent 7804b4efb1
commit fe8f1b1ef5
16 changed files with 238 additions and 16 deletions

View File

@@ -0,0 +1,17 @@
package controllers
import (
"github.com/HFO4/cloudreve/service/aria2"
"github.com/gin-gonic/gin"
)
// AddAria2URL 添加离线下载URL
func AddAria2URL(c *gin.Context) {
var addService aria2.AddURLService
if err := c.ShouldBindJSON(&addService); err == nil {
res := addService.Add(c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
}
}

View File

@@ -16,6 +16,7 @@ func ParamErrorMsg(filed string, tag string) string {
"Password": "密码",
"Path": "路径",
"SourceID": "原始资源",
"URL": "链接",
}
// 未通过的规则与中文对应
tagMap := map[string]string{

View File

@@ -11,7 +11,7 @@ import (
// SiteConfig 获取站点全局配置
func SiteConfig(c *gin.Context) {
siteConfig := model.GetSettingByNames([]string{
siteConfig := model.GetSettingByNames(
"siteName",
"login_captcha",
"qq_login",
@@ -25,7 +25,7 @@ func SiteConfig(c *gin.Context) {
"share_score_rate",
"home_view_method",
"share_view_method",
})
)
// 如果已登录,则同时返回用户信息
user, _ := c.Get("user")

View File

@@ -274,7 +274,10 @@ func InitMasterRouter() *gin.Engine {
}
// 离线下载任务
//aria2 := auth.Group("aria2")
aria2 := auth.Group("aria2")
{
aria2.POST("url", controllers.AddAria2URL)
}
// 目录
directory := auth.Group("directory")