From 6819487a43934426a088807b993b1203afd01dae Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Sun, 3 Oct 2021 22:01:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/api/user.ts | 11 +++++++---- back/loaders/express.ts | 12 +++++++----- src/pages/initialization/index.tsx | 13 ++++++++++--- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/back/api/user.ts b/back/api/user.ts index df385d25..ef0a704a 100644 --- a/back/api/user.ts +++ b/back/api/user.ts @@ -5,6 +5,7 @@ import * as fs from 'fs'; import config from '../config'; import UserService from '../services/user'; import { celebrate, Joi } from 'celebrate'; +import { getFileContentByName } from '../config/util'; const route = Router(); export default (app: Router) => { @@ -211,12 +212,14 @@ export default (app: Router) => { try { const userService = Container.get(UserService); const authInfo = await userService.getUserInfo(); + const envDbContent = getFileContentByName(config.envDbFile); + let isInitialized = true; if ( - !authInfo || - (Object.keys(authInfo).length === 2 && - authInfo.username === 'admin' && - authInfo.password === 'admin') + Object.keys(authInfo).length === 2 && + authInfo.username === 'admin' && + authInfo.password === 'admin' && + envDbContent.length === 0 ) { isInitialized = false; } diff --git a/back/loaders/express.ts b/back/loaders/express.ts index 8bab163e..e4c86f33 100644 --- a/back/loaders/express.ts +++ b/back/loaders/express.ts @@ -5,7 +5,7 @@ import routes from '../api'; import config from '../config'; import jwt from 'express-jwt'; import fs from 'fs'; -import { getPlatform, getToken } from '../config/util'; +import { getFileContentByName, getPlatform, getToken } from '../config/util'; import Container from 'typedi'; import OpenService from '../services/open'; import rewrite from 'express-urlrewrite'; @@ -90,12 +90,14 @@ export default ({ app }: { app: Application }) => { } const userService = Container.get(UserService); const authInfo = await userService.getUserInfo(); + const envDbContent = getFileContentByName(config.envDbFile); + let isInitialized = true; if ( - !authInfo || - (Object.keys(authInfo).length === 2 && - authInfo.username === 'admin' && - authInfo.password === 'admin') + Object.keys(authInfo).length === 2 && + authInfo.username === 'admin' && + authInfo.password === 'admin' && + envDbContent.length === 0 ) { isInitialized = false; } diff --git a/src/pages/initialization/index.tsx b/src/pages/initialization/index.tsx index 34d12793..f6393e1a 100644 --- a/src/pages/initialization/index.tsx +++ b/src/pages/initialization/index.tsx @@ -5,18 +5,19 @@ import { Input, Form, message, - notification, + Typography, Steps, Select, } from 'antd'; import config from '@/utils/config'; -import { history, Link } from 'umi'; +import { history } from 'umi'; import styles from './index.less'; import { request } from '@/utils/http'; const FormItem = Form.Item; const { Step } = Steps; const { Option } = Select; +const { Link } = Typography; const Login = () => { const [loading, setLoading] = useState(false); @@ -192,8 +193,14 @@ const Login = () => {
恭喜安装完成! + + Github + + + Telegram频道 +
-
+