From 28bd0e3cc208ddd937f52861d2694e83c0257629 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Fri, 7 Jul 2023 23:15:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BA=94=E7=94=A8=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AB=AF=E5=8F=A3=E7=9A=84=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E8=8C=83=E5=9B=B4=20(#1581)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app.go | 24 +++++++---- backend/app/service/app_utils.go | 44 ++++++--------------- frontend/src/lang/modules/en.ts | 1 + frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + frontend/src/views/app-store/apps/index.vue | 1 + 6 files changed, 33 insertions(+), 39 deletions(-) diff --git a/backend/app/service/app.go b/backend/app/service/app.go index 280f3e224..d10ecb7e5 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -24,6 +24,7 @@ import ( "os" "path" "strconv" + "strings" ) type AppService struct { @@ -269,14 +270,23 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) ( appDetail model.AppDetail app model.App ) - httpPort, err = checkPort("PANEL_APP_PORT_HTTP", req.Params) - if err != nil { - return - } - httpsPort, err = checkPort("PANEL_APP_PORT_HTTPS", req.Params) - if err != nil { - return + for key := range req.Params { + if !strings.Contains(key, "PORT") { + continue + } + var port int + if port, err = checkPort(key, req.Params); err == nil { + if key == "PANEL_APP_PORT_HTTP" { + httpPort = port + } + if key == "PANEL_APP_PORT_HTTPS" { + httpsPort = port + } + } else { + return + } } + appDetail, err = appDetailRepo.GetFirst(commonRepo.WithByID(req.AppDetailId)) if err != nil { return diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 98a6147b4..59ca59e6d 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -8,7 +8,6 @@ import ( "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" "github.com/1Panel-dev/1Panel/backend/app/dto/request" "github.com/1Panel-dev/1Panel/backend/i18n" - "github.com/compose-spec/compose-go/types" "github.com/subosito/gotenv" "gopkg.in/yaml.v3" "math" @@ -521,27 +520,6 @@ func upAppPre(app model.App, appInstall *model.AppInstall) error { return nil } -func getServiceFromInstall(appInstall *model.AppInstall) (service *composeV2.ComposeService, err error) { - var ( - project *types.Project - envStr string - ) - envStr, err = coverEnvJsonToStr(appInstall.Env) - if err != nil { - return - } - project, err = composeV2.GetComposeProject(appInstall.Name, appInstall.GetPath(), []byte(appInstall.DockerCompose), []byte(envStr), true) - if err != nil { - return - } - service, err = composeV2.NewComposeService() - if err != nil { - return - } - service.SetProject(project) - return -} - func checkContainerNameIsExist(containerName, appDir string) (bool, error) { client, err := composeV2.NewDockerClient() if err != nil { @@ -574,18 +552,20 @@ func upApp(appInstall *model.AppInstall) { out string errMsg string ) - out, err = compose.Pull(appInstall.GetComposePath()) - if err != nil { - if out != "" { - if strings.Contains(out, "no such host") { - errMsg = i18n.GetMsgByKey("ErrNoSuchHost") + ":" + if appInstall.App.Type != "php" { + out, err = compose.Pull(appInstall.GetComposePath()) + if err != nil { + if out != "" { + if strings.Contains(out, "no such host") { + errMsg = i18n.GetMsgByKey("ErrNoSuchHost") + ":" + } + if strings.Contains(out, "timeout") { + errMsg = i18n.GetMsgByKey("ErrImagePullTimeOut") + ":" + } + appInstall.Message = errMsg + out } - if strings.Contains(out, "timeout") { - errMsg = i18n.GetMsgByKey("ErrImagePullTimeOut") + ":" - } - appInstall.Message = errMsg + out + return err } - return err } out, err = compose.Up(appInstall.GetComposePath()) if err != nil { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index cbf8c4776..f636f6891 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1201,6 +1201,7 @@ const message = { showIgnore: 'View ignore application', cancelIgnore: 'Cancel ignore', ignoreList: 'ignore list', + appHelper: 'Please view the installation instructions of some applications on the application details page', }, website: { website: 'Website', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index f57c70a74..a5b63ef11 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1142,6 +1142,7 @@ const message = { showIgnore: '查看忽略應用', cancelIgnore: '取消忽略', ignoreList: '忽略列表', + appHelper: '部分應用的安裝使用說明請在應用詳情頁查看', }, website: { website: '網站', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 0613008c0..e7408d56e 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1148,6 +1148,7 @@ const message = { showIgnore: '查看忽略应用', cancelIgnore: '取消忽略', ignoreList: '忽略列表', + appHelper: '部分应用的安装使用说明请在应用详情页查看', }, website: { website: '网站', diff --git a/frontend/src/views/app-store/apps/index.vue b/frontend/src/views/app-store/apps/index.vue index 62a53a316..079643a67 100644 --- a/frontend/src/views/app-store/apps/index.vue +++ b/frontend/src/views/app-store/apps/index.vue @@ -44,6 +44,7 @@