perf: init db and config

This commit is contained in:
archer
2023-07-27 09:33:56 +08:00
parent aa7fb6a65c
commit 97c7984dd1
7 changed files with 74 additions and 19 deletions

View File

@@ -90,7 +90,8 @@ const defaultVectorModels = [
export async function getInitConfig() {
try {
const res = JSON.parse(readFileSync('data/config.json', 'utf-8'));
const filename = process.env.NODE_ENV === 'development' ? 'config.json.local' : 'config.json';
const res = JSON.parse(readFileSync(`data/${filename}`, 'utf-8'));
console.log(res);
global.systemEnv = res.SystemParams || defaultSystemEnv;

View File

@@ -60,15 +60,10 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
<form onSubmit={handleSubmit(onclickLogin)}>
<FormControl mt={8} isInvalid={!!errors.username}>
<Input
placeholder="邮箱/手机号"
placeholder="邮箱/手机号/用户名"
size={['md', 'lg']}
{...register('username', {
required: '邮箱/手机号不能为空',
pattern: {
value:
/(^1[3456789]\d{9}$)|(^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$)/,
message: '邮箱/手机号格式错误'
}
required: '邮箱/手机号/用户名不能为空'
})}
></Input>
<FormErrorMessage position={'absolute'} fontSize="xs">
@@ -82,13 +77,9 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
placeholder="密码"
{...register('password', {
required: '密码不能为空',
minLength: {
value: 4,
message: '密码最少4位最多12位'
},
maxLength: {
value: 12,
message: '密码最少4位最多12位'
message: '密码最多12位'
}
})}
></Input>

View File

@@ -65,7 +65,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
title: `注册成功`,
status: 'success'
});
// aut register a model
// auto register template app
appTemplates.forEach((template) => {
postCreateApp({
avatar: template.avatar,