Skip to content

Commit

Permalink
perf: add uniqueopened setting
Browse files Browse the repository at this point in the history
  • Loading branch information
kailong502431556 committed Apr 14, 2022
1 parent 7dc6d8a commit b060319
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/components/Menu/src/Menu.vue
Expand Up @@ -47,6 +47,8 @@ export default defineComponent({
const collapse = computed(() => appStore.getCollapse)
const uniqueOpened = computed(() => appStore.getUniqueOpened)
const activeMenu = computed(() => {
const { meta, path } = unref(currentRoute)
// if set path, the sidebar will highlight the path you set
Expand Down Expand Up @@ -87,6 +89,7 @@ export default defineComponent({
collapse={
unref(layout) === 'top' || unref(layout) === 'cutMenu' ? false : unref(collapse)
}
uniqueOpened={unref(layout) === 'top' ? false : unref(uniqueOpened)}
backgroundColor="var(--left-menu-bg-color)"
textColor="var(--left-menu-text-color)"
activeTextColor="var(--left-menu-text-active-color)"
Expand Down
2 changes: 2 additions & 0 deletions src/components/Setting/src/Setting.vue
Expand Up @@ -130,6 +130,8 @@ const copyConfig = async () => {
tagsView: ${appStore.getTagsView},
// logo
logo: ${appStore.getLogo},
// 菜单手风琴
uniqueOpened: ${appStore.getUniqueOpened},
// 固定header
fixedHeader: ${appStore.getFixedHeader},
// 页脚
Expand Down
12 changes: 12 additions & 0 deletions src/components/Setting/src/components/InterfaceDisplay.vue
Expand Up @@ -72,6 +72,13 @@ const logoChange = (show: boolean) => {
appStore.setLogo(show)
}
// 菜单手风琴
const uniqueOpened = ref(appStore.getUniqueOpened)
const uniqueOpenedChange = (uniqueOpened: boolean) => {
appStore.setUniqueOpened(uniqueOpened)
}
// 固定头部
const fixedHeader = ref(appStore.getFixedHeader)
Expand Down Expand Up @@ -147,6 +154,11 @@ watch(
<ElSwitch v-model="logo" @change="logoChange" />
</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">
<span class="text-14px">{{ t('setting.fixedHeader') }}</span>
<ElSwitch v-model="fixedHeader" @change="fixedHeaderChange" />
Expand Down
2 changes: 2 additions & 0 deletions src/config/app.ts
Expand Up @@ -24,6 +24,7 @@ export interface AppState {
breadcrumb: boolean
breadcrumbIcon: boolean
collapse: boolean
uniqueOpened: boolean
hamburger: boolean
screenfull: boolean
size: boolean
Expand Down Expand Up @@ -54,6 +55,7 @@ export const appModules: AppState = {
breadcrumb: true, // 面包屑
breadcrumbIcon: true, // 面包屑图标
collapse: false, // 折叠菜单
uniqueOpened: false, // 是否只保持一个子菜单的展开
hamburger: true, // 折叠图标
screenfull: true, // 全屏图标
size: true, // 尺寸图标
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.ts
Expand Up @@ -72,7 +72,8 @@ export default {
clearAndReset: 'Clear cache and reset',
copySuccess: 'Copy success',
copyFailed: 'Copy failed',
footer: 'Footer'
footer: 'Footer',
uniqueOpened: 'Unique opened'
},
size: {
default: 'Default',
Expand Down
3 changes: 2 additions & 1 deletion src/locales/zh-CN.ts
Expand Up @@ -72,7 +72,8 @@ export default {
clearAndReset: '清除缓存并且重置',
copySuccess: '拷贝成功',
copyFailed: '拷贝失败',
footer: '页脚'
footer: '页脚',
uniqueOpened: '菜单手风琴'
},
size: {
default: '默认',
Expand Down
6 changes: 6 additions & 0 deletions src/store/modules/app.ts
Expand Up @@ -24,6 +24,9 @@ export const useAppStore = defineStore({
getCollapse(): boolean {
return this.collapse
},
getUniqueOpened(): boolean {
return this.uniqueOpened
},
getHamburger(): boolean {
return this.hamburger
},
Expand Down Expand Up @@ -89,6 +92,9 @@ export const useAppStore = defineStore({
setCollapse(collapse: boolean) {
this.collapse = collapse
},
setUniqueOpened(uniqueOpened: boolean) {
this.uniqueOpened = uniqueOpened
},
setHamburger(hamburger: boolean) {
this.hamburger = hamburger
},
Expand Down

0 comments on commit b060319

Please sign in to comment.