mirror of https://github.com/Xhofe/alist
🐛 sql group
parent
0324ea1fcb
commit
2780efaea8
|
@ -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 {
|
||||
|
|
|
@ -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"}
|
||||
)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue