From b96ba6aac5f11261bd59538ef093561aee1a8dec Mon Sep 17 00:00:00 2001 From: ningmengchongshui <916415899@qq.com> Date: Tue, 18 Jun 2024 13:46:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=8E=A8=E5=AF=BC=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/module.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/utils/module.ts b/src/utils/module.ts index d47d526..48543a7 100644 --- a/src/utils/module.ts +++ b/src/utils/module.ts @@ -59,6 +59,23 @@ export type ModuleWithComponent< PropsType = any > = Promise<{ [K in ComponentName]: React.ComponentType }> +// export const createDynamicComponent = (basePath: string) => { +// /** +// * 与import作用相同 +// * @param path 相对路径 +// * @returns +// */ +// return = { default: any }>( +// path: string +// ): Promise<{ [K in keyof T]: React.ComponentType }> => +// import( +// new URL( +// `${path}${process.env.NODE_ENV == 'production' ? '' : now()}`, +// basePath +// ).href +// ) +// } + /** * @param basePath import.meta.url * @returns @@ -73,7 +90,7 @@ export const createDynamicComponent = (basePath: string) => { * @param path 相对路径 * @returns */ - return (path: string): ModuleWithComponent => + return (path: string): Promise => import( new URL( `${path}${process.env.NODE_ENV == 'production' ? '' : now()}`,