mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-02-23 06:32:27 +08:00
1.0发布,Fixes Bug,以及新增 ProTable组件
This commit is contained in:
@@ -5,9 +5,10 @@ import { PageEnum } from '@/enums/pageEnum';
|
||||
import { createRouterGuards } from './router-guards'
|
||||
import 'nprogress/css/nprogress.css' // 进度条样式
|
||||
|
||||
// @ts-ignore
|
||||
const modules = import.meta.globEager('./modules/**/*.ts');
|
||||
|
||||
const routeModuleList: AppRouteModule[] = [];
|
||||
const routeModuleList: RouteRecordRaw[] = [];
|
||||
|
||||
Object.keys(modules).forEach((key) => {
|
||||
const mod = modules[key].default || {};
|
||||
@@ -15,7 +16,13 @@ Object.keys(modules).forEach((key) => {
|
||||
routeModuleList.push(...modList);
|
||||
});
|
||||
|
||||
export const RootRoute: AppRouteRecordRaw = {
|
||||
function sortRoute(a, b) {
|
||||
return (a.meta.sort || 0) - (b.meta.sort || 0)
|
||||
}
|
||||
|
||||
routeModuleList.sort(sortRoute)
|
||||
|
||||
export const RootRoute: RouteRecordRaw = {
|
||||
path: '/',
|
||||
name: 'Root',
|
||||
redirect: PageEnum.BASE_HOME,
|
||||
@@ -24,7 +31,7 @@ export const RootRoute: AppRouteRecordRaw = {
|
||||
},
|
||||
};
|
||||
|
||||
export const LoginRoute: AppRouteRecordRaw = {
|
||||
export const LoginRoute: RouteRecordRaw = {
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
component: () => import('@/views/login/index.vue'),
|
||||
|
||||
44
src/router/modules/comp.ts
Normal file
44
src/router/modules/comp.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { RouteRecordRaw } from 'vue-router'
|
||||
import { Layout } from '@/router/constant';
|
||||
import { ProfileOutlined } from '@vicons/antd'
|
||||
import { renderIcon } from '@/utils/index'
|
||||
|
||||
|
||||
const routeName = 'comp'
|
||||
|
||||
/**
|
||||
* @param name 路由名称, 必须设置,且不能重名
|
||||
* @param meta 路由元信息(路由附带扩展信息)
|
||||
* @param redirect 重定向地址, 访问这个路由时,自定进行重定向
|
||||
* @param meta.disabled 禁用整个菜单
|
||||
* @param meta.title 菜单名称
|
||||
* @param meta.icon 菜单图标
|
||||
* @param meta.keepAlive 缓存该路由
|
||||
* @param meta.sort 排序越小越排前
|
||||
*
|
||||
* */
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/comp',
|
||||
name: routeName,
|
||||
redirect: '/comp/console',
|
||||
component: Layout,
|
||||
meta: {
|
||||
title: '组件',
|
||||
icon: renderIcon(ProfileOutlined),
|
||||
sort: 1
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'table',
|
||||
name: `${ routeName }_table`,
|
||||
meta: {
|
||||
title: '基础表格',
|
||||
},
|
||||
component: () => import('@/views/comp/table/list.vue')
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
|
||||
export default routes
|
||||
@@ -1,13 +1,7 @@
|
||||
import { h } from 'vue'
|
||||
import { NIcon } from 'naive-ui'
|
||||
import { RouteRecordRaw } from 'vue-router'
|
||||
import { Layout } from '@/router/constant';
|
||||
import { MainView } from '@/layout/components/Main'
|
||||
import { DashboardOutlined } from '@vicons/antd'
|
||||
|
||||
function renderIcon(icon) {
|
||||
return () => h(NIcon, null, { default: () => h(icon) })
|
||||
}
|
||||
import { renderIcon } from '@/utils/index'
|
||||
|
||||
const routeName = 'dashboard'
|
||||
|
||||
@@ -19,7 +13,7 @@ const routeName = 'dashboard'
|
||||
* @param meta.title 菜单名称
|
||||
* @param meta.icon 菜单图标
|
||||
* @param meta.keepAlive 缓存该路由
|
||||
*
|
||||
* @param meta.sort 排序越小越排前
|
||||
* */
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
@@ -30,7 +24,8 @@ const routes: Array<RouteRecordRaw> = [
|
||||
meta: {
|
||||
title: 'Dashboard',
|
||||
icon: renderIcon(DashboardOutlined),
|
||||
permission: ['dashboard_console', 'dashboard_console', 'dashboard_workplace']
|
||||
permission: ['dashboard_console', 'dashboard_console', 'dashboard_workplace'],
|
||||
sort: 0
|
||||
},
|
||||
children: [
|
||||
{
|
||||
@@ -56,7 +51,7 @@ const routes: Array<RouteRecordRaw> = [
|
||||
name: `${ routeName }_workplace`,
|
||||
meta: {
|
||||
title: '工作台',
|
||||
keepAlive:true,
|
||||
keepAlive: true,
|
||||
permission: ['dashboard_workplace']
|
||||
},
|
||||
component: () => import('@/views/dashboard/workplace/workplace.vue')
|
||||
|
||||
@@ -128,7 +128,7 @@ export function createRouterGuards(router: Router) {
|
||||
const asyncRouteStore = useAsyncRouteStoreWidthOut();
|
||||
// 在这里设置需要缓存的组件名称
|
||||
const keepAliveComponents = asyncRouteStore.keepAliveComponents
|
||||
const currentComName:any = to.matched.find((item) => item.name == to.name)?.name
|
||||
const currentComName: any = to.matched.find((item) => item.name == to.name)?.name
|
||||
if (currentComName && !keepAliveComponents.includes(currentComName) && to.meta?.keepAlive) {
|
||||
// 需要缓存的组件
|
||||
keepAliveComponents.push(currentComName)
|
||||
|
||||
Reference in New Issue
Block a user