From 3c19a07226ef2047096aa88c5e85cdeeadb39ee3 Mon Sep 17 00:00:00 2001
From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com>
Date: Fri, 23 Aug 2024 17:38:58 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BA=94=E7=94=A8=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E5=86=85=E5=AD=98=E9=9C=80=E6=B1=82=E5=B1=95=E7=A4=BA=20(#6224?=
=?UTF-8?q?)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
agent/app/dto/app.go | 2 +-
agent/app/dto/response/app.go | 12 ++++++------
agent/app/model/app.go | 2 +-
agent/app/service/app_utils.go | 2 +-
agent/app/task/task.go | 11 +++++++----
agent/cmd/server/conf/app.yaml | 3 +++
agent/i18n/lang/en.yaml | 1 +
agent/i18n/lang/zh-Hant.yaml | 1 +
agent/i18n/lang/zh.yaml | 3 ++-
agent/init/migration/migrations/init.go | 16 ++++++++--------
frontend/src/api/interface/app.ts | 2 +-
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/detail/index.vue | 7 ++++---
.../views/app-store/detail/install/index.vue | 17 +++++++++++++----
.../src/views/website/website/create/index.vue | 7 ++++++-
17 files changed, 58 insertions(+), 31 deletions(-)
diff --git a/agent/app/dto/app.go b/agent/app/dto/app.go
index 8b1c77d22..0fe36618f 100644
--- a/agent/app/dto/app.go
+++ b/agent/app/dto/app.go
@@ -95,7 +95,7 @@ type AppProperty struct {
Github string `json:"github"`
Document string `json:"document"`
Architectures []string `json:"architectures"`
- MemoryLimit int `json:"memoryLimit"`
+ MemoryRequired int `json:"memoryRequired"`
}
type AppConfigVersion struct {
diff --git a/agent/app/dto/response/app.go b/agent/app/dto/response/app.go
index df670b8ed..c0f0165c7 100644
--- a/agent/app/dto/response/app.go
+++ b/agent/app/dto/response/app.go
@@ -67,12 +67,12 @@ type AppInstalledCheck struct {
type AppDetailDTO struct {
model.AppDetail
- Enable bool `json:"enable"`
- Params interface{} `json:"params"`
- Image string `json:"image"`
- HostMode bool `json:"hostMode"`
- Architectures string `json:"architectures"`
- MemoryLimit int `json:"memoryLimit"`
+ Enable bool `json:"enable"`
+ Params interface{} `json:"params"`
+ Image string `json:"image"`
+ HostMode bool `json:"hostMode"`
+ Architectures string `json:"architectures"`
+ MemoryRequired int `json:"memoryRequired"`
}
type IgnoredApp struct {
diff --git a/agent/app/model/app.go b/agent/app/model/app.go
index 4f878dbcf..695007f56 100644
--- a/agent/app/model/app.go
+++ b/agent/app/model/app.go
@@ -27,7 +27,7 @@ type App struct {
ReadMe string `json:"readMe"`
LastModified int `json:"lastModified"`
Architectures string `json:"architectures"`
- MemoryLimit int `json:"memoryLimit"`
+ MemoryRequired int `json:"memoryRequired"`
Details []AppDetail `json:"-" gorm:"-:migration"`
TagsKey []string `json:"tags" yaml:"tags" gorm:"-"`
diff --git a/agent/app/service/app_utils.go b/agent/app/service/app_utils.go
index 7c63e2f84..21bfdf2ba 100644
--- a/agent/app/service/app_utils.go
+++ b/agent/app/service/app_utils.go
@@ -1118,7 +1118,7 @@ func getApps(oldApps []model.App, items []dto.AppDefine) map[string]model.App {
app.Status = constant.AppNormal
app.LastModified = item.LastModified
app.ReadMe = item.ReadMe
- app.MemoryLimit = config.MemoryLimit
+ app.MemoryRequired = config.MemoryRequired
app.Architectures = strings.Join(config.Architectures, ",")
apps[key] = app
}
diff --git a/agent/app/task/task.go b/agent/app/task/task.go
index a2bf8f6e9..8a3ef3ee2 100644
--- a/agent/app/task/task.go
+++ b/agent/app/task/task.go
@@ -120,7 +120,10 @@ func (t *Task) AddSubTaskWithIgnoreErr(name string, action ActionFunc) {
}
func (s *SubTask) Execute() error {
- s.RootTask.Log(s.Name)
+ subTaskName := s.Name
+ if s.Name == "" {
+ subTaskName = i18n.GetMsgByKey("SubTask")
+ }
var err error
for i := 0; i < s.Retry+1; i++ {
if i > 0 {
@@ -136,12 +139,12 @@ func (s *SubTask) Execute() error {
select {
case <-ctx.Done():
- s.RootTask.Log(i18n.GetWithName("TaskTimeout", s.Name))
+ s.RootTask.Log(i18n.GetWithName("TaskTimeout", subTaskName))
case err = <-done:
if err != nil {
- s.RootTask.Log(i18n.GetWithNameAndErr("SubTaskFailed", s.Name, err))
+ s.RootTask.Log(i18n.GetWithNameAndErr("SubTaskFailed", subTaskName, err))
} else {
- s.RootTask.Log(i18n.GetWithName("SubTaskSuccess", s.Name))
+ s.RootTask.Log(i18n.GetWithName("SubTaskSuccess", subTaskName))
return nil
}
}
diff --git a/agent/cmd/server/conf/app.yaml b/agent/cmd/server/conf/app.yaml
index 2bed83268..0c9a5a799 100644
--- a/agent/cmd/server/conf/app.yaml
+++ b/agent/cmd/server/conf/app.yaml
@@ -1,9 +1,12 @@
system:
db_agent_file: agent.db
+ db_core_file: core.db
base_dir: /opt
mode: dev
repo_url: https://resource.fit2cloud.com/1panel/package
app_repo: https://apps-assets.fit2cloud.com
+ username: admin
+ password: admin
log:
level: debug
diff --git a/agent/i18n/lang/en.yaml b/agent/i18n/lang/en.yaml
index 20a363c1c..90381fba6 100644
--- a/agent/i18n/lang/en.yaml
+++ b/agent/i18n/lang/en.yaml
@@ -236,4 +236,5 @@ EnableSSL: "Enable HTTPS"
AppStore: "App Store"
TaskSync: "Sync"
LocalApp: "Local App"
+SubTask: "Subtask"
diff --git a/agent/i18n/lang/zh-Hant.yaml b/agent/i18n/lang/zh-Hant.yaml
index 09a966996..4ad1d53ff 100644
--- a/agent/i18n/lang/zh-Hant.yaml
+++ b/agent/i18n/lang/zh-Hant.yaml
@@ -238,4 +238,5 @@ EnableSSL: "開啟 HTTPS"
AppStore: "應用商店"
TaskSync: "同步"
LocalApp: "本地應用"
+SubTask: "子任務"
diff --git a/agent/i18n/lang/zh.yaml b/agent/i18n/lang/zh.yaml
index 6bb68baba..6816556b8 100644
--- a/agent/i18n/lang/zh.yaml
+++ b/agent/i18n/lang/zh.yaml
@@ -238,4 +238,5 @@ AppLink: "关联应用"
EnableSSL: "开启 HTTPS"
AppStore: "应用商店"
TaskSync: "同步"
-LocalApp: "本地应用"
\ No newline at end of file
+LocalApp: "本地应用"
+SubTask: "子任务"
\ No newline at end of file
diff --git a/agent/init/migration/migrations/init.go b/agent/init/migration/migrations/init.go
index dfbc2272c..dc5e9fdd7 100644
--- a/agent/init/migration/migrations/init.go
+++ b/agent/init/migration/migrations/init.go
@@ -235,14 +235,6 @@ var UpdateWebsiteDomain = &gormigrate.Migration{
},
}
-var UpdateApp = &gormigrate.Migration{
- ID: "20240822-update-app",
- Migrate: func(tx *gorm.DB) error {
- return tx.AutoMigrate(
- &model.App{})
- },
-}
-
var AddTaskDB = &gormigrate.Migration{
ID: "20240822-add-task-table",
Migrate: func(tx *gorm.DB) error {
@@ -251,3 +243,11 @@ var AddTaskDB = &gormigrate.Migration{
)
},
}
+
+var UpdateApp = &gormigrate.Migration{
+ ID: "20240823-update-app",
+ Migrate: func(tx *gorm.DB) error {
+ return tx.AutoMigrate(
+ &model.App{})
+ },
+}
diff --git a/frontend/src/api/interface/app.ts b/frontend/src/api/interface/app.ts
index 46b36f87c..9f00e30e9 100644
--- a/frontend/src/api/interface/app.ts
+++ b/frontend/src/api/interface/app.ts
@@ -49,7 +49,7 @@ export namespace App {
dockerCompose: string;
image: string;
hostMode?: boolean;
- memoryLimit: number;
+ memoryRequired: number;
architectures: string;
}
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index 7d5d5c869..ba6e3be51 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -1879,6 +1879,7 @@ const message = {
link: 'Link',
showCurrentArch: 'Architecture',
syncLocalApp: 'Sync Local App',
+ memoryRequiredHelper: 'Current application memory requirement {0}',
},
website: {
website: 'Website',
diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts
index b8ae1fde4..ca541209d 100644
--- a/frontend/src/lang/modules/tw.ts
+++ b/frontend/src/lang/modules/tw.ts
@@ -1745,6 +1745,7 @@ const message = {
link: '鏈接',
showCurrentArch: '僅顯示當前架構',
syncLocalApp: '同步本地應用',
+ memoryRequiredHelper: '目前應用記憶體需求 {0}',
},
website: {
website: '網站',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index 15aa82db4..a87c851cd 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -1746,6 +1746,7 @@ const message = {
link: '链接',
showCurrentArch: '仅显示当前服务器架构应用',
syncLocalApp: '同步本地应用',
+ memoryRequiredHelper: '当前应用内存需求 {0}',
},
website: {
website: '网站',
diff --git a/frontend/src/views/app-store/detail/index.vue b/frontend/src/views/app-store/detail/index.vue
index 29eec404e..7446db4cf 100644
--- a/frontend/src/views/app-store/detail/index.vue
+++ b/frontend/src/views/app-store/detail/index.vue
@@ -58,8 +58,8 @@
-
- {{ appDetail.memoryLimit }} MB
+
+ {{ computeSizeFromMB(appDetail.memoryRequired) }}
@@ -81,8 +81,9 @@ import { ref } from 'vue';
import Install from './install/index.vue';
import router from '@/routers';
import { GlobalStore } from '@/store';
-import { getLanguage } from '@/utils/util';
+import { getLanguage, computeSizeFromMB } from '@/utils/util';
import { storeToRefs } from 'pinia';
+
const globalStore = GlobalStore();
const { isDarkTheme } = storeToRefs(globalStore);
diff --git a/frontend/src/views/app-store/detail/install/index.vue b/frontend/src/views/app-store/detail/install/index.vue
index 356cfe68d..79ed369d4 100644
--- a/frontend/src/views/app-store/detail/install/index.vue
+++ b/frontend/src/views/app-store/detail/install/index.vue
@@ -1,13 +1,19 @@
+
-
{
const paramKey = ref(1);
const isHostMode = ref(false);
const taskLogRef = ref();
+const memoryRequired = ref(0);
const changeUnit = () => {
if (req.memoryUnit == 'M') {
@@ -228,6 +236,7 @@ const getAppDetail = async (version: string) => {
isHostMode.value = res.data.hostMode;
installData.value.params = res.data.params;
paramKey.value++;
+ memoryRequired.value = res.data.memoryRequired;
} catch (error) {
} finally {
loading.value = false;
diff --git a/frontend/src/views/website/website/create/index.vue b/frontend/src/views/website/website/create/index.vue
index f06f4e84e..1970571bf 100644
--- a/frontend/src/views/website/website/create/index.vue
+++ b/frontend/src/views/website/website/create/index.vue
@@ -120,7 +120,12 @@
-
+