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

View File

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

View File

@ -1,9 +1,6 @@
package model
import (
"database/sql/driver"
"encoding/json"
"github.com/IceWhaleTech/CasaOS/service/docker_base"
"time"
)
@ -11,25 +8,12 @@ type RelyDBModel struct {
Id uint `gorm:"column:id;primary_key" json:"id"`
CustomId string ` json:"custom_id"`
ContainerCustomId string `json:"container_custom_id"`
Config MysqlConfigs `json:"config"`
ContainerId string `json:"container_id,omitempty"`
Type int `json:"type"` // 目前暂未使用
CreatedAt time.Time `gorm:"<-:create" json:"created_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结构*******************/
func (p RelyDBModel) TableName() string {