GuoYuFu123 5 years ago
parent
commit
aa4d835235

+ 11 - 9
src/framework/layout/Main.vue

@@ -39,13 +39,14 @@ export default {
     props: [],
     data() {
         return {
+            isPath:  false
         }
     },
     computed: {
         ...mapGetters('layout', ['sidebarClosed', 'breadcrumb'])
     },
     methods: {
-        ...mapMutations('layout', ['setSidebarClosed']),
+        ...mapMutations('layout', ['setSidebarClosed','setSidebarSelected']),
         windwoResize() {
             // 窗口大小发生变化时
             let clientWidth = `${document.documentElement.clientWidth}`
@@ -60,24 +61,25 @@ export default {
             }
         },
         findPathInArray(arr, path) {
-            console.log()
             arr.forEach(ele => {
                 if(ele.path == path) {
-                    return true
+                    this.isPath = true
                 }
                 if(ele.children) {
-                    return this.findPathInArray(ele.children, path)
+                   this.findPathInArray(ele.children, path)
                 }
             })
         }
     },
     watch: {
-        $route: {
+        "$route": {
             handler: function(route, oldVal){
-                console.log('**************************')
-                console.log(menus)
-                console.log(route.path,'guoguo');
-                console.log(this.findPathInArray(menus,route.path))
+                let path = route.path
+                this.isPath = false;
+                this.findPathInArray(menus,path)
+                if(this.isPath) {
+                    this.setSidebarSelected(path)
+                }
             },
             // 深度观察监听
             deep: true

+ 2 - 1
src/framework/layout/PageSidebar.vue

@@ -1,5 +1,6 @@
 <template>
     <div id='page-sidebar-wrapper' class='page-sidebar-wrapper'>
+        {{sidebarSelected}}
         <el-menu
             :collapse='sidebarClosed'
             :default-active='sidebarSelected'
@@ -62,7 +63,7 @@ export default {
         },
         menuSelect(index, indexPath) {
             this.setSidebarSelected(index)
-            console.log('menu select ', index, indexPath)
+            // console.log('menu select ', index, indexPath)
         }
     },
     created() {

+ 9 - 8
src/framework/layout/layout-store.js

@@ -19,13 +19,14 @@ export default {
     getters: {
         sidebarClosed: state => state.sidebarClosed,
         sidebarSelected: state => {
-            if (!state.pageSidebarSelected) {
-                let menu = storage.get(KEY_MENU_SELECTED)
-                if (menu) {
-                    state.pageSidebarSelected = menu
-                }
-            }
-            return state.pageSidebarSelected
+            // if (!state.pageSidebarSelected) {
+            //     let menu = storage.get(KEY_MENU_SELECTED)
+            //     if (menu) {
+            //         state.pageSidebarSelected = menu
+            //     }
+            // }
+            // return state.pageSidebarSelected
+            return state.sidebarSelected
         },
         userInfo: state => state.userInfo,
         permissions: state => state.permissions,
@@ -64,7 +65,7 @@ export default {
         loadUserInfo({ state }) {
             return new Promise((resolve, reject) => {
                 frameworkApi.loadUserInfo().then(resp => {
-                    console.log('api load user info ', resp)
+                    // console.log('api load user info ', resp)
                     if (resp.result == 'success') {
                         state.userInfo = { username: resp.username }
                         state.permissions = {}

+ 1 - 1
src/framework/template/TablePageTemplate.vue

@@ -22,7 +22,7 @@ export default {
     computed: {},
     methods: {},
     created() {
-        console.log('--------------------- TablePageTemplate created')
+        // console.log('--------------------- TablePageTemplate created')
     },
     mounted() {},
     components: {}