feat: auto generate drivers language json

This commit is contained in:
Noah Hsu
2022-08-26 15:08:31 +08:00
parent d9ee174dd3
commit 7425e001db
7 changed files with 117 additions and 27 deletions

View File

@ -8,7 +8,7 @@ type Item struct {
Name string `json:"name"`
Type string `json:"type"`
Default string `json:"default"`
Values string `json:"values"`
Options string `json:"options"`
Required bool `json:"required"`
Help string `json:"help"`
}

View File

@ -17,13 +17,13 @@ const (
)
type SettingItem struct {
Key string `json:"key" gorm:"primaryKey" binding:"required"` // unique key
Value string `json:"value"` // value
Help string `json:"help"` // help message
Type string `json:"type"` // string, number, bool, select
Values string `json:"values"` // values for select
Group int `json:"group"` // use to group setting in frontend
Flag int `json:"flag"` // 0 = public, 1 = private, 2 = readonly, 3 = deprecated, etc.
Key string `json:"key" gorm:"primaryKey" binding:"required"` // unique key
Value string `json:"value"` // value
Help string `json:"help"` // help message
Type string `json:"type"` // string, number, bool, select
Options string `json:"options"` // values for select
Group int `json:"group"` // use to group setting in frontend
Flag int `json:"flag"` // 0 = public, 1 = private, 2 = readonly, 3 = deprecated, etc.
}
func (s SettingItem) IsDeprecated() bool {

View File

@ -85,7 +85,7 @@ func getMainItems(config driver.Config) []driver.Item {
}, {
Name: "webdav_policy",
Type: conf.TypeSelect,
Values: "302_redirect, use_proxy_url, native_proxy",
Options: "302_redirect, use_proxy_url, native_proxy",
Default: "302_redirect",
Required: true,
},
@ -95,25 +95,25 @@ func getMainItems(config driver.Config) []driver.Item {
Name: "webdav_policy",
Type: conf.TypeSelect,
Default: "native_proxy",
Values: "use_proxy_url, native_proxy",
Options: "use_proxy_url, native_proxy",
Required: true,
})
}
if config.LocalSort {
items = append(items, []driver.Item{{
Name: "order_by",
Type: conf.TypeSelect,
Values: "name,size,modified",
Name: "order_by",
Type: conf.TypeSelect,
Options: "name,size,modified",
}, {
Name: "order_direction",
Type: conf.TypeSelect,
Values: "asc,desc",
Name: "order_direction",
Type: conf.TypeSelect,
Options: "asc,desc",
}}...)
}
items = append(items, driver.Item{
Name: "extract_folder",
Type: conf.TypeSelect,
Values: "front,back",
Name: "extract_folder",
Type: conf.TypeSelect,
Options: "front,back",
})
return items
}
@ -135,7 +135,7 @@ func getAdditionalItems(t reflect.Type, defaultRoot string) []driver.Item {
Name: tag.Get("json"),
Type: strings.ToLower(field.Type.Name()),
Default: tag.Get("default"),
Values: tag.Get("values"),
Options: tag.Get("options"),
Required: tag.Get("required") == "true",
Help: tag.Get("help"),
}