diff --git a/internal/model/account.go b/internal/model/account.go index 1f220848..27482503 100644 --- a/internal/model/account.go +++ b/internal/model/account.go @@ -22,9 +22,8 @@ type Sort struct { } type Proxy struct { - WebProxy string `json:"web_proxy"` - WebdavProxy bool `json:"webdav_proxy"` - WebdavDirect bool `json:"webdav_direct"` + WebProxy bool `json:"web_proxy"` + WebdavPolicy string `json:"webdav_policy"` DownProxyUrl string `json:"down_proxy_url"` } @@ -35,3 +34,15 @@ func (a Account) GetAccount() Account { func (a *Account) SetStatus(status string) { a.Status = status } + +func (p Proxy) Webdav302() bool { + return p.WebdavPolicy == "302_redirect" +} + +func (p Proxy) WebdavProxy() bool { + return p.WebdavPolicy == "use_proxy_url" +} + +func (p Proxy) WebdavNative() bool { + return !p.Webdav302() && !p.WebdavProxy() +} diff --git a/internal/operations/driver.go b/internal/operations/driver.go index ec0df14b..23a65da9 100644 --- a/internal/operations/driver.go +++ b/internal/operations/driver.go @@ -64,20 +64,27 @@ func getMainItems(config driver.Config) []driver.Item { }, { Name: "down_proxy_url", Type: driver.TypeText, - }, { - Name: "webdav_direct", - Type: driver.TypeBool, - Help: "Transfer the WebDAV of this account through the native without redirect", }} if !config.OnlyProxy && !config.OnlyLocal { items = append(items, []driver.Item{{ Name: "web_proxy", Type: driver.TypeBool, }, { - Name: "webdav_proxy", - Type: driver.TypeBool, + Name: "webdav_policy", + Type: driver.TypeSelect, + Values: "302_redirect, use_proxy_url, native_proxy", + Default: "direct", + Required: true, }, }...) + } else { + items = append(items, driver.Item{ + Name: "webdav_policy", + Type: driver.TypeSelect, + Default: "", + Values: "use_proxy_url, native_proxy", + Required: true, + }) } if config.LocalSort { items = append(items, []driver.Item{{