vueComponent / ant-design-vue

🌈 An enterprise-class UI components based on Ant Design and Vue. 🐜
https://antdv.com/
Other
20.14k stars 3.78k forks source link

Menu 在折叠后会失去 openkeys #7651

Closed hdtopku closed 1 month ago

hdtopku commented 3 months ago

Version

4.2.3

Environment

macos chrome vue3

Reproduction link

https://github.com/hdtopku/tiny-admin/blob/main/tiny-admin-vue/src/layout/Sidebar.vue

这是关键代码

<template>
  <a-menu v-model:selected-keys="useMenuStore().selectedKeys"
          v-model:open-keys="useMenuStore().openKeys"
          @click="handleClick" :items="menus" class="overflow-auto h-full "
          theme="dark" mode="inline">

  </a-menu>
</template>
<script lang="ts" setup>
import {useMenuStore, useUserStore} from "@/store/index.ts";
import router from "@/router";
const menus = useUserStore().getSidebar()
const handleClick = ({key}) => {
  router.push(key)
}
</script>

Steps to reproduce

1、将 openkeys 存在 pinia 中,并用pinia-plugin-persistedstate插件持久化到 LocalStorage 中 2、折叠菜单,再打开菜单 3、点击任意菜单,菜单全部收缩了

这是复现 gif,仔细看控制台 openKey,原先是["/system"],点击折叠按钮后,变为了[]: Kapture 2024-06-13 at 22 04 05

What is expected?

折叠后再打开,openkeys 不应该为空 list

What is actually happening?

折叠后再打开,openkeys变成空了

hdtopku commented 3 months ago

看到示例中你们用preOpenKeys,是不是暂时需要这么处理?

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days