refactor: 所有本地路由(除个人中心/workflow-iframe)改为从后端返回 适配
This commit is contained in:
parent
d039c53053
commit
a38f2de982
@ -1,6 +1,7 @@
|
||||
import type {
|
||||
ComponentRecordType,
|
||||
GenerateMenuAndRoutesOptions,
|
||||
RouteMeta,
|
||||
RouteRecordStringComponent,
|
||||
} from '@vben/types';
|
||||
|
||||
@ -21,6 +22,37 @@ import { localMenuList } from './routes/local';
|
||||
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
|
||||
const NotFoundComponent = () => import('#/views/_core/fallback/not-found.vue');
|
||||
|
||||
/**
|
||||
* 后端返回的meta有时候不包括需要的信息 比如activePath等
|
||||
* 在这里定义映射
|
||||
*/
|
||||
const routeMetaMapping: Record<string, Omit<RouteMeta, 'title'>> = {
|
||||
'/system/role-auth/user/:roleId(\\d+)': {
|
||||
activePath: '/system/role',
|
||||
requireHomeRedirect: true,
|
||||
},
|
||||
|
||||
'/system/oss-config/index': {
|
||||
activePath: '/system/oss',
|
||||
requireHomeRedirect: true,
|
||||
},
|
||||
|
||||
'/tool/gen-edit/index/:tableId(\\d+)': {
|
||||
activePath: '/tool/gen',
|
||||
requireHomeRedirect: true,
|
||||
},
|
||||
|
||||
'/workflow/design/index': {
|
||||
activePath: '/workflow/processDefinition',
|
||||
requireHomeRedirect: true,
|
||||
},
|
||||
|
||||
'/workflow/leaveEdit/index': {
|
||||
activePath: '/demo/leave',
|
||||
requireHomeRedirect: true,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 后台路由转vben路由
|
||||
* @param menuList 后台菜单
|
||||
@ -98,6 +130,17 @@ function backMenuToVbenMenu(
|
||||
path: menu.path,
|
||||
};
|
||||
|
||||
// 处理meta映射
|
||||
if (Object.keys(routeMetaMapping).includes(vbenRoute.path)) {
|
||||
const routeMeta = routeMetaMapping[vbenRoute.path];
|
||||
if (routeMeta) {
|
||||
vbenRoute.meta = {
|
||||
...vbenRoute.meta,
|
||||
...(routeMeta as RouteMeta),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 添加路由参数信息
|
||||
if (menu.query) {
|
||||
try {
|
||||
|
@ -9,6 +9,7 @@ const {
|
||||
|
||||
/**
|
||||
* 该文件放非后台返回的路由 比如个人中心 等需要跳转显示的页面
|
||||
* 也可以直接在菜单管理配置
|
||||
*/
|
||||
const localRoutes: RouteRecordStringComponent[] = [
|
||||
{
|
||||
@ -22,69 +23,6 @@ const localRoutes: RouteRecordStringComponent[] = [
|
||||
name: 'Profile',
|
||||
path: '/profile',
|
||||
},
|
||||
{
|
||||
component: '/system/oss-config/index',
|
||||
meta: {
|
||||
activePath: '/system/oss',
|
||||
icon: 'ant-design:setting-outlined',
|
||||
title: 'oss配置',
|
||||
hideInMenu: true,
|
||||
requireHomeRedirect: true,
|
||||
},
|
||||
name: 'OssConfig',
|
||||
path: '/system/oss-config',
|
||||
},
|
||||
{
|
||||
component: '/tool/gen/edit-gen',
|
||||
meta: {
|
||||
activePath: '/tool/gen',
|
||||
icon: 'tabler:code',
|
||||
title: '生成配置',
|
||||
hideInMenu: true,
|
||||
requireHomeRedirect: true,
|
||||
},
|
||||
name: 'GenConfig',
|
||||
path: '/code-gen/edit/:tableId',
|
||||
},
|
||||
{
|
||||
component: '/system/role-assign/index',
|
||||
meta: {
|
||||
activePath: '/system/role',
|
||||
icon: 'eos-icons:role-binding-outlined',
|
||||
title: '分配角色',
|
||||
hideInMenu: true,
|
||||
requireHomeRedirect: true,
|
||||
},
|
||||
name: 'RoleAssign',
|
||||
path: '/system/role-assign/:roleId',
|
||||
},
|
||||
{
|
||||
component: '/workflow/components/flow-designer',
|
||||
meta: {
|
||||
activePath: '/workflow/processDefinition',
|
||||
icon: 'fluent-mdl2:flow',
|
||||
title: '流程设计',
|
||||
hideInMenu: true,
|
||||
requireHomeRedirect: true,
|
||||
},
|
||||
name: 'WorkflowDesigner',
|
||||
path: '/workflow/designer',
|
||||
},
|
||||
/**
|
||||
* 需要添加iframe路由 同目录的./workflow-iframe.ts
|
||||
*/
|
||||
{
|
||||
component: 'workflow/leave/leave-form',
|
||||
meta: {
|
||||
icon: 'flat-color-icons:leave',
|
||||
title: '请假申请',
|
||||
activePath: '/demo/leave',
|
||||
hideInMenu: true,
|
||||
requireHomeRedirect: true,
|
||||
},
|
||||
name: 'WorkflowLeaveIndex',
|
||||
path: '/workflow/leaveEdit/index',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
|
11
apps/web-antd/src/views/system/oss/config.vue
Normal file
11
apps/web-antd/src/views/system/oss/config.vue
Normal file
@ -0,0 +1,11 @@
|
||||
<!--
|
||||
后端版本>=5.4.0 这个从本地路由变为从后台返回
|
||||
未修改文件名 而是新加了这个文件
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import OssConfigPage from '#/views/system/oss-config/index.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<OssConfigPage />
|
||||
</template>
|
@ -156,7 +156,7 @@ function handleMultiDelete() {
|
||||
|
||||
const router = useRouter();
|
||||
function handleToSettings() {
|
||||
router.push('/system/oss-config');
|
||||
router.push('/system/oss-config/index');
|
||||
}
|
||||
|
||||
const preview = ref(false);
|
||||
|
11
apps/web-antd/src/views/system/role/authUser.vue
Normal file
11
apps/web-antd/src/views/system/role/authUser.vue
Normal file
@ -0,0 +1,11 @@
|
||||
<!--
|
||||
后端版本>=5.4.0 这个从本地路由变为从后台返回
|
||||
未修改文件名 而是新加了这个文件
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import RoleAssignPage from '#/views/system/role-assign/index.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RoleAssignPage />
|
||||
</template>
|
@ -142,7 +142,7 @@ function handleAuthEdit(record: Role) {
|
||||
|
||||
const router = useRouter();
|
||||
function handleAssignRole(record: Role) {
|
||||
router.push(`/system/role-assign/${record.roleId}`);
|
||||
router.push(`/system/role-auth/user/${record.roleId}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
10
apps/web-antd/src/views/tool/gen/editTable.vue
Normal file
10
apps/web-antd/src/views/tool/gen/editTable.vue
Normal file
@ -0,0 +1,10 @@
|
||||
<!--
|
||||
后端版本>=5.4.0 这个从本地路由变为从后台返回
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import EditGenPage from './edit-gen.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<EditGenPage />
|
||||
</template>
|
@ -110,7 +110,7 @@ function handlePreview(record: Recordable<any>) {
|
||||
|
||||
const router = useRouter();
|
||||
function handleEdit(record: Recordable<any>) {
|
||||
router.push(`/code-gen/edit/${record.tableId}`);
|
||||
router.push(`/tool/gen-edit/index/${record.tableId}`);
|
||||
}
|
||||
|
||||
async function handleSync(record: Recordable<any>) {
|
||||
|
11
apps/web-antd/src/views/workflow/leave/leaveEdit.vue
Normal file
11
apps/web-antd/src/views/workflow/leave/leaveEdit.vue
Normal file
@ -0,0 +1,11 @@
|
||||
<!--
|
||||
后端版本>=5.4.0 这个从本地路由变为从后台返回
|
||||
未修改文件名 而是新加了这个文件
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import LeaveFormPage from './leave-form.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<LeaveFormPage />
|
||||
</template>
|
@ -0,0 +1,11 @@
|
||||
<!--
|
||||
后端版本>=5.4.0 这个从本地路由变为从后台返回
|
||||
未修改文件名 而是新加了这个文件
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import FlowDesignerPage from '../components/flow-designer.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FlowDesignerPage />
|
||||
</template>
|
@ -154,7 +154,7 @@ const router = useRouter();
|
||||
*/
|
||||
function handleDesign(row: any, disabled: boolean) {
|
||||
router.push({
|
||||
path: '/workflow/designer',
|
||||
path: '/workflow/design/index',
|
||||
query: { definitionId: row.id, disabled: String(disabled) },
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user