mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-11 11:56:46 +08:00
feat:修改路由
This commit is contained in:
@@ -1,16 +1,25 @@
|
||||
/*
|
||||
* @Author: lixg lixg@dongwu-inc.com
|
||||
* @Date: 2022-11-09 09:26:26
|
||||
* @LastEditors: lixg lixg@dongwu-inc.com
|
||||
* @LastEditTime: 2022-11-21 15:06:51
|
||||
* @FilePath: /fe-manage/src/router/config.js
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
const routes = [];
|
||||
const context = require.context("@/views", true, /\.vue$/, "lazy");
|
||||
context.keys().forEach((path) => {
|
||||
// console.log('path', path)
|
||||
const componentName = path.replace(/.*\/([^\\.\\/]*)\.vue$/, "$1");
|
||||
routes.push({
|
||||
path: `/${componentName.toLowerCase()}/:id?`,
|
||||
path: `/manage/${componentName.toLowerCase()}/:id?`,
|
||||
name: componentName,
|
||||
component: () => context(path),
|
||||
meta: {
|
||||
isLink: true,
|
||||
},
|
||||
});
|
||||
// console.log('routes', routes)
|
||||
});
|
||||
|
||||
export default routes;
|
||||
|
||||
@@ -2,26 +2,24 @@
|
||||
* @Author: lixg lixg@dongwu-inc.com
|
||||
* @Date: 2022-11-09 09:26:26
|
||||
* @LastEditors: lixg lixg@dongwu-inc.com
|
||||
* @LastEditTime: 2022-11-16 09:56:16
|
||||
* @LastEditTime: 2022-11-21 14:55:13
|
||||
* @FilePath: /fe-manage/src/router/index.js
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
import { createRouter,createWebHistory } from 'vue-router';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import routesConfig from './config';
|
||||
console.log('routesConfig', routesConfig)
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: '首页',
|
||||
redirect: '/learningpath'
|
||||
redirect: '/manage/learningpath'
|
||||
},
|
||||
...routesConfig
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes
|
||||
})
|
||||
base: '/manage',
|
||||
routes,
|
||||
|
||||
})
|
||||
export default router
|
||||
Reference in New Issue
Block a user