Kaynağa Gözat

菜单修改后,增加更改前端页面标题。

zhengqiang 4 yıl önce
ebeveyn
işleme
1e953f0d15

+ 1 - 1
src/components/MenuTreeItem/index.vue

@@ -4,7 +4,7 @@
     <el-scrollbar style="height:100%">
     <template v-for="item in routes">
       <template v-if="item.children==null || item.children.length==0">     
-        <el-menu-item :index="item.menuUrl" :key="item.id">
+        <el-menu-item :index="item.menuUrl + ',' + item.menuName" :key="item.id">
             <i :class="item.icon"></i>
           <span>{{item.menuName}}</span>
         </el-menu-item>

+ 1 - 1
src/routers/modules/base.js

@@ -628,7 +628,7 @@ var routers = [
                 component: () => import('@/views/base/personApplication-list.vue'),
                 meta: {
                         roles: ["admin"],
-                        title: '审批人员管理'
+                        title: '注册人员管理'
                 }
         },
 ]

+ 14 - 7
src/store/modules/tagsView.js

@@ -1,24 +1,29 @@
 const state = {
   visitedViews: [],
-  cachedViews: []
+  cachedViews: [],
+  menuDict: {}
 }
 
 const mutations = {
+  SELECT_MENU: (state,menu)=> {
+    state.menuDict[menu.url] = menu.title;
+  },
   ADD_VISITED_VIEW: (state, view) => {
     console.log("ADD_VISITED_VIEW");
     console.log(view.path);
+    console.log(state.menuDict[view.path] );
 
     if (state.visitedViews.some(v => v.path === view.path)) return
 
-    var newView =  Object.assign({}, view, {
-      title: view.meta.title || 'no-name'
-    });
+    // var newView =  Object.assign({}, view, {
+    //   title: state.menuDict[view.path] || view.meta.title || 'no-name'
+    // });
 
-    console.log(newView);
+    // console.log(newView);
 
     state.visitedViews.push({
       path : view.path,
-      title: view.meta.title || 'no-name',
+      title: state.menuDict[view.path] || view.meta.title || 'no-name',
       meta: view.meta,
       name: view.name,
       fullPath: view.fullPath
@@ -84,6 +89,9 @@ const mutations = {
 }
 
 const actions = {
+  selectMenu({commit},menu) {
+    commit('SELECT_MENU', menu)
+  },
   addView({ dispatch }, view) {
     console.log("addView");
 
@@ -96,7 +104,6 @@ const actions = {
   addCachedView({ commit }, view) {
     commit('ADD_CACHED_VIEW', view)
   },
-
   delView({ dispatch, state }, view) {
     return new Promise(resolve => {
       dispatch('delVisitedView', view)

+ 4 - 3
src/views/layout/TagsView/index.vue

@@ -82,7 +82,7 @@ export default {
             path: tagPath,
             name: route.name,
             meta: { ...route.meta }
-          })
+          }) 
         }
         if (route.children) {
           const tempTags = this.filterAffixTags(route.children, route.path)
@@ -103,9 +103,10 @@ export default {
       }
     },
     addTags() {
-      console.log("addTags");
+      const { name,meta } = this.$route
 
-      const { name } = this.$route
+      console.log("addTags:" + name + "," + meta.title);
+      
       if (name) {
         this.$store.dispatch('tagsView/addView', this.$route)
       }

+ 10 - 2
src/views/layout/index.vue

@@ -173,8 +173,16 @@ export default {
       console.log(key, keyPath);
     },
     handleSelect(key, keyPath) {
-      //console.log(key, keyPath);
-      this.$router.push({ path: key });
+      //console.log("select:", key, keyPath);
+      var arr = key.split(",");
+
+      //在store保存
+      this.$store.dispatch('tagsView/selectMenu', {
+        url: arr[0],
+        title: arr[1]
+      })
+
+      this.$router.push({ path: arr[0]});
     },
     logout() {
       this.$store.dispatch("user/logout").then(() => {