mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-12 05:15:59 +08:00
fix: Fix the recommended application display exception (#8148)
This commit is contained in:
parent
47d8c405dd
commit
1220a0c1ae
4 changed files with 19 additions and 7 deletions
|
|
@ -62,7 +62,7 @@ func (b *BaseApi) LoadAppLauncherOption(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseApi) SyncAppLauncher(c *gin.Context) {
|
func (b *BaseApi) SyncAppLauncher(c *gin.Context) {
|
||||||
var req []dto.AppLauncherSync
|
var req dto.AppLauncherSync
|
||||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ type DashboardCurrent struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppLauncherSync struct {
|
type AppLauncherSync struct {
|
||||||
Key string `json:"key"`
|
Keys []string `json:"keys"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DiskInfo struct {
|
type DiskInfo struct {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import (
|
||||||
type DashboardService struct{}
|
type DashboardService struct{}
|
||||||
|
|
||||||
type IDashboardService interface {
|
type IDashboardService interface {
|
||||||
Sync(req []dto.AppLauncherSync) error
|
Sync(req dto.AppLauncherSync) error
|
||||||
|
|
||||||
LoadOsInfo() (*dto.OsInfo, error)
|
LoadOsInfo() (*dto.OsInfo, error)
|
||||||
LoadBaseInfo(ioOption string, netOption string) (*dto.DashboardBase, error)
|
LoadBaseInfo(ioOption string, netOption string) (*dto.DashboardBase, error)
|
||||||
|
|
@ -47,10 +47,10 @@ func NewIDashboardService() IDashboardService {
|
||||||
return &DashboardService{}
|
return &DashboardService{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *DashboardService) Sync(req []dto.AppLauncherSync) error {
|
func (u *DashboardService) Sync(req dto.AppLauncherSync) error {
|
||||||
var launchers []model.AppLauncher
|
var launchers []model.AppLauncher
|
||||||
for _, item := range req {
|
for _, item := range req.Keys {
|
||||||
launchers = append(launchers, model.AppLauncher{Key: item.Key})
|
launchers = append(launchers, model.AppLauncher{Key: item})
|
||||||
}
|
}
|
||||||
return launcherRepo.SyncAll(launchers)
|
return launcherRepo.SyncAll(launchers)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,19 @@ func (u *LauncherService) ChangeShow(req dto.SettingUpdate) error {
|
||||||
|
|
||||||
func syncLauncherToAgent() {
|
func syncLauncherToAgent() {
|
||||||
launchers, _ := launcherRepo.List()
|
launchers, _ := launcherRepo.List()
|
||||||
itemData, _ := json.Marshal(launchers)
|
var list []string
|
||||||
|
launcherMap := make(map[string]struct{})
|
||||||
|
for _, item := range launchers {
|
||||||
|
if _, ok := launcherMap[item.Key]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
launcherMap[item.Key] = struct{}{}
|
||||||
|
list = append(list, item.Key)
|
||||||
|
}
|
||||||
|
launcherData := struct {
|
||||||
|
Keys []string
|
||||||
|
}{Keys: list}
|
||||||
|
itemData, _ := json.Marshal(launcherData)
|
||||||
_, _ = proxy_local.NewLocalClient("/api/v2/dashboard/app/launcher/sync", http.MethodPost, bytes.NewReader((itemData)))
|
_, _ = proxy_local.NewLocalClient("/api/v2/dashboard/app/launcher/sync", http.MethodPost, bytes.NewReader((itemData)))
|
||||||
_ = xpack.RequestToAllAgent("/api/v2/dashboard/app/launcher/sync", http.MethodPost, bytes.NewReader((itemData)))
|
_ = xpack.RequestToAllAgent("/api/v2/dashboard/app/launcher/sync", http.MethodPost, bytes.NewReader((itemData)))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue