From bbc845b01c61df6c6238a6aa5d0eaf942856482a Mon Sep 17 00:00:00 2001 From: Xc Date: Wed, 10 Apr 2024 22:56:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=84=E9=80=A0=E9=A1=B9=E7=9B=AE=E7=9A=84ex?= =?UTF-8?q?ception=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/src/context/RuntimeContext.ts | 3 +-- template/src/types/Exception.ts | 16 +++++++++++----- template/wechatMp/src/app.ts | 11 +++++------ templateFiles/DependentExceptions.ts | 14 ++++++++++++++ 4 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 templateFiles/DependentExceptions.ts diff --git a/template/src/context/RuntimeContext.ts b/template/src/context/RuntimeContext.ts index 211c821..c08cf46 100644 --- a/template/src/context/RuntimeContext.ts +++ b/template/src/context/RuntimeContext.ts @@ -1,6 +1,5 @@ -import { RuntimeContext as GeneralRuntimeContext } from 'oak-general-business'; /** * 若业务逻辑需要更多的上下文之间的数据传递,可以放在这里 */ -export interface RuntimeContext extends GeneralRuntimeContext {} +export interface RuntimeContext {} diff --git a/template/src/types/Exception.ts b/template/src/types/Exception.ts index 7fc4342..2a65bf9 100644 --- a/template/src/types/Exception.ts +++ b/template/src/types/Exception.ts @@ -1,13 +1,19 @@ -import { OakException } from 'oak-domain/lib/types'; -import { EntityDict } from '@project/oak-app-domain'; -import { makeException as makeGeneralException } from 'oak-general-business'; +import { OakException, OakUserException } from 'oak-domain/lib/types'; +import { EntityDict } from '@oak-app-domain'; +import makeDepedentException from './DependentExceptions'; -export class ExampleException extends OakException {} +export class ExampleException extends OakException {}; + +export class ConsoleModeIllegalException extends OakException {}; + +export class ConsoleLoadingDataException extends OakException {}; + +export class ExistsNewBidException extends OakUserException {}; export function makeException(msg: string | object) { const data = typeof msg === 'string' ? JSON.parse(msg) : msg; - const exception = makeGeneralException(data); + const exception = makeDepedentException(data); if (exception) { return exception; } diff --git a/template/wechatMp/src/app.ts b/template/wechatMp/src/app.ts index 4153754..22e21e6 100644 --- a/template/wechatMp/src/app.ts +++ b/template/wechatMp/src/app.ts @@ -5,6 +5,7 @@ import { compareVersion } from 'oak-domain/lib/utils/version'; import { sdkVersion } from './configuration'; import { features } from './initialize'; +import initializeFeatures from '@project/initializeFeatures'; export interface IAppOption { globalData: { @@ -55,11 +56,9 @@ App({ showCancel: false, }); } - // 等application初始化完成后进行登录 - await features.application.initialize(); - if (!features.token.getTokenValue()) { - await features.token.loginWechatMp(); - } + features.navigator.setNamespace('/frontend'); + + await initializeFeatures(features); }, onHide() { @@ -74,4 +73,4 @@ App({ const { reason } = rejection; exceptionHandler(reason, features); }, -}); +}); \ No newline at end of file diff --git a/templateFiles/DependentExceptions.ts b/templateFiles/DependentExceptions.ts new file mode 100644 index 0000000..d143833 --- /dev/null +++ b/templateFiles/DependentExceptions.ts @@ -0,0 +1,14 @@ +import { EntityDict } from '@project/oak-app-domain'; +import { SelectOpResult } from 'oak-domain/lib/types/Entity'; +import { makeException as makeDomainException } from 'oak-domain/lib/types/Exception'; + +export default function makeException(data: { + name: string; + message?: string; + opRecords: SelectOpResult; + [A: string]: any; +}) { + const e = makeDomainException(data); + + return e; +}