mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-18 03:16:30 +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) {
|
||||
var req []dto.AppLauncherSync
|
||||
var req dto.AppLauncherSync
|
||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ type DashboardCurrent struct {
|
|||
}
|
||||
|
||||
type AppLauncherSync struct {
|
||||
Key string `json:"key"`
|
||||
Keys []string `json:"keys"`
|
||||
}
|
||||
|
||||
type DiskInfo struct {
|
||||
|
|
|
@ -31,7 +31,7 @@ import (
|
|||
type DashboardService struct{}
|
||||
|
||||
type IDashboardService interface {
|
||||
Sync(req []dto.AppLauncherSync) error
|
||||
Sync(req dto.AppLauncherSync) error
|
||||
|
||||
LoadOsInfo() (*dto.OsInfo, error)
|
||||
LoadBaseInfo(ioOption string, netOption string) (*dto.DashboardBase, error)
|
||||
|
@ -47,10 +47,10 @@ func NewIDashboardService() IDashboardService {
|
|||
return &DashboardService{}
|
||||
}
|
||||
|
||||
func (u *DashboardService) Sync(req []dto.AppLauncherSync) error {
|
||||
func (u *DashboardService) Sync(req dto.AppLauncherSync) error {
|
||||
var launchers []model.AppLauncher
|
||||
for _, item := range req {
|
||||
launchers = append(launchers, model.AppLauncher{Key: item.Key})
|
||||
for _, item := range req.Keys {
|
||||
launchers = append(launchers, model.AppLauncher{Key: item})
|
||||
}
|
||||
return launcherRepo.SyncAll(launchers)
|
||||
}
|
||||
|
|
|
@ -54,7 +54,19 @@ func (u *LauncherService) ChangeShow(req dto.SettingUpdate) error {
|
|||
|
||||
func syncLauncherToAgent() {
|
||||
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)))
|
||||
_ = xpack.RequestToAllAgent("/api/v2/dashboard/app/launcher/sync", http.MethodPost, bytes.NewReader((itemData)))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue