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; }