🐛 sql group

pull/548/head
微凉 2021-10-30 17:34:34 +08:00
parent 0324ea1fcb
commit 2780efaea8
7 changed files with 23 additions and 11 deletions

View File

@ -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 {

View File

@ -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"}
)

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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
}