This commit is contained in:
Tiger Wang 2022-11-20 02:58:38 +00:00
parent 38e300419b
commit 56d59a2c69
3 changed files with 23 additions and 41 deletions

View File

@ -14,15 +14,14 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/IceWhaleTech/CasaOS-Common/utils/port"
"github.com/IceWhaleTech/CasaOS/model/notify" "github.com/IceWhaleTech/CasaOS/model/notify"
"github.com/IceWhaleTech/CasaOS/pkg/config" "github.com/IceWhaleTech/CasaOS/pkg/config"
"github.com/IceWhaleTech/CasaOS/pkg/utils/port"
"github.com/IceWhaleTech/CasaOS/service" "github.com/IceWhaleTech/CasaOS/service"
f "github.com/ambelovsky/gosf" f "github.com/ambelovsky/gosf"
) )
func SocketInit(msg chan notify.Message) { func SocketInit(msg chan notify.Message) {
// set socket port // set socket port
socketPort := 0 socketPort := 0
if len(config.ServerInfo.SocketPort) == 0 { if len(config.ServerInfo.SocketPort) == 0 {
@ -51,10 +50,9 @@ func SocketInit(msg chan notify.Message) {
f.Broadcast("", v.Path, &v.Msg) f.Broadcast("", v.Path, &v.Msg)
time.Sleep(time.Millisecond * 100) time.Sleep(time.Millisecond * 100)
} }
}(msg) }(msg)
f.Startup(map[string]interface{}{ f.Startup(map[string]interface{}{
"port": socketPort}) "port": socketPort,
})
} }

View File

@ -222,19 +222,19 @@ func DirPath(c *gin.Context) {
for _, v := range shares { for _, v := range shares {
sharesMap[v.Path] = fmt.Sprint(v.ID) sharesMap[v.Path] = fmt.Sprint(v.ID)
} }
if path == "/DATA/AppData" { // if path == "/DATA/AppData" {
list := service.MyService.Docker().DockerContainerList() // list := service.MyService.Docker().DockerContainerList()
apps := make(map[string]string, len(list)) // apps := make(map[string]string, len(list))
for _, v := range list { // for _, v := range list {
apps[strings.ReplaceAll(v.Names[0], "/", "")] = strings.ReplaceAll(v.Names[0], "/", "") // apps[strings.ReplaceAll(v.Names[0], "/", "")] = strings.ReplaceAll(v.Names[0], "/", "")
} // }
for i := 0; i < len(info); i++ { // for i := 0; i < len(info); i++ {
if v, ok := apps[info[i].Name]; ok { // if v, ok := apps[info[i].Name]; ok {
info[i].Label = v // info[i].Label = v
info[i].Type = "application" // info[i].Type = "application"
} // }
} // }
} // } // TODO - ?
for i := 0; i < len(info); i++ { for i := 0; i < len(info); i++ {
if v, ok := sharesMap[info[i].Path]; ok { if v, ok := sharesMap[info[i].Path]; ok {

View File

@ -1,33 +1,17 @@
package model package model
import ( import (
"database/sql/driver"
"encoding/json"
"github.com/IceWhaleTech/CasaOS/service/docker_base"
"time" "time"
) )
type RelyDBModel struct { type RelyDBModel struct {
Id uint `gorm:"column:id;primary_key" json:"id"` Id uint `gorm:"column:id;primary_key" json:"id"`
CustomId string ` json:"custom_id"` CustomId string ` json:"custom_id"`
ContainerCustomId string `json:"container_custom_id"` ContainerCustomId string `json:"container_custom_id"`
Config MysqlConfigs `json:"config"` ContainerId string `json:"container_id,omitempty"`
ContainerId string `json:"container_id,omitempty"` Type int `json:"type"` // 目前暂未使用
Type int `json:"type"` //目前暂未使用 CreatedAt time.Time `gorm:"<-:create" json:"created_at"`
CreatedAt time.Time `gorm:"<-:create" json:"created_at"` UpdatedAt time.Time `gorm:"<-:create;<-:update" json:"updated_at"`
UpdatedAt time.Time `gorm:"<-:create;<-:update" json:"updated_at"`
}
/****************使gorm支持[]string结构*******************/
type MysqlConfigs docker_base.MysqlConfig
func (c MysqlConfigs) Value() (driver.Value, error) {
b, err := json.Marshal(c)
return string(b), err
}
func (c *MysqlConfigs) Scan(input interface{}) error {
return json.Unmarshal(input.([]byte), c)
} }
/****************使gorm支持[]string结构*******************/ /****************使gorm支持[]string结构*******************/