perf: add uniqueopened setting

This commit is contained in:
陈凯龙 2022-04-14 09:25:10 +08:00
parent 7dc6d8a9d7
commit b0603199a5
7 changed files with 29 additions and 2 deletions

View File

@ -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)"

View File

@ -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},
// //

View File

@ -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" />

View File

@ -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, // 尺寸图标

View File

@ -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',

View File

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

View File

@ -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
}, },