diff --git a/back/api/system.ts b/back/api/system.ts index 1ef84b58..7623ef1f 100644 --- a/back/api/system.ts +++ b/back/api/system.ts @@ -25,7 +25,6 @@ export default (app: Router) => { try { const userService = Container.get(UserService); const authInfo = await userService.getUserInfo(); - const envCount = await EnvModel.count(); const { version, changeLog, changeLogLink } = await parseVersion( config.versionFile, ); @@ -95,9 +94,7 @@ export default (app: Router) => { const logger: Logger = Container.get('logger'); try { const systemService = Container.get(SystemService); - const result = await systemService.updateSystemConfig( - req.body, - ); + const result = await systemService.updateSystemConfig(req.body); res.send(result); } catch (e) { return next(e); diff --git a/back/services/system.ts b/back/services/system.ts index a39921e1..108eb928 100644 --- a/back/services/system.ts +++ b/back/services/system.ts @@ -2,7 +2,13 @@ import { Service, Inject } from 'typedi'; import winston from 'winston'; import config from '../config'; import * as fs from 'fs'; -import { AuthDataType, AuthInfo, AuthInstance, AuthModel, AuthModelInfo } from '../data/auth'; +import { + AuthDataType, + AuthInfo, + AuthInstance, + AuthModel, + AuthModelInfo, +} from '../data/auth'; import { NotificationInfo } from '../data/notify'; import NotificationService from './notify'; import ScheduleService, { TaskCallbacks } from './schedule'; @@ -16,7 +22,7 @@ import { parseVersion, } from '../config/util'; import { TASK_COMMAND } from '../config/const'; -import taskLimit from '../shared/pLimit' +import taskLimit from '../shared/pLimit'; @Service() export default class SystemService { @@ -31,7 +37,7 @@ export default class SystemService { public async getSystemConfig() { const doc = await this.getDb({ type: AuthDataType.systemConfig }); - return doc || {}; + return doc || ({} as AuthInstance); } private async updateAuthDb(payload: AuthInfo): Promise { @@ -42,7 +48,7 @@ export default class SystemService { public async getDb(query: any): Promise { const doc: any = await AuthModel.findOne({ where: { ...query } }); - return doc && (doc.get({ plain: true })); + return doc && doc.get({ plain: true }); } public async updateNotificationMode(notificationInfo: NotificationInfo) { diff --git a/shell/update.sh b/shell/update.sh index 7a54f932..1639dd0b 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -231,7 +231,7 @@ usage() { ## 更新qinglong update_qinglong() { - rm -rf "${dir_tmp}/*" + rm -rf ${dir_tmp}/* local mirror="gitee" local downloadQLUrl="https://gitee.com/whyour/qinglong/repository/archive" local downloadStaticUrl="https://gitee.com/whyour/qinglong-static/repository/archive" @@ -253,7 +253,8 @@ update_qinglong() { if [[ $exit_status -eq 0 ]]; then echo -e "\n更新青龙源文件成功...\n" - unzip -oq "${dir_tmp}/ql.zip" + cd + unzip -oq ${dir_tmp}/ql.zip -d ${dir_tmp} update_qinglong_static else @@ -267,7 +268,7 @@ update_qinglong_static() { if [[ $exit_status -eq 0 ]]; then echo -e "\n更新青龙静态资源成功...\n" - unzip -oq "${dir_tmp}/static.zip" + unzip -oq ${dir_tmp}/static.zip -d ${dir_tmp} check_update_dep else @@ -288,9 +289,9 @@ check_update_dep() { if [[ $exit_status -eq 0 ]]; then echo -e "\n依赖检测安装成功...\n" - cp -rf ${dir_tmp}/qinglong-${primary_branch}/* ${dir_root} + cp -rf ${dir_tmp}/qinglong-${primary_branch}/* ${dir_root}/ rm -rf $dir_static/* - cp -rf ${dir_tmp}/qinglong-static-${primary_branch}/* ${dir_static} + cp -rf ${dir_tmp}/qinglong-static-${primary_branch}/* ${dir_static}/ cp -f $file_config_sample $dir_config/config.sample.sh reload_pm2