Update drive model

This commit is contained in:
LinkLeong 2023-08-07 11:53:07 +01:00
parent 5681eeb7f3
commit c55c88b8c7
5 changed files with 32 additions and 27 deletions

View File

@ -2,7 +2,6 @@ package dropbox
import (
"github.com/IceWhaleTech/CasaOS/internal/driver"
"github.com/IceWhaleTech/CasaOS/internal/op"
)
const ICONURL = "./img/driver/Dropbox.svg"
@ -23,10 +22,3 @@ var config = driver.Config{
OnlyProxy: true,
DefaultRoot: "root",
}
func init() {
op.RegisterDriver(func() driver.Driver {
dropbox := GetConfig()
return &dropbox
})
}

View File

@ -2,7 +2,6 @@ package google_drive
import (
"github.com/IceWhaleTech/CasaOS/internal/driver"
"github.com/IceWhaleTech/CasaOS/internal/op"
)
const ICONURL = "./img/driver/GoogleDrive.svg"
@ -25,10 +24,3 @@ var config = driver.Config{
OnlyProxy: true,
DefaultRoot: "root",
}
func init() {
op.RegisterDriver(func() driver.Driver {
google := GetConfig()
return &google
})
}

View File

@ -2,7 +2,6 @@ package onedrive
import (
"github.com/IceWhaleTech/CasaOS/internal/driver"
"github.com/IceWhaleTech/CasaOS/internal/op"
)
type Host struct {
@ -66,10 +65,3 @@ var config = driver.Config{
LocalSort: true,
DefaultRoot: "/",
}
func init() {
op.RegisterDriver(func() driver.Driver {
one := GetConfig()
return &one
})
}

7
model/drive.go Normal file
View File

@ -0,0 +1,7 @@
package model
type Drive struct {
Name string `json:"name"`
Icon string `json:"icon"`
AuthUrl string `json:"auth_url"`
}

View File

@ -1,12 +1,34 @@
package v1
import (
"github.com/IceWhaleTech/CasaOS-Common/model"
"github.com/IceWhaleTech/CasaOS-Common/utils/common_err"
"github.com/IceWhaleTech/CasaOS/internal/op"
"github.com/IceWhaleTech/CasaOS/drivers/dropbox"
"github.com/IceWhaleTech/CasaOS/drivers/google_drive"
"github.com/IceWhaleTech/CasaOS/drivers/onedrive"
"github.com/IceWhaleTech/CasaOS/model"
"github.com/gin-gonic/gin"
)
func ListDriverInfo(c *gin.Context) {
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: op.GetDriverInfoMap()})
list := []model.Drive{}
google := google_drive.GetConfig()
list = append(list, model.Drive{
Name: "Google Drive",
Icon: google.Icon,
AuthUrl: google.AuthUrl,
})
dp := dropbox.GetConfig()
list = append(list, model.Drive{
Name: "Dropbox",
Icon: dp.Icon,
AuthUrl: dp.AuthUrl,
})
od := onedrive.GetConfig()
list = append(list, model.Drive{
Name: "OneDrive",
Icon: od.Icon,
AuthUrl: od.AuthUrl,
})
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: list})
}