From 6bb2b76e253e4cf04ff40527452b528a50a42874 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Mon, 27 Jun 2022 14:32:21 +0800 Subject: [PATCH] chore: move item types --- internal/conf/const.go | 8 ++++++++ internal/driver/addition.go | 8 -------- internal/operations/driver.go | 19 ++++++++++--------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/internal/conf/const.go b/internal/conf/const.go index 8f52a955..7230cfb9 100644 --- a/internal/conf/const.go +++ b/internal/conf/const.go @@ -1 +1,9 @@ package conf + +const ( + TypeString = "string" + TypeSelect = "select" + TypeBool = "bool" + TypeText = "text" + TypeNumber = "number" +) diff --git a/internal/driver/addition.go b/internal/driver/addition.go index 993e92b3..55dcfc40 100644 --- a/internal/driver/addition.go +++ b/internal/driver/addition.go @@ -4,14 +4,6 @@ type Additional interface{} type Select string -const ( - TypeString = "string" - TypeSelect = "select" - TypeBool = "bool" - TypeText = "text" - TypeNumber = "number" -) - type Item struct { Name string `json:"name"` Type string `json:"type"` diff --git a/internal/operations/driver.go b/internal/operations/driver.go index 23a65da9..46480f12 100644 --- a/internal/operations/driver.go +++ b/internal/operations/driver.go @@ -1,6 +1,7 @@ package operations import ( + "github.com/alist-org/alist/v3/internal/conf" "reflect" "strings" @@ -54,24 +55,24 @@ func registerDriverItems(config driver.Config, addition driver.Additional) { func getMainItems(config driver.Config) []driver.Item { items := []driver.Item{{ Name: "virtual_path", - Type: driver.TypeString, + Type: conf.TypeString, Required: true, Help: "", }, { Name: "index", - Type: driver.TypeNumber, + Type: conf.TypeNumber, Help: "use to sort", }, { Name: "down_proxy_url", - Type: driver.TypeText, + Type: conf.TypeText, }} if !config.OnlyProxy && !config.OnlyLocal { items = append(items, []driver.Item{{ Name: "web_proxy", - Type: driver.TypeBool, + Type: conf.TypeBool, }, { Name: "webdav_policy", - Type: driver.TypeSelect, + Type: conf.TypeSelect, Values: "302_redirect, use_proxy_url, native_proxy", Default: "direct", Required: true, @@ -80,7 +81,7 @@ func getMainItems(config driver.Config) []driver.Item { } else { items = append(items, driver.Item{ Name: "webdav_policy", - Type: driver.TypeSelect, + Type: conf.TypeSelect, Default: "", Values: "use_proxy_url, native_proxy", Required: true, @@ -89,17 +90,17 @@ func getMainItems(config driver.Config) []driver.Item { if config.LocalSort { items = append(items, []driver.Item{{ Name: "order_by", - Type: driver.TypeSelect, + Type: conf.TypeSelect, Values: "name,size,modified", }, { Name: "order_direction", - Type: driver.TypeSelect, + Type: conf.TypeSelect, Values: "ASC,DESC", }}...) } items = append(items, driver.Item{ Name: "extract_folder", - Type: driver.TypeSelect, + Type: conf.TypeSelect, Values: "front,back", }) return items