From 97cdf7bc78139740c4555f0d6e0e1bebd1908a12 Mon Sep 17 00:00:00 2001 From: CityFun <31820853+zhengkunwang223@users.noreply.github.com> Date: Thu, 28 Aug 2025 15:56:08 +0800 Subject: [PATCH] feat: Optimized the runtime environment installation, but the application store still does not display it as installed. (#10175) Refs https://github.com/1Panel-dev/1Panel/issues/10174 --- agent/app/repo/runtime.go | 7 +++++++ agent/app/service/app.go | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/agent/app/repo/runtime.go b/agent/app/repo/runtime.go index cc23def47..c32dd30e2 100644 --- a/agent/app/repo/runtime.go +++ b/agent/app/repo/runtime.go @@ -17,6 +17,7 @@ type IRuntimeRepo interface { WithNotId(id uint) DBOption WithStatus(status string) DBOption WithDetailId(id uint) DBOption + WithDetailIdsIn(ids []uint) DBOption WithPort(port int) DBOption WithNormalStatus(status string) DBOption Page(page, size int, opts ...DBOption) (int64, []model.Runtime, error) @@ -55,6 +56,12 @@ func (r *RuntimeRepo) WithDetailId(id uint) DBOption { } } +func (r *RuntimeRepo) WithDetailIdsIn(ids []uint) DBOption { + return func(g *gorm.DB) *gorm.DB { + return g.Where("app_detail_id in(?) ", ids) + } +} + func (r *RuntimeRepo) WithNotId(id uint) DBOption { return func(g *gorm.DB) *gorm.DB { return g.Where("id != ?", id) diff --git a/agent/app/service/app.go b/agent/app/service/app.go index 735bf56c5..f66058e61 100644 --- a/agent/app/service/app.go +++ b/agent/app/service/app.go @@ -132,8 +132,21 @@ func (a AppService) PageApp(ctx *gin.Context, req request.AppSearch) (interface{ continue } appDTO.Tags = tags - installs, _ := appInstallRepo.ListBy(context.Background(), appInstallRepo.WithAppId(ap.ID)) - appDTO.Installed = len(installs) > 0 + if ap.Type == constant.RuntimePHP || ap.Type == constant.RuntimeGo || ap.Type == constant.RuntimeNode || ap.Type == constant.RuntimePython || ap.Type == constant.RuntimeJava || ap.Type == constant.RuntimeDotNet { + details, _ := appDetailRepo.GetBy(appDetailRepo.WithAppId(ap.ID)) + var ids []uint + if len(details) == 0 { + continue + } + for _, d := range details { + ids = append(ids, d.ID) + } + runtimes, _ := runtimeRepo.List(runtimeRepo.WithDetailIdsIn(ids)) + appDTO.Installed = len(runtimes) > 0 + } else { + installs, _ := appInstallRepo.ListBy(context.Background(), appInstallRepo.WithAppId(ap.ID)) + appDTO.Installed = len(installs) > 0 + } } res.Items = appDTOs res.Total = total