Merge pull request #118 from sihuan/transonly

支持仅秒传模式
This commit is contained in:
微凉
2021-07-06 17:30:20 +08:00
committed by GitHub
3 changed files with 9 additions and 5 deletions

View File

@ -13,6 +13,7 @@ server:
address: "0.0.0.0" address: "0.0.0.0"
port: "5244" port: "5244"
search: true search: true
download: true //是否允许获取直链
static: dist static: dist
site_url: '*' site_url: '*'
password: password #用于重建目录 password: password #用于重建目录

View File

@ -32,8 +32,9 @@ type Config struct {
} `yaml:"info"` } `yaml:"info"`
Server struct { Server struct {
Address string `yaml:"address"` Address string `yaml:"address"`
Port string `yaml:"port"` //端口 Port string `yaml:"port"` //端口
Search bool `yaml:"search"` //允许搜索 Search bool `yaml:"search"` //允许搜索
Download bool `yaml:"download"` //允许下载
Static string `yaml:"static"` Static string `yaml:"static"`
SiteUrl string `yaml:"site_url"` //网站url SiteUrl string `yaml:"site_url"` //网站url
Password string `yaml:"password"` Password string `yaml:"password"`

View File

@ -16,11 +16,11 @@ func InitRouter(engine *gin.Engine) {
engine.NoRoute(func(c *gin.Context) { engine.NoRoute(func(c *gin.Context) {
c.File(conf.Conf.Server.Static + "/index.html") c.File(conf.Conf.Server.Static + "/index.html")
}) })
InitApiRouter(engine) InitApiRouter(engine, conf.Conf.Server.Download)
} }
// init api router // init api router
func InitApiRouter(engine *gin.Engine) { func InitApiRouter(engine *gin.Engine, download bool) {
apiV2 := engine.Group("/api") apiV2 := engine.Group("/api")
{ {
apiV2.GET("/info", controllers.Info) apiV2.GET("/info", controllers.Info)
@ -32,5 +32,7 @@ func InitApiRouter(engine *gin.Engine) {
apiV2.POST("/global_search", controllers.GlobalSearch) apiV2.POST("/global_search", controllers.GlobalSearch)
apiV2.POST("/rebuild", controllers.RebuildTree) apiV2.POST("/rebuild", controllers.RebuildTree)
} }
engine.GET("/d/*path", controllers.Down) if download {
engine.GET("/d/*path", controllers.Down)
}
} }