chore: move item types

refactor/fs
Noah Hsu 2022-06-27 14:32:21 +08:00
parent e71aff9d94
commit 6bb2b76e25
3 changed files with 18 additions and 17 deletions

View File

@ -1 +1,9 @@
package conf package conf
const (
TypeString = "string"
TypeSelect = "select"
TypeBool = "bool"
TypeText = "text"
TypeNumber = "number"
)

View File

@ -4,14 +4,6 @@ type Additional interface{}
type Select string type Select string
const (
TypeString = "string"
TypeSelect = "select"
TypeBool = "bool"
TypeText = "text"
TypeNumber = "number"
)
type Item struct { type Item struct {
Name string `json:"name"` Name string `json:"name"`
Type string `json:"type"` Type string `json:"type"`

View File

@ -1,6 +1,7 @@
package operations package operations
import ( import (
"github.com/alist-org/alist/v3/internal/conf"
"reflect" "reflect"
"strings" "strings"
@ -54,24 +55,24 @@ func registerDriverItems(config driver.Config, addition driver.Additional) {
func getMainItems(config driver.Config) []driver.Item { func getMainItems(config driver.Config) []driver.Item {
items := []driver.Item{{ items := []driver.Item{{
Name: "virtual_path", Name: "virtual_path",
Type: driver.TypeString, Type: conf.TypeString,
Required: true, Required: true,
Help: "", Help: "",
}, { }, {
Name: "index", Name: "index",
Type: driver.TypeNumber, Type: conf.TypeNumber,
Help: "use to sort", Help: "use to sort",
}, { }, {
Name: "down_proxy_url", Name: "down_proxy_url",
Type: driver.TypeText, Type: conf.TypeText,
}} }}
if !config.OnlyProxy && !config.OnlyLocal { if !config.OnlyProxy && !config.OnlyLocal {
items = append(items, []driver.Item{{ items = append(items, []driver.Item{{
Name: "web_proxy", Name: "web_proxy",
Type: driver.TypeBool, Type: conf.TypeBool,
}, { }, {
Name: "webdav_policy", Name: "webdav_policy",
Type: driver.TypeSelect, Type: conf.TypeSelect,
Values: "302_redirect, use_proxy_url, native_proxy", Values: "302_redirect, use_proxy_url, native_proxy",
Default: "direct", Default: "direct",
Required: true, Required: true,
@ -80,7 +81,7 @@ func getMainItems(config driver.Config) []driver.Item {
} else { } else {
items = append(items, driver.Item{ items = append(items, driver.Item{
Name: "webdav_policy", Name: "webdav_policy",
Type: driver.TypeSelect, Type: conf.TypeSelect,
Default: "", Default: "",
Values: "use_proxy_url, native_proxy", Values: "use_proxy_url, native_proxy",
Required: true, Required: true,
@ -89,17 +90,17 @@ func getMainItems(config driver.Config) []driver.Item {
if config.LocalSort { if config.LocalSort {
items = append(items, []driver.Item{{ items = append(items, []driver.Item{{
Name: "order_by", Name: "order_by",
Type: driver.TypeSelect, Type: conf.TypeSelect,
Values: "name,size,modified", Values: "name,size,modified",
}, { }, {
Name: "order_direction", Name: "order_direction",
Type: driver.TypeSelect, Type: conf.TypeSelect,
Values: "ASC,DESC", Values: "ASC,DESC",
}}...) }}...)
} }
items = append(items, driver.Item{ items = append(items, driver.Item{
Name: "extract_folder", Name: "extract_folder",
Type: driver.TypeSelect, Type: conf.TypeSelect,
Values: "front,back", Values: "front,back",
}) })
return items return items