From 2780efaea8d7ff47297916c55fc220da615844ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=87=89?= <927625802@qq.com> Date: Sat, 30 Oct 2021 17:34:34 +0800 Subject: [PATCH] :bug: sql group --- bootstrap/model.go | 7 +++++++ conf/var.go | 4 ++-- drivers/alidrive.go | 4 ++-- model/account.go | 12 +++++++----- model/setting.go | 2 +- server/account.go | 3 +++ utils/file.go | 2 +- 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/bootstrap/model.go b/bootstrap/model.go index 3e8614c6..7dcd0c53 100644 --- a/bootstrap/model.go +++ b/bootstrap/model.go @@ -140,6 +140,13 @@ func initSettings() { Description: "logo", Group: model.PUBLIC, }, + { + Key: "icon_color", + Value: "blue.400", + Type: "string", + Description: "icon's color", + Group: model.PUBLIC, + }, }, } for k, v := range settingsMap { diff --git a/conf/var.go b/conf/var.go index 8953ae49..8e06fe6d 100644 --- a/conf/var.go +++ b/conf/var.go @@ -19,9 +19,9 @@ var ( ) var ( - TextTypes = []string{"txt", "go"} + TextTypes = []string{"txt", "go", "md"} OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"} VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb"} - AudioTypes = []string{"mp3", "flac"} + AudioTypes = []string{"mp3", "flac","ogg"} ImageTypes = []string{"jpg","jpeg","png","gif","bmp","svg"} ) diff --git a/drivers/alidrive.go b/drivers/alidrive.go index 80fd995d..2e29d6bc 100644 --- a/drivers/alidrive.go +++ b/drivers/alidrive.go @@ -103,14 +103,14 @@ func (a AliDrive) GetFiles(fileId string, account *model.Account) ([]AliFile, er SetBody(JsonStr(Json{ "drive_id": account.DriveId, "fields": "*", - "image_thumbnail_process": "image/resize,w_50", + "image_thumbnail_process": "image/resize,w_400/format,jpeg", "image_url_process": "image/resize,w_1920/format,jpeg", "limit": account.Limit, "marker": marker, "order_by": account.OrderBy, "order_direction": account.OrderDirection, "parent_file_id": fileId, - "video_thumbnail_process": "video/snapshot,t_0,f_jpg,w_50", + "video_thumbnail_process": "video/snapshot,t_0,f_jpg,ar_auto,w_300", //"url_expire_sec": 1600, })).Post("https://api.aliyundrive.com/v2/file/list") if err != nil { diff --git a/model/account.go b/model/account.go index 276a6c34..c04b8973 100644 --- a/model/account.go +++ b/model/account.go @@ -2,6 +2,7 @@ package model import ( "github.com/Xhofe/alist/conf" + "time" ) type Account struct { @@ -15,10 +16,11 @@ type Account struct { Status string `json:"status"` CronId int DriveId string - Limit int `json:"limit"` - OrderBy string `json:"order_by"` - OrderDirection string `json:"order_direction"` - Proxy bool `json:"proxy"` + Limit int `json:"limit"` + OrderBy string `json:"order_by"` + OrderDirection string `json:"order_direction"` + Proxy bool `json:"proxy"` + UpdatedAt *time.Time `json:"updated_at"` } var accountsMap = map[string]Account{} @@ -68,7 +70,7 @@ func GetAccountFiles() []*File { Name: v.Name, Size: 0, Type: conf.FOLDER, - UpdatedAt: nil, + UpdatedAt: v.UpdatedAt, }) } return files diff --git a/model/setting.go b/model/setting.go index 2237e0a6..fc825451 100644 --- a/model/setting.go +++ b/model/setting.go @@ -24,7 +24,7 @@ func SaveSettings(items []SettingItem) error { func GetSettingsByGroup(t int) (*[]SettingItem, error) { var items []SettingItem - if err := conf.DB.Where("group = ?", t).Find(&items).Error; err != nil { + if err := conf.DB.Where("`group` = ?", t).Find(&items).Error; err != nil { return nil, err } return &items, nil diff --git a/server/account.go b/server/account.go index e00a999e..0942f088 100644 --- a/server/account.go +++ b/server/account.go @@ -5,6 +5,7 @@ import ( "github.com/Xhofe/alist/drivers" "github.com/Xhofe/alist/model" "github.com/gofiber/fiber/v2" + "time" ) func GetAccounts(ctx *fiber.Ctx) error { @@ -24,6 +25,8 @@ func SaveAccount(ctx *fiber.Ctx) error { return ErrorResp(ctx, fmt.Errorf("no [%s] driver", req.Type), 400) } old, ok := model.GetAccount(req.Name) + now := time.Now() + req.UpdatedAt = &now if err := model.SaveAccount(req); err != nil { return ErrorResp(ctx, err, 500) } else { diff --git a/utils/file.go b/utils/file.go index 9cb47a67..f7c93281 100644 --- a/utils/file.go +++ b/utils/file.go @@ -34,7 +34,7 @@ func GetFileType(ext string) int { if ext == "" { return conf.UNKNOWN } - ext = ext[1:] + ext = strings.TrimLeft(ext,".") if IsContain(conf.OfficeTypes, ext) { return conf.OFFICE }