diff --git a/src/apps/remoteLoader.ts b/src/apps/remoteLoader.ts index 9fbb3f8..3ab37d7 100644 --- a/src/apps/remoteLoader.ts +++ b/src/apps/remoteLoader.ts @@ -42,7 +42,20 @@ export function GetRemoteHostRuntime(): RemoteHostRuntime { } /** - * 加载远端组件 + * 加载远端模块命名空间(不做契约解析,交由调用方判断 mount / createComponent) + * + * @param RemoteEntry 远端入口 URL + */ +export async function LoadRemoteModule(RemoteEntry: string): Promise> { + if (!RemoteEntry) { + throw new Error('远端入口地址为空') + } + // 运行期 URL:@vite-ignore 阻止打包器静态分析(远端不在本仓库内) + return (await import(/* @vite-ignore */ RemoteEntry)) as Record +} + +/** + * 加载远端组件(组件工厂契约) * * @param RemoteEntry 远端入口 URL(如 https://sub.xxx/remoteEntry.js 或 /remote-demo/entry.js) * @param ExportName 导出名(默认 default;工厂约定忽略此参数) @@ -53,11 +66,7 @@ export async function LoadRemoteComponent( RemoteEntry: string, ExportName = 'default', ): Promise { - if (!RemoteEntry) { - throw new Error('远端入口地址为空') - } - // 运行期 URL:@vite-ignore 阻止打包器静态分析(远端不在本仓库内) - const mod: Record = await import(/* @vite-ignore */ RemoteEntry) + const mod = await LoadRemoteModule(RemoteEntry) // 约定 1:工厂(宿主把运行时以参数传入) const factory = mod.createComponent diff --git a/src/views/RemoteAppHost.vue b/src/views/RemoteAppHost.vue index 129b08a..0603e3a 100644 --- a/src/views/RemoteAppHost.vue +++ b/src/views/RemoteAppHost.vue @@ -1,34 +1,69 @@ @@ -63,6 +116,9 @@ watch( .remote-app-host { padding: 16px; box-sizing: border-box; - height: 100%; + min-height: 100%; +} +.remote-mount { + min-height: 200px; }