From 0ebfa92a17a11495651eeacd8031423f90c90d6a Mon Sep 17 00:00:00 2001
From: wen <1515>
Date: Sun, 16 Oct 2022 19:41:41 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/layout/components/Sidebar/SidebarItem.vue | 5 +-
src/layout/components/Sidebar/index.vue | 52 ++++++++++++++-
.../components/Sidebar/leftMenusData.js | 36 +++++++++++
src/permission.js | 47 --------------
src/router/index.js | 63 ++++++++++++++++---
src/views/usermanage/index.vue | 1 +
6 files changed, 143 insertions(+), 61 deletions(-)
create mode 100644 src/layout/components/Sidebar/leftMenusData.js
diff --git a/src/layout/components/Sidebar/SidebarItem.vue b/src/layout/components/Sidebar/SidebarItem.vue
index ec4b83f..c172638 100644
--- a/src/layout/components/Sidebar/SidebarItem.vue
+++ b/src/layout/components/Sidebar/SidebarItem.vue
@@ -1,13 +1,15 @@
+
+
-
+
@@ -50,7 +52,6 @@ export default {
}
},
// mounted: function () {
-// console.log(222);
// },
data() {
// To fix https://github.com/PanJiaChen/vue-admin-template/issues/237
diff --git a/src/layout/components/Sidebar/index.vue b/src/layout/components/Sidebar/index.vue
index c73b3ea..ec80862 100644
--- a/src/layout/components/Sidebar/index.vue
+++ b/src/layout/components/Sidebar/index.vue
@@ -15,23 +15,37 @@
+
diff --git a/src/layout/components/Sidebar/leftMenusData.js b/src/layout/components/Sidebar/leftMenusData.js
new file mode 100644
index 0000000..3144a76
--- /dev/null
+++ b/src/layout/components/Sidebar/leftMenusData.js
@@ -0,0 +1,36 @@
+
+// 菜单栏生成
+let menusdata = [
+ {
+ id: '0',
+ path: '/filemange',
+
+ meta: { title: '文件管理', icon: 'dashboard' },
+ children:[]
+ },
+ {
+ path: '/usermange',
+ meta: { title: '用户管理', icon: 'dashboard' }
+
+ },
+ {
+ path: '/systme',
+ meta: { title: '系统管理', icon: 'dashboard' },
+ children: [
+ {
+ path: 'changepass',
+ meta: { title: '修改密码', icon: 'table' }
+ },
+ {
+ path: 'userrelated',
+ meta: { title: '用户相关', icon: 'tree' }
+ },
+ {
+ path: 'userrelated2',
+ meta: { title: '皮肤更换', icon: 'tree' }
+ }
+ ]
+ },
+]
+
+export default menusdata
\ No newline at end of file
diff --git a/src/permission.js b/src/permission.js
index 36536ad..e9252da 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -11,53 +11,6 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration
const whiteList = ['/login'] // no redirect whitelist
-// 动态添加路由
-import { mirlist } from '@/api/user'
-mirlist().then(response => {
- let datamain = response.data;
- routesData(datamain.data.menus);
- //console.log(response);
-}).catch(function (error) {
- Message({
- showClose: true,
- message: error,
- type: 'error'
- });
-});
-
-function routesData(data) {
- // 重新加载一次 VueRouter
- //router.reloadRouter()
- let currentMenu = [
- {
- path: '/',
- component: () => import('@/views/systme/changepass'),
- children: []
- }
- ]
- console.log(router);
- data.forEach(item => {
- console.log(item);
- const temp = {
- name: item.directory,
- path: item.directory,
- component: () => import(`../page/${item.path}/${firstUppercase(i.path)}.vue`)
- }
- // 动态添加为 filemange 的子路由
- router.addRoutes(currentMenu)
- // item.children.forEach(i => {
- // // 组装路由配置
- // const temp = {
- // name: i.path,
- // path: i.path,
- // component: () => import(`../page/${item.path}/${firstUppercase(i.path)}.vue`)
- // }
- // // 动态添加为 filemange 的子路由
- // router.addRoute("filemange", temp)
- // })
- })
-}
-
router.beforeEach(async(to, from, next) => {
// start progress bar
NProgress.start()
diff --git a/src/router/index.js b/src/router/index.js
index 6a91d71..4f5e2d9 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -30,6 +30,7 @@ import Layout from '@/layout'
* all roles can be accessed
*/
+
export const constantRoutes = [
{
path: '/login',
@@ -45,9 +46,7 @@ export const constantRoutes = [
{
path: '/',
component: Layout,
- redirect: '/filemange', // 重定向地址
name: 'filemange',
- alwaysShow: false,
meta: { title: '文件管理', icon: 'el-icon-s-help' },
children: [
{
@@ -56,14 +55,11 @@ export const constantRoutes = [
component: () => import('@/views/filemange/index'),
meta: { title: '文件管理', icon: 'dashboard' }
}
-
-
]
},
{
path: '',
component: Layout,
- redirect: '/usermange',
children: [{
path: 'usermange',
name: 'Usermange',
@@ -71,6 +67,16 @@ export const constantRoutes = [
meta: { title: '用户管理', icon: 'dashboard' }
}]
},
+ // {
+ // path: '/',
+ // component: Layout,
+ // children: [{
+ // path: 'filemangeff',
+ // name: 'filemangeff',
+ // component: () => import('@/views/usermanage/index'),
+ // meta: { title: 'text', icon: 'dashboard' }
+ // }]
+ // },
{
path: '/systme',
component: Layout,
@@ -113,13 +119,52 @@ export const constantRoutes = [
{ path: '*', redirect: '/404', hidden: true }
]
-const createRouter = () => new Router({
+const createRouter = (a) => new Router({
//mode: 'history', // require service support
- scrollBehavior: () => ({ y: 0 }),
- routes: constantRoutes
+ scrollBehavior: () => ({ y: 0 }),
+ routes: a
})
-const router = createRouter()
+//let router
+const router = createRouter(constantRoutes)
+// 动态添加路由
+// import { mirlist } from '@/api/user'
+// let pachs = () => import('@/views/filemange/index');
+// mirlist().then(response => {
+// let datamain = response.data;
+// //routesData(datamain.data.menus);
+// //console.log(response);
+// datamain.data.menus.forEach(item => {
+// menus.push(
+// {
+// path: item.directory,
+// name: item.directory,
+// component: pachs,
+// meta: { title: item.directory, icon: 'dashboard' }
+// }
+// );
+// });
+// //console.log(menus);
+// //router = createRouter(constantRoutes)
+// console.log(router.options);
+// router = createRouter(constantRoutes)
+// // {
+// // path: 'filemange',
+// // name: 'Filemange',
+// // component: () => import('@/views/filemange/index'),
+// // meta: { title: '文件管理', icon: 'dashboard' }
+// // }
+
+// }).catch(function (error) {
+// Message({
+// showClose: true,
+// message: error,
+// type: 'error'
+// });
+// });
+//router = createRouter(constantRoutes)
+//router.addRoutes(constantRoutes);
+
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
diff --git a/src/views/usermanage/index.vue b/src/views/usermanage/index.vue
index 729237b..55217b1 100644
--- a/src/views/usermanage/index.vue
+++ b/src/views/usermanage/index.vue
@@ -44,6 +44,7 @@