Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 菜单栏新增根据路径匹配到根菜单进行展开功能 #11

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:options="props.menus"
:collapsed="isSideBarCollapse"
@select="onMenuClick"
:expandedKeys="expandedKeys"
></FMenu>
</div>
<div class="collapse-btn" @click="toggleSideBar">
Expand All @@ -27,7 +28,7 @@
</div>
</template>
<script setup lang="ts">
import { defineProps, defineEmits, ref, computed, useSlots } from 'vue';
import { defineProps, defineEmits, ref, computed, useSlots, watchEffect } from 'vue';
import { FMenu } from '@fesjs/fes-design';
import { RightOutlined, LeftOutlined } from '@fesjs/fes-design/icon';

Expand Down Expand Up @@ -80,6 +81,16 @@ const toggleSideBar = () => {
isSideBarCollapse.value = !isSideBarCollapse.value;
};

const expandedKeys = ref<string[]>([]);
watchEffect(() => {
if(curPath.value) {
// 如/train/workflow,匹配到根路径,展开/train菜单
const regex = /^\/\w+/;
const match = curPath.value.match(regex);
if (match) expandedKeys.value = [match[0]];
}
})

</script>

<script lang="ts">
Expand Down
Loading