From 793e740c324e9240b8331ce5866381593c8c0691 Mon Sep 17 00:00:00 2001 From: kangert Date: Thu, 17 Jun 2021 10:32:20 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=8F=90=E9=AB=98=E7=BC=96=E7=A0=81=E4=BD=93?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 6c0f0a15..85a1fe95 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -858,7 +858,7 @@ const pathMatch = { }; // 获取目录下的 .vue 全部文件,参考 vite:import.meta.glob -const dynamicViewsModules = import.meta.glob('../views/**/*.{vue,tsx}'); +const dynamicViewsModules: Record = import.meta.glob('../views/**/*.{vue,tsx}'); // 添加静态路由 const router = createRouter({ @@ -919,7 +919,7 @@ export function backEndRouter(routes: any) { } // 后端控制路由,后端路由 component 转换函数 -export function dynamicImport(dynamicViewsModules: Record Promise<{ [key: string]: any }>>, component: string) { +export function dynamicImport(dynamicViewsModules: Record, component: string) { const keys = Object.keys(dynamicViewsModules); const matchKeys = keys.filter((key) => { const k = key.replace('../views', ''); From 134b63848a6c1cb37e9a1bd0b6ca3d4f432bcd62 Mon Sep 17 00:00:00 2001 From: kangert Date: Thu, 17 Jun 2021 10:33:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=B0=86=E7=B1=BB=E5=9E=8B=E2=80=9Cstring=20|=20undefined?= =?UTF-8?q?=E2=80=9D=E5=88=86=E9=85=8D=E7=BB=99=E7=B1=BB=E5=9E=8B=E2=80=9C?= =?UTF-8?q?string=E2=80=9D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/viteBuild.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/viteBuild.ts b/src/utils/viteBuild.ts index 05bc8eaa..647da4de 100644 --- a/src/utils/viteBuild.ts +++ b/src/utils/viteBuild.ts @@ -9,7 +9,7 @@ export interface ViteEnv { export function loadEnv(): ViteEnv { const env = process.env.NODE_ENV; const ret: any = {}; - const envList = [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env', ,]; + const envList = [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env', ]; envList.forEach((e) => { dotenv.config({ path: e }); }); From 72ffa2d6fdec58cc876ca2e69612fe81eb365730 Mon Sep 17 00:00:00 2001 From: kangert Date: Fri, 18 Jun 2021 11:11:20 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E6=B7=B1=E5=85=8B?= =?UTF-8?q?=E9=9A=86=E5=B7=A5=E5=85=B7=E6=96=B9=E4=BE=BF=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/deepClone.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/utils/deepClone.ts diff --git a/src/utils/deepClone.ts b/src/utils/deepClone.ts new file mode 100644 index 00000000..3e45034d --- /dev/null +++ b/src/utils/deepClone.ts @@ -0,0 +1,22 @@ +/** + * 对象深克隆 + * @param obj 源对象 + * @returns 克隆后的对象 + */ +export function deepClone(obj: any) { + let newObj: any + try { + //如果obj有push方法则 定义newObj为数组,否则为对象。 + newObj = obj.push ? [] : {} + } catch (error) { + newObj = {} + } + for (let attr in obj) { + if (typeof obj[attr] === 'object') { + newObj[attr] = deepClone(obj[attr]); + } else { + newObj[attr] = obj[attr]; + } + } + return newObj; +} \ No newline at end of file