From 48e2e01a57dee187656c23b035d423696c41de08 Mon Sep 17 00:00:00 2001 From: CityFun <31820853+zhengkunwang223@users.noreply.github.com> Date: Tue, 25 Nov 2025 11:51:17 +0800 Subject: [PATCH] feat: Add MySQL character set and collation configuration during application installation (#11062) --- agent/app/dto/app.go | 2 + agent/app/service/app_utils.go | 3 +- agent/init/migration/migrations/init.go | 2 +- frontend/package.json | 1 + .../src/views/app-store/detail/form/index.vue | 1 + .../views/app-store/detail/install/index.vue | 2 + .../views/app-store/detail/params/index.vue | 39 ++++++++++++++++++- .../src/views/app-store/installed/index.vue | 25 ++++++------ .../app-store/installed/upgrade/index.vue | 7 ++-- frontend/vite.config.ts | 21 +++++----- 10 files changed, 76 insertions(+), 27 deletions(-) diff --git a/agent/app/dto/app.go b/agent/app/dto/app.go index 3f22817f2..3eb8b4ad5 100644 --- a/agent/app/dto/app.go +++ b/agent/app/dto/app.go @@ -12,6 +12,8 @@ type AppDatabase struct { DbUser string `json:"PANEL_DB_USER"` Password string `json:"PANEL_DB_USER_PASSWORD"` DatabaseName string `json:"DATABASE_NAME"` + Format string `json:"format"` + Collation string `json:"collation"` } type AuthParam struct { diff --git a/agent/app/service/app_utils.go b/agent/app/service/app_utils.go index f8e86d64e..bf6107318 100644 --- a/agent/app/service/app_utils.go +++ b/agent/app/service/app_utils.go @@ -300,10 +300,11 @@ func createLink(ctx context.Context, installTask *task.Task, app model.App, appI createMysql.Name = dbConfig.DbName createMysql.Username = dbConfig.DbUser createMysql.Database = database.Name - createMysql.Format = "utf8mb4" + createMysql.Format = dbConfig.Format createMysql.Permission = "%" createMysql.Password = dbConfig.Password createMysql.From = database.From + createMysql.Collation = dbConfig.Collation mysqldb, err := NewIMysqlService().Create(ctx, createMysql) if err != nil { return err diff --git a/agent/init/migration/migrations/init.go b/agent/init/migration/migrations/init.go index 124255efe..fd7432b80 100644 --- a/agent/init/migration/migrations/init.go +++ b/agent/init/migration/migrations/init.go @@ -730,6 +730,6 @@ var AddGPUMonitor = &gormigrate.Migration{ var UpdateDatabaseMysql = &gormigrate.Migration{ ID: "20251125-update-database-mysql", Migrate: func(tx *gorm.DB) error { - return tx.AutoMigrate(&model.Database{}) + return tx.AutoMigrate(&model.DatabaseMysql{}) }, } diff --git a/frontend/package.json b/frontend/package.json index f590e25c0..55db7744c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -87,6 +87,7 @@ "vite-plugin-compression": "^0.5.1", "vite-plugin-eslint": "^1.8.1", "vite-plugin-html": "^3.2.2", + "vite-plugin-monaco-editor": "^1.1.0", "vite-plugin-vue-setup-extend": "^0.4.0", "vite-svg-loader": "^5.1.0", "vue-tsc": "^0.29.8" diff --git a/frontend/src/views/app-store/detail/form/index.vue b/frontend/src/views/app-store/detail/form/index.vue index 4060743cc..64e187f6d 100644 --- a/frontend/src/views/app-store/detail/form/index.vue +++ b/frontend/src/views/app-store/detail/form/index.vue @@ -201,6 +201,7 @@ const formRules = ref({ memoryLimit: [Rules.requiredInput, checkNumberRange(0, 9999999999)], specifyIP: [Rules.ipv4orV6], restartPolicy: [Rules.requiredSelect], + format: [Rules.requiredInput], }); const initFormData = () => ({ diff --git a/frontend/src/views/app-store/detail/install/index.vue b/frontend/src/views/app-store/detail/install/index.vue index dcf17a166..71e808c2e 100644 --- a/frontend/src/views/app-store/detail/install/index.vue +++ b/frontend/src/views/app-store/detail/install/index.vue @@ -49,6 +49,8 @@ const formData = ref({ taskID: '', gpuConfig: false, specifyIP: '', + format: 'utf8mb4', + collation: '', }); const handleClose = () => { diff --git a/frontend/src/views/app-store/detail/params/index.vue b/frontend/src/views/app-store/detail/params/index.vue index e9bf881ff..4f1631d66 100644 --- a/frontend/src/views/app-store/detail/params/index.vue +++ b/frontend/src/views/app-store/detail/params/index.vue @@ -118,6 +118,17 @@ {{ getDescription(p) }} + + + + + + + + + + {{ $t('database.collationHelper', [form.format]) }} +