Skip to content

Commit

Permalink
fix: 修复layout及子组件更改时热更新报错问题(将layout layoutPage改为动态引入)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntian001 committed Nov 9, 2022
1 parent f42271c commit 3a96bb6
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/router/constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const Layout = ()=>import('@/layout/index.vue');
export const LayoutPage = ()=>import('@/layout/components/page.vue');
3 changes: 2 additions & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { PageEnum } from '@/enums/pageEnum';
import { App } from 'vue';
import { setupRouterGuard } from './guard';
import { concatObjectValue } from '@/utils/helper';
import Layout from '@/layout/index.vue';
import { Layout } from '@/router/constant';
export const asyncRoutes = concatObjectValue<RouteRecordRaw>(
import.meta.glob('./routes/*.ts', { eager: true, import: 'routes' }),
);
import { isExternal } from '@/utils/validate';
import { resolve } from 'path-browserify';


export const constantRoutes: RouteRecordRaw[] = [
{
path: '/',
Expand Down
2 changes: 1 addition & 1 deletion src/router/routes/1-dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PageEnum } from '@/enums/pageEnum';
import { RouteRecordRaw } from 'vue-router';
import Layout from '@/layout/index.vue';
import { Layout } from '@/router/constant';
import { concatObjectValue } from '@/utils/helper';
export const routes: RouteRecordRaw[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/router/routes/2-example.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RouteRecordRaw } from 'vue-router';
import Layout from '@/layout/index.vue';
import { Layout } from '@/router/constant';
import { concatObjectValue } from '@/utils/helper';
export const routes: RouteRecordRaw[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions src/router/routes/example/6-multilevel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RouteRecordRaw, RouterView } from 'vue-router';
import LayoutPage from '@/layout/components/page.vue';
import { RouteRecordRaw } from 'vue-router';
import {LayoutPage} from '@/router/constant';
import { concatObjectValue } from '@/utils/helper';
export const routes: RouteRecordRaw[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions src/router/routes/example/multilevel/1.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RouteRecordRaw, RouterView } from 'vue-router';
import LayoutPage from '@/layout/components/page.vue';
import { RouteRecordRaw } from 'vue-router';
import {LayoutPage} from '@/router/constant';
export const routes: RouteRecordRaw[] = [
{
path: '1',
Expand Down
3 changes: 1 addition & 2 deletions src/utils/permission.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Layout from '@/layout/index.vue';
import LayoutPage from '@/layout/components/page.vue';
import { Layout,LayoutPage } from '@/router/constant';
import Page404 from '@/views/404.vue';
import { useUserStore } from '@/store';
import { RouteRecordRaw } from 'vue-router';
Expand Down

0 comments on commit 3a96bb6

Please sign in to comment.