From 278a56232054ba830dee31a49030264ca76c0558 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Thu, 10 Aug 2023 12:48:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E6=95=B0=E6=8D=AE=E5=BA=93=E5=90=8D=E7=9A=84?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC=20(#1904)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/util.ts | 11 +++++++++++ frontend/src/views/app-store/detail/params/index.vue | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts index 6db703eb0..f39b441d9 100644 --- a/frontend/src/utils/util.ts +++ b/frontend/src/utils/util.ts @@ -116,6 +116,17 @@ export function getRandomStr(e: number): string { return n; } +export function getDBName(e: number): string { + const t = 'abcdefhijkmnprstwxyz2345678'; + const a = t.length; + let n = ''; + + for (let i = 0; i < e; i++) { + n += t.charAt(Math.floor(Math.random() * a)); + } + return n; +} + export function loadZero(i: number) { return i < 10 ? '0' + i : '' + i; } diff --git a/frontend/src/views/app-store/detail/params/index.vue b/frontend/src/views/app-store/detail/params/index.vue index 972271ee0..0e48a3be1 100644 --- a/frontend/src/views/app-store/detail/params/index.vue +++ b/frontend/src/views/app-store/detail/params/index.vue @@ -102,6 +102,7 @@ import { Rules } from '@/global/form-rules'; import { App } from '@/api/interface/app'; import { useRouter } from 'vue-router'; import { useI18n } from 'vue-i18n'; +import { getDBName } from '@/utils/util'; const router = useRouter(); interface ParamObj extends App.FromField { @@ -167,7 +168,11 @@ const handleParams = () => { pObj.disabled = p.disabled; paramObjs.value.push(pObj); if (p.random) { - form[p.envKey] = p.default + '_' + getRandomStr(6); + if (p.envKey === 'PANEL_DB_NAME') { + form[p.envKey] = p.default + '_' + getDBName(6); + } else { + form[p.envKey] = p.default + '_' + getRandomStr(6); + } } else { form[p.envKey] = p.default; }