feat: 修改应用安装数据库名的默认值 (#1904)

pull/1906/head
zhengkunwang 1 year ago committed by GitHub
parent c0d8578466
commit 278a562320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -116,6 +116,17 @@ export function getRandomStr(e: number): string {
return n; 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) { export function loadZero(i: number) {
return i < 10 ? '0' + i : '' + i; return i < 10 ? '0' + i : '' + i;
} }

@ -102,6 +102,7 @@ import { Rules } from '@/global/form-rules';
import { App } from '@/api/interface/app'; import { App } from '@/api/interface/app';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { getDBName } from '@/utils/util';
const router = useRouter(); const router = useRouter();
interface ParamObj extends App.FromField { interface ParamObj extends App.FromField {
@ -167,7 +168,11 @@ const handleParams = () => {
pObj.disabled = p.disabled; pObj.disabled = p.disabled;
paramObjs.value.push(pObj); paramObjs.value.push(pObj);
if (p.random) { if (p.random) {
if (p.envKey === 'PANEL_DB_NAME') {
form[p.envKey] = p.default + '_' + getDBName(6);
} else {
form[p.envKey] = p.default + '_' + getRandomStr(6); form[p.envKey] = p.default + '_' + getRandomStr(6);
}
} else { } else {
form[p.envKey] = p.default; form[p.envKey] = p.default;
} }

Loading…
Cancel
Save