Skip to content

Commit f094002

Browse files
committedNov 29, 2024·
应用商店安装应用时增加默认值和说明
1 parent 999ac07 commit f094002

17 files changed

+56
-27
lines changed
 

‎app/application/logic/compose.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func (self Compose) GetTasker(entity *entity.Compose) (*compose.Task, error) {
317317
if !function.IsEmptyArray(entity.Setting.Environment) {
318318
globalEnv := make([]string, 0)
319319
for _, item := range entity.Setting.Environment {
320-
globalEnv = append(globalEnv, fmt.Sprintf("%s=%s", item.Name, item.Value))
320+
globalEnv = append(globalEnv, fmt.Sprintf("%s=%s", item.Name, compose.ReplacePlaceholder(item.Value)))
321321
}
322322
envFileName := filepath.Join(taskFileDir, ComposeProjectEnvFileName)
323323
err := os.MkdirAll(filepath.Dir(envFileName), os.ModePerm)

‎app/common/http/controller/store.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,10 @@ func (self Store) Sync(http *gin.Context) {
205205

206206
func (self Store) Deploy(http *gin.Context) {
207207
type ParamsValidate struct {
208-
StoreId int32 `json:"storeId" binding:"required"`
209-
Name string `json:"name" binding:"required"`
210-
ComposeFile string `json:"composeFile" binding:"required"`
208+
StoreId int32 `json:"storeId" binding:"required"`
209+
Name string `json:"name" binding:"required"`
210+
ComposeFile string `json:"composeFile" binding:"required"`
211+
Environment []accessor.EnvItem `json:"environment"`
211212
}
212213
params := ParamsValidate{}
213214
if !self.Validate(http, &params) {
@@ -229,9 +230,10 @@ func (self Store) Deploy(http *gin.Context) {
229230
Title: "",
230231
Yaml: "",
231232
Setting: &accessor.ComposeSettingOption{
232-
Status: "waiting",
233-
Type: accessor.ComposeTypeStore,
234-
Store: fmt.Sprintf("%s@%s", storeRow.Title, storeRow.Setting.Url),
233+
Status: "waiting",
234+
Type: accessor.ComposeTypeStore,
235+
Store: fmt.Sprintf("%s@%s", storeRow.Title, storeRow.Setting.Url),
236+
Environment: params.Environment,
235237
Uri: []string{
236238
filepath.Join(params.Name, filepath.Base(params.ComposeFile)),
237239
},

‎app/common/logic/store.go

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"github.com/donknap/dpanel/common/accessor"
88
"github.com/donknap/dpanel/common/function"
9+
"github.com/donknap/dpanel/common/service/compose"
910
"github.com/donknap/dpanel/common/service/exec"
1011
"github.com/donknap/dpanel/common/service/storage"
1112
"gopkg.in/yaml.v3"
@@ -202,6 +203,11 @@ func (self Store) GetAppByOnePanel(storePath string) ([]accessor.StoreAppItem, e
202203
if len(segments) == 3 {
203204
fields := yamlData.GetSliceStringMapString("additionalProperties.formFields")
204205
env := make([]accessor.EnvItem, 0)
206+
env = append(env, accessor.EnvItem{
207+
Name: "CONTAINER_NAME",
208+
Label: "容器名称",
209+
Value: compose.ContainerDefaultName,
210+
})
205211
for _, field := range fields {
206212
env = append(env, accessor.EnvItem{
207213
Name: field["envKey"],

‎asset/static/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
</head>
1919
<body>
2020
<div id="root"></div>
21-
<script src="/dpanel/static/asset/umi.9edcb667.js"></script>
21+
<script src="/dpanel/static/asset/umi.9c4e42ea.js"></script>
2222
</body>
2323
</html>

‎asset/static/p__app__create__image.5316b09c.async.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎asset/static/p__app__create__image.9f1ffb74.async.js

-5
This file was deleted.

‎asset/static/p__app__list.77e55adb.async.js ‎asset/static/p__app__list.6f7f960b.async.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎asset/static/p__compose__appstore.0a63b7c2.async.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎asset/static/p__compose__appstore.b60fcf6c.async.js

-5
This file was deleted.

‎asset/static/p__compose__create.a0e4184a.async.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎asset/static/p__compose__create.bcac50fb.async.js

-3
This file was deleted.

‎asset/static/p__compose__deploy.2a714692.async.js

-3
This file was deleted.

‎asset/static/p__compose__deploy.e9fd5ff1.async.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎asset/static/p__system__appstore.2279d1b6.async.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎asset/static/p__system__appstore.31e100f5.async.js

-1
This file was deleted.

‎asset/static/umi.9edcb667.js ‎asset/static/umi.9c4e42ea.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎common/service/compose/placehold.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package compose
2+
3+
const (
4+
ContainerDefaultName = "%CONTAINER_DEFAULT_NAME%"
5+
)
6+
7+
var placeholderList = map[string]string{
8+
ContainerDefaultName: "",
9+
}
10+
11+
func ReplacePlaceholder(str string) string {
12+
if value, ok := placeholderList[str]; ok {
13+
return value
14+
} else {
15+
return ""
16+
}
17+
}

0 commit comments

Comments
 (0)
Please sign in to comment.