Skip to content

Commit

Permalink
Merge pull request #236 from WuWenL0/patch-1
Browse files Browse the repository at this point in the history
feat: add top menu layout config
  • Loading branch information
sHow8e authored Jan 10, 2023
2 parents 1bb4a4f + 3231431 commit 3fe0f52
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions arco-design-pro-vite/src/components/global-setting/block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
if (key === 'menuFromServer' && value) {
await appStore.fetchServerMenuConfig();
}
if (key === 'topMenu') {
appStore.updateSettings({
menuCollapse: false,
});
}
appStore.updateSettings({ [key]: value });
};
</script>
Expand Down
5 changes: 5 additions & 0 deletions arco-design-pro-vite/src/components/global-setting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
key: 'menu',
defaultVal: appStore.menu,
},
{
name: 'settings.topMenu',
key: 'topMenu',
defaultVal: appStore.topMenu,
},
{ name: 'settings.footer', key: 'footer', defaultVal: appStore.footer },
{ name: 'settings.tabBar', key: 'tabBar', defaultVal: appStore.tabBar },
{
Expand Down
4 changes: 3 additions & 1 deletion arco-design-pro-vite/src/components/menu/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
});
const topMenu = computed(() => appStore.topMenu);
const openKeys = ref<string[]>([]);
const selectedKey = ref<string[]>([]);
Expand Down Expand Up @@ -126,14 +127,15 @@
return () => (
<a-menu
mode={topMenu.value ? 'horizontal' : 'vertical'}
v-model:collapsed={collapsed.value}
v-model:open-keys={openKeys.value}
show-collapse-button={appStore.device !== 'mobile'}
auto-open={false}
selected-keys={selectedKey.value}
auto-open-selected={true}
level-indent={34}
style="height: 100%"
style="height: 100%;width:100%;"
onCollapse={setCollapse}
>
{renderSubMenu()}
Expand Down
11 changes: 10 additions & 1 deletion arco-design-pro-vite/src/components/navbar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
Arco Pro
</a-typography-title>
<icon-menu-fold
v-if="appStore.device === 'mobile'"
v-if="!topMenu && appStore.device === 'mobile'"
style="font-size: 22px; cursor: pointer"
@click="toggleDrawerMenu"
/>
</a-space>
</div>
<div class="center-side">
<Menu v-if="topMenu" />
</div>
<ul class="right-side">
<li>
<a-tooltip :content="$t('settings.search')">
Expand Down Expand Up @@ -194,6 +197,7 @@
import { LOCALE_OPTIONS } from '@/locale';
import useLocale from '@/hooks/locale';
import useUser from '@/hooks/user';
import Menu from '@/components/menu/index.vue';
import MessageBox from '../message-box/index.vue';
const appStore = useAppStore();
Expand All @@ -208,6 +212,7 @@
const theme = computed(() => {
return appStore.theme;
});
const topMenu = computed(() => appStore.topMenu && appStore.menu);
const isDark = useDark({
selector: 'body',
attribute: 'arco-theme',
Expand Down Expand Up @@ -269,6 +274,10 @@
padding-left: 20px;
}
.center-side {
flex: 1;
}
.right-side {
display: flex;
padding-right: 20px;
Expand Down
1 change: 1 addition & 0 deletions arco-design-pro-vite/src/config/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"colorWeak": false,
"navbar": true,
"menu": true,
"topMenu": false,
"hideMenu": false,
"menuCollapse": false,
"footer": true,
Expand Down
2 changes: 1 addition & 1 deletion arco-design-pro-vite/src/layout/default-layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
useResponsive(true);
const navbarHeight = `60px`;
const navbar = computed(() => appStore.navbar);
const renderMenu = computed(() => appStore.menu);
const renderMenu = computed(() => appStore.menu && !appStore.topMenu);
const hideMenu = computed(() => appStore.hideMenu);
const footer = computed(() => appStore.footer);
const menuWidth = computed(() => {
Expand Down
1 change: 1 addition & 0 deletions arco-design-pro-vite/src/locale/en-US/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {
'settings.navbar.screen.toExit': 'Click to exit the full screen mode',
'settings.navbar.alerts': 'alerts',
'settings.menu': 'Menu',
'settings.topMenu': 'Top Menu',
'settings.tabBar': 'Tab Bar',
'settings.footer': 'Footer',
'settings.otherSettings': 'Other Settings',
Expand Down
1 change: 1 addition & 0 deletions arco-design-pro-vite/src/locale/zh-CN/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {
'settings.navbar.screen.toExit': '点击退出全屏模式',
'settings.navbar.alerts': '消息通知',
'settings.menu': '菜单栏',
'settings.topMenu': '顶部菜单栏',
'settings.tabBar': '多页签',
'settings.footer': '底部',
'settings.otherSettings': '其他设置',
Expand Down
1 change: 1 addition & 0 deletions arco-design-pro-vite/src/store/modules/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface AppState {
colorWeak: boolean;
navbar: boolean;
menu: boolean;
topMenu: boolean;
hideMenu: boolean;
menuCollapse: boolean;
footer: boolean;
Expand Down

0 comments on commit 3fe0f52

Please sign in to comment.