alist/conf/var.go

97 lines
1.9 KiB
Go
Raw Normal View History

2021-10-25 10:53:59 +00:00
package conf
2021-10-27 10:59:03 +00:00
import (
"context"
"github.com/eko/gocache/v2/cache"
2021-10-27 14:45:36 +00:00
"github.com/robfig/cron/v3"
2021-10-27 10:59:03 +00:00
"gorm.io/gorm"
2022-01-04 13:21:27 +00:00
"strconv"
2021-10-27 10:59:03 +00:00
)
2021-10-25 10:53:59 +00:00
2021-11-04 05:23:17 +00:00
var (
BuiltAt string
GoVersion string
GitAuthor string
GitCommit string
GitTag string = "dev"
2021-11-04 05:23:17 +00:00
)
2021-10-25 10:53:59 +00:00
var (
ConfigFile string // config file
2021-10-26 14:28:37 +00:00
Conf *Config
Debug bool
2021-11-03 11:51:19 +00:00
Version bool
2021-11-16 07:00:56 +00:00
Password bool
2021-10-25 10:53:59 +00:00
2021-11-03 11:51:19 +00:00
DB *gorm.DB
2021-10-27 10:59:03 +00:00
Cache *cache.Cache
2021-11-03 11:51:19 +00:00
Ctx = context.TODO()
Cron *cron.Cron
2021-10-26 14:28:37 +00:00
)
var (
2021-12-20 09:24:49 +00:00
TextTypes = []string{"txt", "htm", "html", "xml", "java", "properties", "sql",
"js", "md", "json", "conf", "ini", "vue", "php", "py", "bat", "gitignore", "yml",
"go", "sh", "c", "cpp", "h", "hpp", "tsx", "vtt", "srt", "ass"}
2021-10-26 14:28:37 +00:00
OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"}
2022-01-06 11:26:19 +00:00
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb", "webm", "flv"}
2021-12-21 07:44:07 +00:00
AudioTypes = []string{"mp3", "flac", "ogg", "m4a", "wav"}
2022-01-20 06:40:59 +00:00
ImageTypes = []string{"jpg", "tiff", "jpeg", "png", "gif", "bmp", "svg", "ico", "swf"}
2021-10-26 14:28:37 +00:00
)
2021-11-12 14:56:30 +00:00
2022-01-04 13:21:27 +00:00
var settingsMap = make(map[string]string, 0)
func Set(key string, value string) {
settingsMap[key] = value
}
func GetStr(key string) string {
value, ok := settingsMap[key]
if !ok {
return ""
}
return value
}
func GetBool(key string) bool {
value, ok := settingsMap[key]
if !ok {
return false
}
return value == "true"
}
func GetInt(key string, defaultV int) int {
value, ok := settingsMap[key]
if !ok {
return defaultV
}
v, err := strconv.Atoi(value)
if err != nil {
return defaultV
}
return v
}
var (
LoadSettings = []string{
"check parent folder", "check down link", "WebDAV username", "WebDAV password",
"Visitor WebDAV username", "Visitor WebDAV password",
"default page size", "load type",
}
)
2021-11-12 14:56:30 +00:00
var (
2021-11-16 07:00:56 +00:00
RawIndexHtml string
ManageHtml string
2021-11-16 07:00:56 +00:00
IndexHtml string
2022-01-04 13:21:27 +00:00
Token string
//CheckParent bool
//CheckDown bool
//DavUsername string
//DavPassword string
//VisitorDavUsername string
//VisitorDavPassword string
)