mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-02-13 17:52:28 +08:00
fix Bug or add docs
This commit is contained in:
@@ -3,3 +3,5 @@ export const RedirectName = 'Redirect';
|
||||
export const ErrorPage = () => import('@/views/exception/404.vue');
|
||||
|
||||
export const Layout = () => import('@/layout/index.vue');
|
||||
|
||||
export const ParentLayout = () => import('@/layout/parentLayout.vue');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { RouteRecordRaw } from 'vue-router';
|
||||
import { Layout } from '@/router/constant';
|
||||
import { Layout, ParentLayout } from '@/router/constant';
|
||||
import { WalletOutlined } from '@vicons/antd';
|
||||
import { renderIcon } from '@/utils/index';
|
||||
|
||||
@@ -20,8 +20,8 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/comp',
|
||||
name: routeName,
|
||||
redirect: '/comp/console',
|
||||
component: Layout,
|
||||
redirect: '/comp/table',
|
||||
meta: {
|
||||
title: '组件示例',
|
||||
icon: renderIcon(WalletOutlined),
|
||||
@@ -31,10 +31,37 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: 'table',
|
||||
name: `${routeName}_table`,
|
||||
redirect: '/comp/table/basic',
|
||||
component: ParentLayout,
|
||||
meta: {
|
||||
title: '表格',
|
||||
},
|
||||
component: () => import('@/views/comp/table/list.vue'),
|
||||
children: [
|
||||
{
|
||||
path: 'basic',
|
||||
name: `${routeName}_table_basic`,
|
||||
meta: {
|
||||
title: '基础表格',
|
||||
},
|
||||
component: () => import('@/views/comp/table/basic.vue'),
|
||||
},
|
||||
{
|
||||
path: 'editCell',
|
||||
name: `${routeName}_table_editCell`,
|
||||
meta: {
|
||||
title: '单元格编辑',
|
||||
},
|
||||
component: () => import('@/views/comp/table/editCell.vue'),
|
||||
},
|
||||
{
|
||||
path: 'editRow',
|
||||
name: `${routeName}_table_editRow`,
|
||||
meta: {
|
||||
title: '整行编辑',
|
||||
},
|
||||
component: () => import('@/views/comp/table/editRow.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'upload',
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import { isNavigationFailure, Router } from 'vue-router';
|
||||
import { useUserStoreWidthOut } from '@/store/modules/user';
|
||||
import { useAsyncRouteStoreWidthOut } from '@/store/modules/asyncRoute';
|
||||
import NProgress from 'nprogress'; // progress bar
|
||||
import { ACCESS_TOKEN } from '@/store/mutation-types';
|
||||
import { storage } from '@/utils/Storage';
|
||||
import { PageEnum } from '@/enums/pageEnum';
|
||||
|
||||
NProgress.configure({ showSpinner: false }); // NProgress Configuration
|
||||
|
||||
const LOGIN_PATH = PageEnum.BASE_LOGIN;
|
||||
|
||||
const whitePathList = [LOGIN_PATH]; // no redirect whitelist
|
||||
@@ -15,8 +12,9 @@ const whitePathList = [LOGIN_PATH]; // no redirect whitelist
|
||||
export function createRouterGuards(router: Router) {
|
||||
const userStore = useUserStoreWidthOut();
|
||||
const asyncRouteStore = useAsyncRouteStoreWidthOut();
|
||||
const Loading = window['$loading'] || null;
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
NProgress.start();
|
||||
Loading && Loading.start();
|
||||
if (from.path === LOGIN_PATH && to.name === 'errorPage') {
|
||||
next(PageEnum.BASE_HOME);
|
||||
return;
|
||||
@@ -70,7 +68,7 @@ export function createRouterGuards(router: Router) {
|
||||
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect };
|
||||
asyncRouteStore.setDynamicAddedRoute(true);
|
||||
next(nextData);
|
||||
NProgress.done();
|
||||
Loading && Loading.finish();
|
||||
});
|
||||
|
||||
router.afterEach((to, _, failure) => {
|
||||
@@ -93,7 +91,7 @@ export function createRouterGuards(router: Router) {
|
||||
}
|
||||
}
|
||||
asyncRouteStore.setKeepAliveComponents(keepAliveComponents);
|
||||
NProgress.done(); // finish progress bar
|
||||
Loading && Loading.finish();
|
||||
});
|
||||
|
||||
router.onError((error) => {
|
||||
|
||||
Reference in New Issue
Block a user