Skip to content

Commit

Permalink
feat: add setting menuAutoCollapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
RSS1102 committed Aug 18, 2024
1 parent abe1c39 commit b7c3f06
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/config/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
showFooter: true,
isSidebarCompact: false,
showBreadcrumb: false,
menuAutoCollapsed: false,
mode: 'light',
layout: 'side',
splitMenu: false,
Expand Down
4 changes: 3 additions & 1 deletion src/layouts/components/SideNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:value="active"
:collapsed="collapsed"
:expanded="expanded"
:expand-mutex="menuAutoCollapsed"
@expand="onExpanded"
>
<template #logo>
Expand Down Expand Up @@ -73,6 +74,7 @@ const props = defineProps({
});
const collapsed = computed(() => useSettingStore().isSidebarCompact);
const menuAutoCollapsed = computed(() => useSettingStore().menuAutoCollapsed);
const active = computed(() => getActive());
Expand All @@ -83,7 +85,7 @@ watch(
() => {
const path = getActive();
const parentPath = path.substring(0, path.lastIndexOf('/'));
expanded.value = union([parentPath], expanded.value);
expanded.value = menuAutoCollapsed.value ? [parentPath] : union([parentPath], expanded.value);
},
);
Expand Down
3 changes: 3 additions & 0 deletions src/layouts/setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
<t-form-item :label="$t('layout.setting.element.useTagTabs')" name="isUseTabsRouter">
<t-switch v-model="formData.isUseTabsRouter"></t-switch>
</t-form-item>
<t-form-item :label="$t('layout.setting.element.menuAutoCollapsed')" name="menuAutoCollapsed">
<t-switch v-model="formData.menuAutoCollapsed"></t-switch>
</t-form-item>
</t-form>
<div class="setting-info">
<p>{{ $t('layout.setting.tips') }}</p>
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/en_US/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default {
showBreadcrumb: 'Show Breadcrumb',
showFooter: 'Show Footer',
useTagTabs: 'Use Tag Tabs',
menuAutoCollapsed: 'Menu Auto Collapsed',
},
tips: 'Please copy and manually modify the configuration file: /src/config/style.ts',
copy: {
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/zh_CN/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default {
showBreadcrumb: '显示面包屑',
showFooter: '显示页脚',
useTagTabs: '展示多标签Tab页',
menuAutoCollapsed: '菜单自动折叠',
},
tips: '请复制后手动修改配置文件: /src/config/style.ts',
copy: {
Expand Down

0 comments on commit b7c3f06

Please sign in to comment.