From 4e464e9d7c6b8e2917b943199bd7248575f40daa Mon Sep 17 00:00:00 2001 From: liximomo Date: Mon, 11 Sep 2023 11:25:37 +0800 Subject: [PATCH] feat: pass router to appContext hook --- packages/platform-shared/src/shared/application.ts | 4 +++- packages/platform-shared/src/shared/runtimPlugin.ts | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/platform-shared/src/shared/application.ts b/packages/platform-shared/src/shared/application.ts index acc28aa51..2ac58000e 100644 --- a/packages/platform-shared/src/shared/application.ts +++ b/packages/platform-shared/src/shared/application.ts @@ -109,7 +109,9 @@ export class ApplicationImpl { } private async _initAppContext() { - await this._pluginManager.runner.appContext(this._context); + await this._pluginManager.runner.appContext(this._context, { + router: this._router + }); } private async _initAppComponent() { diff --git a/packages/platform-shared/src/shared/runtimPlugin.ts b/packages/platform-shared/src/shared/runtimPlugin.ts index c147ea674..dba581ff5 100644 --- a/packages/platform-shared/src/shared/runtimPlugin.ts +++ b/packages/platform-shared/src/shared/runtimPlugin.ts @@ -11,11 +11,15 @@ import { import { CustomRuntimePluginHooks } from '@shuvi/runtime'; import { createPluginCreator } from '@shuvi/shared/plugins'; import { IAppContext } from './applicationTypes'; +import { IRouter } from './routerTypes'; export type AppComponent = unknown; +export type AppContextCtx = { + router: IRouter; +}; const init = createAsyncParallelHook(); -const appContext = createAsyncSeriesHook(); +const appContext = createAsyncSeriesHook(); const appComponent = createAsyncSeriesWaterfallHook< AppComponent, IAppContext