浏览代码

perf: add uniqueopened setting

陈凯龙 3 年之前
父节点
当前提交
b0603199a5

+ 3 - 0
src/components/Menu/src/Menu.vue

@@ -47,6 +47,8 @@ export default defineComponent({
 
 
     const collapse = computed(() => appStore.getCollapse)
     const collapse = computed(() => appStore.getCollapse)
 
 
+    const uniqueOpened = computed(() => appStore.getUniqueOpened)
+
     const activeMenu = computed(() => {
     const activeMenu = computed(() => {
       const { meta, path } = unref(currentRoute)
       const { meta, path } = unref(currentRoute)
       // if set path, the sidebar will highlight the path you set
       // if set path, the sidebar will highlight the path you set
@@ -87,6 +89,7 @@ export default defineComponent({
             collapse={
             collapse={
               unref(layout) === 'top' || unref(layout) === 'cutMenu' ? false : unref(collapse)
               unref(layout) === 'top' || unref(layout) === 'cutMenu' ? false : unref(collapse)
             }
             }
+            uniqueOpened={unref(layout) === 'top' ? false : unref(uniqueOpened)}
             backgroundColor="var(--left-menu-bg-color)"
             backgroundColor="var(--left-menu-bg-color)"
             textColor="var(--left-menu-text-color)"
             textColor="var(--left-menu-text-color)"
             activeTextColor="var(--left-menu-text-active-color)"
             activeTextColor="var(--left-menu-text-active-color)"

+ 2 - 0
src/components/Setting/src/Setting.vue

@@ -130,6 +130,8 @@ const copyConfig = async () => {
       tagsView: ${appStore.getTagsView},
       tagsView: ${appStore.getTagsView},
       // logo
       // logo
       logo: ${appStore.getLogo},
       logo: ${appStore.getLogo},
+      // 菜单手风琴
+      uniqueOpened: ${appStore.getUniqueOpened},
       // 固定header
       // 固定header
       fixedHeader: ${appStore.getFixedHeader},
       fixedHeader: ${appStore.getFixedHeader},
       // 页脚
       // 页脚

+ 12 - 0
src/components/Setting/src/components/InterfaceDisplay.vue

@@ -72,6 +72,13 @@ const logoChange = (show: boolean) => {
   appStore.setLogo(show)
   appStore.setLogo(show)
 }
 }
 
 
+// 菜单手风琴
+const uniqueOpened = ref(appStore.getUniqueOpened)
+
+const uniqueOpenedChange = (uniqueOpened: boolean) => {
+  appStore.setUniqueOpened(uniqueOpened)
+}
+
 // 固定头部
 // 固定头部
 const fixedHeader = ref(appStore.getFixedHeader)
 const fixedHeader = ref(appStore.getFixedHeader)
 
 
@@ -147,6 +154,11 @@ watch(
       <ElSwitch v-model="logo" @change="logoChange" />
       <ElSwitch v-model="logo" @change="logoChange" />
     </div>
     </div>
 
 
+    <div class="flex justify-between items-center">
+      <span class="text-14px">{{ t('setting.uniqueOpened') }}</span>
+      <ElSwitch v-model="uniqueOpened" @change="uniqueOpenedChange" />
+    </div>
+
     <div class="flex justify-between items-center">
     <div class="flex justify-between items-center">
       <span class="text-14px">{{ t('setting.fixedHeader') }}</span>
       <span class="text-14px">{{ t('setting.fixedHeader') }}</span>
       <ElSwitch v-model="fixedHeader" @change="fixedHeaderChange" />
       <ElSwitch v-model="fixedHeader" @change="fixedHeaderChange" />

+ 2 - 0
src/config/app.ts

@@ -24,6 +24,7 @@ export interface AppState {
   breadcrumb: boolean
   breadcrumb: boolean
   breadcrumbIcon: boolean
   breadcrumbIcon: boolean
   collapse: boolean
   collapse: boolean
+  uniqueOpened: boolean
   hamburger: boolean
   hamburger: boolean
   screenfull: boolean
   screenfull: boolean
   size: boolean
   size: boolean
@@ -54,6 +55,7 @@ export const appModules: AppState = {
   breadcrumb: true, // 面包屑
   breadcrumb: true, // 面包屑
   breadcrumbIcon: true, // 面包屑图标
   breadcrumbIcon: true, // 面包屑图标
   collapse: false, // 折叠菜单
   collapse: false, // 折叠菜单
+  uniqueOpened: false, // 是否只保持一个子菜单的展开
   hamburger: true, // 折叠图标
   hamburger: true, // 折叠图标
   screenfull: true, // 全屏图标
   screenfull: true, // 全屏图标
   size: true, // 尺寸图标
   size: true, // 尺寸图标

+ 2 - 1
src/locales/en.ts

@@ -72,7 +72,8 @@ export default {
     clearAndReset: 'Clear cache and reset',
     clearAndReset: 'Clear cache and reset',
     copySuccess: 'Copy success',
     copySuccess: 'Copy success',
     copyFailed: 'Copy failed',
     copyFailed: 'Copy failed',
-    footer: 'Footer'
+    footer: 'Footer',
+    uniqueOpened: 'Unique opened'
   },
   },
   size: {
   size: {
     default: 'Default',
     default: 'Default',

+ 2 - 1
src/locales/zh-CN.ts

@@ -72,7 +72,8 @@ export default {
     clearAndReset: '清除缓存并且重置',
     clearAndReset: '清除缓存并且重置',
     copySuccess: '拷贝成功',
     copySuccess: '拷贝成功',
     copyFailed: '拷贝失败',
     copyFailed: '拷贝失败',
-    footer: '页脚'
+    footer: '页脚',
+    uniqueOpened: '菜单手风琴'
   },
   },
   size: {
   size: {
     default: '默认',
     default: '默认',

+ 6 - 0
src/store/modules/app.ts

@@ -24,6 +24,9 @@ export const useAppStore = defineStore({
     getCollapse(): boolean {
     getCollapse(): boolean {
       return this.collapse
       return this.collapse
     },
     },
+    getUniqueOpened(): boolean {
+      return this.uniqueOpened
+    },
     getHamburger(): boolean {
     getHamburger(): boolean {
       return this.hamburger
       return this.hamburger
     },
     },
@@ -89,6 +92,9 @@ export const useAppStore = defineStore({
     setCollapse(collapse: boolean) {
     setCollapse(collapse: boolean) {
       this.collapse = collapse
       this.collapse = collapse
     },
     },
+    setUniqueOpened(uniqueOpened: boolean) {
+      this.uniqueOpened = uniqueOpened
+    },
     setHamburger(hamburger: boolean) {
     setHamburger(hamburger: boolean) {
       this.hamburger = hamburger
       this.hamburger = hamburger
     },
     },