From 19f9c4635b0169c5cc30ce8adb5b9777ff749254 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Mon, 10 Oct 2022 15:10:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8C=BA=E5=88=86mysql=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app_utils.go | 13 +++++++++---- frontend/src/views/app-store/installed/index.vue | 15 +++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index a46ad3695..d556bdf28 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -46,21 +46,26 @@ func execDockerCommand(database model.Database, dbInstall model.AppInstall, op D Auth: auth, DbParam: dbConfig, } - _, err := cmd.Exec(getSqlStr(database.Key, op, execConfig)) + _, err := cmd.Exec(getSqlStr(database.Key, dbInstall.Version, op, execConfig)) if err != nil { return err } return nil } -func getSqlStr(key string, operate DatabaseOp, exec dto.ContainerExec) string { +func getSqlStr(key, version string, operate DatabaseOp, exec dto.ContainerExec) string { var str string param := exec.DbParam switch key { case "mysql": if operate == Add { - str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%' IDENTIFIED BY '%s';\"", - exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser, param.Password) + if common.CompareVersion(version, "8.0") { + str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%';\" -e \"FLUSH PRIVILEGES;\"", + exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser) + } else { + str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"CREATE USER '%s'@'%%' IDENTIFIED BY '%s';\" -e \"create database %s;\" -e \"GRANT ALL ON %s.* TO '%s'@'%%' IDENTIFIED BY '%s';\" -e \"FLUSH PRIVILEGES;\"", + exec.ContainerName, exec.Auth.RootPassword, param.DbUser, param.Password, param.DbName, param.DbName, param.DbUser, param.Password) + } } if operate == Delete { str = fmt.Sprintf("docker exec -i %s mysql -uroot -p%s -e \"drop database %s;\" -e \"drop user %s;\" ", diff --git a/frontend/src/views/app-store/installed/index.vue b/frontend/src/views/app-store/installed/index.vue index 56a9348ea..27b96176c 100644 --- a/frontend/src/views/app-store/installed/index.vue +++ b/frontend/src/views/app-store/installed/index.vue @@ -32,10 +32,13 @@ {{ row.status }} - - - - {{ row.status }} + + + + + + {{ row.status }} + import { GetAppInstalled, InstalledOp, SyncInstalledApp, GetAppUpdateVersions } from '@/api/modules/app'; -import { onBeforeMount, onMounted, reactive, ref } from 'vue'; +import { onMounted, onUnmounted, reactive, ref } from 'vue'; import ComplexTable from '@/components/complex-table/index.vue'; import { dateFromat } from '@/utils/util'; import i18n from '@/lang'; @@ -254,7 +257,7 @@ onMounted(() => { }, 1000 * 8); }); -onBeforeMount(() => { +onUnmounted(() => { clearInterval(Number(timer)); });