Преглед изворни кода

feat(设备管理): 添加设备列表页的keep-alive缓存支持

yusheng пре 5 месеци
родитељ
комит
4185a016a1

+ 2 - 1
src/components/RouterLayout/index.vue

@@ -8,11 +8,12 @@
 </template>
 </template>
 
 
 <script>
 <script>
+  import { KEEP_ALIVE_INCLUDE } from '@/config/setting';
   export default {
   export default {
     name: 'RouterLayout',
     name: 'RouterLayout',
     computed: {
     computed: {
       include() {
       include() {
-        return this.$store.getters['theme/keepAliveInclude'] ?? [];
+        return KEEP_ALIVE_INCLUDE;
       },
       },
       transitionName() {
       transitionName() {
         return this.$store.state.theme.transitionName;
         return this.$store.state.theme.transitionName;

+ 4 - 1
src/config/setting.js

@@ -22,7 +22,10 @@ export const WHITE_LIST = ['/login', '/forget'];
 
 
 // 开启 KeepAlive 后仍然不需要缓存的路由地址
 // 开启 KeepAlive 后仍然不需要缓存的路由地址
 export const KEEP_ALIVE_EXCLUDES = [];
 export const KEEP_ALIVE_EXCLUDES = [];
-
+// 开启 KeepAlive 后需要缓存的路由地址
+export const KEEP_ALIVE_INCLUDE = [
+ 'equipmentIndex'
+];
 // 直接指定菜单数据
 // 直接指定菜单数据
 export const USER_MENUS = undefined;
 export const USER_MENUS = undefined;
 // [
 // [

+ 9 - 0
src/views/ledgerAssets/equipment/index.vue

@@ -36,6 +36,7 @@
   import AssetTree from '@/components/AssetTree';
   import AssetTree from '@/components/AssetTree';
   import EquipmentList from './components/equipment-list.vue';
   import EquipmentList from './components/equipment-list.vue';
   export default {
   export default {
+    name: 'equipmentIndex',
     components: {
     components: {
       AssetTree,
       AssetTree,
       EquipmentList
       EquipmentList
@@ -51,6 +52,7 @@
       };
       };
     },
     },
     computed: {},
     computed: {},
+
     methods: {
     methods: {
       handleNodeClick(info) {
       handleNodeClick(info) {
         console.log(info);
         console.log(info);
@@ -64,6 +66,13 @@
       setRootId(id) {
       setRootId(id) {
         this.rootId = id;
         this.rootId = id;
       }
       }
+    },
+    activated() {
+      this.$nextTick(() => {
+        if (this.current.id) {
+          this.$refs.listRef.sucesstion(true);
+        }
+      });
     }
     }
   };
   };
 </script>
 </script>