mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	perf: tag demo
This commit is contained in:
		
							parent
							
								
									c65940f5ef
								
							
						
					
					
						commit
						378feceb5f
					
				@ -28,5 +28,5 @@ export function useDetail() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return { toDetail, initToDetail, id };
 | 
					  return { toDetail, initToDetail, id, router };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@ import {
 | 
				
			|||||||
  getNodeByUniqueId
 | 
					  getNodeByUniqueId
 | 
				
			||||||
} from "/@/utils/tree";
 | 
					} from "/@/utils/tree";
 | 
				
			||||||
import { useDetail } from "./hooks";
 | 
					import { useDetail } from "./hooks";
 | 
				
			||||||
const { toDetail } = useDetail();
 | 
					const { toDetail, router } = useDetail();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let treeData = computed(() => {
 | 
					let treeData = computed(() => {
 | 
				
			||||||
  return appendFieldByUniqueId(
 | 
					  return appendFieldByUniqueId(
 | 
				
			||||||
@ -22,12 +22,20 @@ let treeData = computed(() => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const value = ref<string[]>([]);
 | 
					const value = ref<string[]>([]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let multiTags = computed(() => {
 | 
				
			||||||
 | 
					  return useMultiTagsStoreHook()?.multiTags;
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function onCloseTags() {
 | 
					function onCloseTags() {
 | 
				
			||||||
  value.value.forEach(uniqueId => {
 | 
					  value.value.forEach(uniqueId => {
 | 
				
			||||||
    let currentPath =
 | 
					    let currentPath =
 | 
				
			||||||
      getNodeByUniqueId(treeData.value, uniqueId).redirect ??
 | 
					      getNodeByUniqueId(treeData.value, uniqueId).redirect ??
 | 
				
			||||||
      getNodeByUniqueId(treeData.value, uniqueId).path;
 | 
					      getNodeByUniqueId(treeData.value, uniqueId).path;
 | 
				
			||||||
    useMultiTagsStoreHook().handleTags("splice", currentPath);
 | 
					    useMultiTagsStoreHook().handleTags("splice", currentPath);
 | 
				
			||||||
 | 
					    if (currentPath === "/tabs/index")
 | 
				
			||||||
 | 
					      router.push({
 | 
				
			||||||
 | 
					        path: multiTags.value[multiTags.value.length - 1].path
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
@ -68,5 +76,17 @@ function onCloseTags() {
 | 
				
			|||||||
      </template>
 | 
					      </template>
 | 
				
			||||||
    </TreeSelect>
 | 
					    </TreeSelect>
 | 
				
			||||||
    <el-button class="ml-2" @click="onCloseTags">关闭标签</el-button>
 | 
					    <el-button class="ml-2" @click="onCloseTags">关闭标签</el-button>
 | 
				
			||||||
 | 
					    <br />
 | 
				
			||||||
 | 
					    <p class="mt-4">
 | 
				
			||||||
 | 
					      注意:此demo并未开启标签页缓存,如果需要在
 | 
				
			||||||
 | 
					      <span class="text-red-500">刷新页面</span>
 | 
				
			||||||
 | 
					      的时候同时
 | 
				
			||||||
 | 
					      <span class="text-red-500">保留标签页的显示</span>
 | 
				
			||||||
 | 
					      或者
 | 
				
			||||||
 | 
					      <span class="text-red-500">保留url的参数</span>
 | 
				
			||||||
 | 
					      ,那么就需要开启标签页持久化。
 | 
				
			||||||
 | 
					      <br />
 | 
				
			||||||
 | 
					      开启方式:在页面最右上角有个设置的小图标,点进去,会看到项目配置面板,找到标签页持久化开启即可。
 | 
				
			||||||
 | 
					    </p>
 | 
				
			||||||
  </el-card>
 | 
					  </el-card>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user