diff --git a/drivers/189pc/meta.go b/drivers/189pc/meta.go index e8eb20155af..29bc1311063 100644 --- a/drivers/189pc/meta.go +++ b/drivers/189pc/meta.go @@ -6,10 +6,10 @@ import ( ) type Addition struct { - Username string `json:"username" required:"true"` - Password string `json:"password" required:"true"` - VCode string `json:"validate_code"` - RootFolderID string `json:"root_folder_id"` + Username string `json:"username" required:"true"` + Password string `json:"password" required:"true"` + VCode string `json:"validate_code"` + driver.RootID OrderBy string `json:"order_by" type:"select" options:"filename,filesize,lastOpTime" default:"filename"` OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"` Type string `json:"type" type:"select" options:"personal,family" default:"personal"` @@ -17,10 +17,6 @@ type Addition struct { RapidUpload bool `json:"rapid_upload"` } -func (a Addition) GetRootId() string { - return a.RootFolderID -} - var config = driver.Config{ Name: "189CloudPC", DefaultRoot: "-11", diff --git a/internal/driver/item.go b/internal/driver/item.go index b0bc5636935..e8b0c8bf4cb 100644 --- a/internal/driver/item.go +++ b/internal/driver/item.go @@ -28,11 +28,11 @@ type IRootId interface { } type RootPath struct { - RootFolderPath string `json:"root_folder_path" required:"true"` + RootFolderPath string `json:"root_folder_path"` } type RootID struct { - RootFolderID string `json:"root_folder_id" required:"true"` + RootFolderID string `json:"root_folder_id"` } func (r RootPath) GetRootPath() string { diff --git a/internal/op/driver.go b/internal/op/driver.go index 518b9e38fa8..919c154f680 100644 --- a/internal/op/driver.go +++ b/internal/op/driver.go @@ -145,8 +145,11 @@ func getAdditionalItems(t reflect.Type, defaultRoot string) []driver.Item { if tag.Get("type") != "" { item.Type = tag.Get("type") } - if (item.Name == "root_folder_id" || item.Name == "root_folder_path") && item.Default == "" { - item.Default = defaultRoot + if item.Name == "root_folder_id" || item.Name == "root_folder_path" { + if item.Default == "" { + item.Default = defaultRoot + } + item.Required = item.Default != "" } // set default type to string if item.Type == "" {