From 1e47f614e148831942016e43712c4b04db16ce64 Mon Sep 17 00:00:00 2001 From: liangtongchuan Date: Sun, 13 Sep 2020 14:02:41 +0800 Subject: [PATCH] =?UTF-8?q?web-server=20=E4=BD=BF=E7=94=A8=20tsconfig-path?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/tsconfig.json | 1 - shared/{ => consts}/statusCode.ts | 0 web-server/app/controller/game.ts | 6 +++--- web-server/app/middleware/tokenParser.ts | 2 +- web-server/app/service/Auth.ts | 10 +++++----- web-server/app/service/TurboCore.ts | 2 +- web-server/config/plugin.ts | 1 + web-server/tsconfig.json | 7 ++++++- 8 files changed, 17 insertions(+), 12 deletions(-) rename shared/{ => consts}/statusCode.ts (100%) diff --git a/game-server/tsconfig.json b/game-server/tsconfig.json index c50b0531d..b9eac9b6d 100644 --- a/game-server/tsconfig.json +++ b/game-server/tsconfig.json @@ -24,7 +24,6 @@ "watch":false //在监视模式下运行编译器。会监视输出文件,在它们改变时重新编译。 }, "include":[ - "../shared/**/*.ts", "./app/**/*.ts", "./config/**/*.ts", "./app.ts", diff --git a/shared/statusCode.ts b/shared/consts/statusCode.ts similarity index 100% rename from shared/statusCode.ts rename to shared/consts/statusCode.ts diff --git a/web-server/app/controller/game.ts b/web-server/app/controller/game.ts index db4281eb5..42a3beab5 100644 --- a/web-server/app/controller/game.ts +++ b/web-server/app/controller/game.ts @@ -1,6 +1,6 @@ -import { SERVER_NOT_FOUND } from './../../../shared/statusCode'; -import { STATUS_SUC } from '../../../shared/statusCode'; -import { GameModel } from '../db/Game'; +import { SERVER_NOT_FOUND } from '@consts/statusCode'; +import { STATUS_SUC } from '@consts/statusCode'; +import { GameModel } from '@db/Game'; import { Controller } from 'egg'; export default class GameController extends Controller { diff --git a/web-server/app/middleware/tokenParser.ts b/web-server/app/middleware/tokenParser.ts index 854faa6bf..72af59fed 100644 --- a/web-server/app/middleware/tokenParser.ts +++ b/web-server/app/middleware/tokenParser.ts @@ -1,4 +1,4 @@ -import { STATUS_TOKEN_ERR, STATUS_WRONG_PARMS } from './../../../shared/statusCode'; +import { STATUS_TOKEN_ERR, STATUS_WRONG_PARMS } from '@consts/statusCode'; import { UserModel } from './../db/User'; module.exports = () => { diff --git a/web-server/app/service/Auth.ts b/web-server/app/service/Auth.ts index a8c9f8838..6a0aba237 100644 --- a/web-server/app/service/Auth.ts +++ b/web-server/app/service/Auth.ts @@ -1,9 +1,9 @@ -import { RoleModel } from './../db/Role'; -import { UserModel } from './../db/User'; -import { SMS_IN_60S, SMS_CNT_LIMIT, STATUS_SUC, STATUS_WRONG_PARMS, SMS_INVALID, ROLE_NOT_FOUND } from './../../../shared/statusCode'; -import { smsModel } from './../db/Sms'; +import { RoleModel } from '@db/Role'; +import { UserModel } from '@db/User'; +import { SMS_IN_60S, SMS_CNT_LIMIT, STATUS_SUC, STATUS_WRONG_PARMS, SMS_INVALID, ROLE_NOT_FOUND } from '@consts/statusCode'; +import { smsModel } from '@db/Sms'; import { Service } from 'egg'; -import Counter from '../db/Counter'; +import Counter from '@db/Counter'; const _ = require('underscore'); /** diff --git a/web-server/app/service/TurboCore.ts b/web-server/app/service/TurboCore.ts index ee34349a0..ec71c949a 100644 --- a/web-server/app/service/TurboCore.ts +++ b/web-server/app/service/TurboCore.ts @@ -1,4 +1,4 @@ -import { TURBO_CORE_URL, APP_ID, TURBO_PARM_SECRET } from './../../../shared/consts/consts'; +import { TURBO_CORE_URL, APP_ID, TURBO_PARM_SECRET } from '@consts/consts'; import { Service } from 'egg'; const crypto = require('crypto'); /** diff --git a/web-server/config/plugin.ts b/web-server/config/plugin.ts index c5011a8cf..658d56bee 100644 --- a/web-server/config/plugin.ts +++ b/web-server/config/plugin.ts @@ -1,4 +1,5 @@ import { EggPlugin } from 'egg'; +import 'tsconfig-paths/register'; const plugin: EggPlugin = { // static: true, diff --git a/web-server/tsconfig.json b/web-server/tsconfig.json index b522c82ed..bfc970cf0 100644 --- a/web-server/tsconfig.json +++ b/web-server/tsconfig.json @@ -20,7 +20,12 @@ "skipLibCheck": true, "skipDefaultLibCheck": true, "inlineSourceMap": true, - "importHelpers": true + "importHelpers": true, + "baseUrl": ".", + "paths": { + "@db/*": ["app/db/*"], + "@consts/*": ["app/consts/*"] + }, }, "exclude": [ "app/public",