ant-design-vue icon indicating copy to clipboard operation
ant-design-vue copied to clipboard

Menu 在折叠后会失去 openkeys

Open hdtopku opened this issue 1 year ago • 1 comments
trafficstars

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

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 avatar Jun 13 '24 21:06 hdtopku

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

hdtopku avatar Jun 13 '24 22:06 hdtopku

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

github-actions[bot] avatar Aug 13 '24 02:08 github-actions[bot]