🎨 change NeedSetLink to NoNeedSetLink

pull/548/head
微凉 2021-12-29 19:47:47 +08:00
parent 88a9edb90a
commit 6a54ed87f3
12 changed files with 33 additions and 34 deletions

View File

@ -22,8 +22,7 @@ type Pan123 struct{}
func (driver Pan123) Config() base.DriverConfig {
return base.DriverConfig{
Name: "123Pan",
NeedSetLink: true,
Name: "123Pan",
}
}

View File

@ -26,8 +26,7 @@ type Cloud189 struct{}
func (driver Cloud189) Config() base.DriverConfig {
return base.DriverConfig{
Name: "189Cloud",
NeedSetLink: true,
Name: "189Cloud",
}
}

View File

@ -21,8 +21,7 @@ type AliDrive struct{}
func (driver AliDrive) Config() base.DriverConfig {
return base.DriverConfig{
Name: "AliDrive",
NeedSetLink: true,
Name: "AliDrive",
}
}

View File

@ -17,9 +17,9 @@ type Alist struct{}
func (driver Alist) Config() base.DriverConfig {
return base.DriverConfig{
Name: "Alist",
OnlyProxy: false,
NoCors: true,
Name: "Alist",
NoNeedSetLink: true,
NoCors: true,
}
}

View File

@ -10,12 +10,12 @@ import (
)
type DriverConfig struct {
Name string
OnlyProxy bool
NoLink bool // 必须本机返回的
ApiProxy bool // 使用API中转的
NeedSetLink bool // 需要设置链接的
NoCors bool // 不可以跨域
Name string
OnlyProxy bool
NoLink bool // 必须本机返回的
ApiProxy bool // 使用API中转的
NoNeedSetLink bool // 需要设置链接的
NoCors bool // 不可以跨域
}
type Args struct {

View File

@ -16,9 +16,10 @@ type FTP struct{}
func (driver FTP) Config() base.DriverConfig {
return base.DriverConfig{
Name: "FTP",
OnlyProxy: true,
NoLink: true,
Name: "FTP",
OnlyProxy: true,
NoLink: true,
NoNeedSetLink: true,
}
}

View File

@ -16,9 +16,10 @@ type GoogleDrive struct{}
func (driver GoogleDrive) Config() base.DriverConfig {
return base.DriverConfig{
Name: "GoogleDrive",
OnlyProxy: true,
ApiProxy: true,
Name: "GoogleDrive",
OnlyProxy: true,
ApiProxy: true,
NoNeedSetLink: true,
}
}

View File

@ -14,9 +14,8 @@ type Lanzou struct{}
func (driver Lanzou) Config() base.DriverConfig {
return base.DriverConfig{
Name: "Lanzou",
NeedSetLink: true,
NoCors: true,
Name: "Lanzou",
NoCors: true,
}
}

View File

@ -19,9 +19,10 @@ type Native struct{}
func (driver Native) Config() base.DriverConfig {
return base.DriverConfig{
Name: "Native",
OnlyProxy: true,
NoLink: true,
Name: "Native",
OnlyProxy: true,
NoLink: true,
NoNeedSetLink: true,
}
}

View File

@ -16,7 +16,8 @@ type Onedrive struct{}
func (driver Onedrive) Config() base.DriverConfig {
return base.DriverConfig{
Name: "Onedrive",
Name: "Onedrive",
NoNeedSetLink: true,
}
}

View File

@ -15,9 +15,8 @@ type PikPak struct{}
func (driver PikPak) Config() base.DriverConfig {
return base.DriverConfig{
Name: "PikPak",
NeedSetLink: true,
ApiProxy: true,
Name: "PikPak",
ApiProxy: true,
}
}

View File

@ -60,9 +60,9 @@ func Path(c *gin.Context) {
if account.DownProxyUrl != "" {
file.Url = fmt.Sprintf("%s%s?sign=%s", account.DownProxyUrl, req.Path, utils.SignWithToken(file.Name, conf.Token))
} else {
file.Url = fmt.Sprintf("//%s/d%s", c.Request.Host, req.Path)
file.Url = fmt.Sprintf("//%s/p%s?sign=%s", c.Request.Host, req.Path, utils.SignWithToken(file.Name, conf.Token))
}
} else if driver.Config().NeedSetLink {
} else if !driver.Config().NoNeedSetLink {
link, err := driver.Link(base.Args{Path: path, IP: c.ClientIP()}, account)
if err != nil {
common.ErrorResp(c, err, 500)
@ -103,7 +103,7 @@ func Link(c *gin.Context) {
}
if driver.Config().NoLink {
common.SuccessResp(c, base.Link{
Url: fmt.Sprintf("//%s/d%s?d=1&sign=%s", c.Request.Host, req.Path, utils.SignWithToken(utils.Base(rawPath), conf.Token)),
Url: fmt.Sprintf("//%s/p%s?d=1&sign=%s", c.Request.Host, req.Path, utils.SignWithToken(utils.Base(rawPath), conf.Token)),
})
return
}