mirror of https://github.com/Xhofe/alist
✨ static files
parent
2780efaea8
commit
eb358e6ede
|
@ -24,3 +24,5 @@ dist/
|
|||
bin/*
|
||||
alist
|
||||
*.json
|
||||
public/index.html
|
||||
public/assets/
|
9
alist.go
9
alist.go
|
@ -27,11 +27,14 @@ func Init() {
|
|||
func main() {
|
||||
Init()
|
||||
app := fiber.New()
|
||||
server.InitApiRouter(app)
|
||||
app.Use("/",filesystem.New(filesystem.Config{
|
||||
Root: http.FS(public.Public),
|
||||
//NotFoundFile: "index.html",
|
||||
NotFoundFile: "index.html",
|
||||
}))
|
||||
server.InitApiRouter(app)
|
||||
log.Info("starting server")
|
||||
_ = app.Listen(fmt.Sprintf(":%d", conf.Conf.Port))
|
||||
err := app.Listen(fmt.Sprintf(":%d", conf.Conf.Port))
|
||||
if err != nil {
|
||||
log.Errorf("failed to start: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,18 +135,24 @@ func initSettings() {
|
|||
},
|
||||
{
|
||||
Key: "logo",
|
||||
Value: "",
|
||||
Value: "https://store.heytapimage.com/cdo-portal/feedback/202110/30/d43c41c5d257c9bc36366e310374fb19.png",
|
||||
Type: "string",
|
||||
Description: "logo",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "icon_color",
|
||||
Key: "icon color",
|
||||
Value: "blue.400",
|
||||
Type: "string",
|
||||
Description: "icon's color",
|
||||
Group: model.PUBLIC,
|
||||
},
|
||||
{
|
||||
Key: "text types",
|
||||
Value: "txt,htm,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,yml,go,sh,c,cpp,h,hpp",
|
||||
Type: "string",
|
||||
Description: "text type extensions",
|
||||
},
|
||||
},
|
||||
}
|
||||
for k, v := range settingsMap {
|
||||
|
@ -158,4 +164,8 @@ func initSettings() {
|
|||
}
|
||||
}
|
||||
}
|
||||
textTypes, err := model.GetSettingByKey("text types")
|
||||
if err==nil{
|
||||
conf.ImageTypes = strings.Split(textTypes.Value,",")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,5 +23,5 @@ var (
|
|||
OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"}
|
||||
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb"}
|
||||
AudioTypes = []string{"mp3", "flac","ogg"}
|
||||
ImageTypes = []string{"jpg","jpeg","png","gif","bmp","svg"}
|
||||
ImageTypes = []string{"jpg","tiff","jpeg","png","gif","bmp","svg"}
|
||||
)
|
||||
|
|
|
@ -17,7 +17,6 @@ func InitApiRouter(app *fiber.App) {
|
|||
api.Use(SetSuccess)
|
||||
public := api.Group("/public")
|
||||
{
|
||||
// TODO check accounts
|
||||
public.Post("/path", CheckAccount, Path)
|
||||
public.Get("/settings", GetSettingsPublic)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func SaveSettings(ctx *fiber.Ctx) error {
|
||||
|
@ -17,6 +19,10 @@ func SaveSettings(ctx *fiber.Ctx) error {
|
|||
if err := model.SaveSettings(req); err != nil {
|
||||
return ErrorResp(ctx, err, 500)
|
||||
} else {
|
||||
textTypes, err := model.GetSettingByKey("text types")
|
||||
if err==nil{
|
||||
conf.ImageTypes = strings.Split(textTypes.Value,",")
|
||||
}
|
||||
return SuccessResp(ctx)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ func GetFileType(ext string) int {
|
|||
if ext == "" {
|
||||
return conf.UNKNOWN
|
||||
}
|
||||
ext = strings.TrimLeft(ext,".")
|
||||
ext = strings.ToLower(strings.TrimLeft(ext,"."))
|
||||
if IsContain(conf.OfficeTypes, ext) {
|
||||
return conf.OFFICE
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue