mirror of https://github.com/Xhofe/alist
✨ add no cors config
parent
91c2c21522
commit
36f07ee194
|
@ -19,6 +19,7 @@ func (driver Alist) Config() base.DriverConfig {
|
|||
return base.DriverConfig{
|
||||
Name: "Alist",
|
||||
OnlyProxy: false,
|
||||
NoCors: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/go-resty/resty/v2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DriverConfig struct {
|
||||
|
@ -14,6 +15,7 @@ type DriverConfig struct {
|
|||
NoLink bool // 必须本机返回的
|
||||
ApiProxy bool // 使用API中转的
|
||||
NeedSetLink bool // 需要设置链接的
|
||||
NoCors bool // 不可以跨域
|
||||
}
|
||||
|
||||
type Args struct {
|
||||
|
@ -75,6 +77,16 @@ func GetDriver(name string) (driver Driver, ok bool) {
|
|||
return
|
||||
}
|
||||
|
||||
func GetNoCors() string {
|
||||
res := make([]string, 0)
|
||||
for k, v := range driversMap {
|
||||
if v.Config().NoCors {
|
||||
res = append(res, k)
|
||||
}
|
||||
}
|
||||
return strings.Join(res, ",")
|
||||
}
|
||||
|
||||
func GetDrivers() map[string][]Item {
|
||||
res := make(map[string][]Item, 0)
|
||||
for k, v := range driversMap {
|
||||
|
|
|
@ -16,6 +16,7 @@ func (driver Lanzou) Config() base.DriverConfig {
|
|||
return base.DriverConfig{
|
||||
Name: "Lanzou",
|
||||
NeedSetLink: true,
|
||||
NoCors: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,6 +113,7 @@ func GetAccountFiles() ([]File, error) {
|
|||
files = append(files, File{
|
||||
Name: v.Name,
|
||||
Size: 0,
|
||||
Driver: v.Type,
|
||||
Type: conf.FOLDER,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
})
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/server/common"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -35,6 +36,12 @@ func GetSettingsPublic(c *gin.Context) {
|
|||
common.ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
*settings = append(*settings, model.SettingItem{
|
||||
Key: "no cors",
|
||||
Value: base.GetNoCors(),
|
||||
Description: "",
|
||||
Type: "string",
|
||||
})
|
||||
common.SuccessResp(c, settings)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ func InitIndex() {
|
|||
index, err = public.Public.Open("index.html")
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf(err.Error())
|
||||
//log.Fatalf(err.Error())
|
||||
return
|
||||
}
|
||||
data, _ := ioutil.ReadAll(index)
|
||||
|
|
Loading…
Reference in New Issue