Commit 25d43a5f7c9182f2ca620f1daf0d5f47d2e4fb2d
1 parent
36734100
fix: fix topMenu align not work
Showing
3 changed files
with
20 additions
and
18 deletions
src/design/global.less
@@ -26,11 +26,11 @@ | @@ -26,11 +26,11 @@ | ||
26 | } | 26 | } |
27 | 27 | ||
28 | .justify-start { | 28 | .justify-start { |
29 | - justify-content: start; | 29 | + justify-content: flex-start; |
30 | } | 30 | } |
31 | 31 | ||
32 | .justify-end { | 32 | .justify-end { |
33 | - justify-content: end; | 33 | + justify-content: flex-end; |
34 | } | 34 | } |
35 | 35 | ||
36 | .justify-around { | 36 | .justify-around { |
src/layouts/default/header/LayoutHeader.tsx
1 | import './index.less'; | 1 | import './index.less'; |
2 | 2 | ||
3 | -import { defineComponent, unref, computed, ref } from 'vue'; | 3 | +import { defineComponent, unref, computed, ref, nextTick } from 'vue'; |
4 | 4 | ||
5 | import { Layout, Tooltip, Badge } from 'ant-design-vue'; | 5 | import { Layout, Tooltip, Badge } from 'ant-design-vue'; |
6 | import { AppLogo } from '/@/components/Application'; | 6 | import { AppLogo } from '/@/components/Application'; |
@@ -39,8 +39,8 @@ export default defineComponent({ | @@ -39,8 +39,8 @@ export default defineComponent({ | ||
39 | setup() { | 39 | setup() { |
40 | let logoEl: Element | null; | 40 | let logoEl: Element | null; |
41 | 41 | ||
42 | - const widthRef = ref(200); | ||
43 | - | 42 | + const logoWidthRef = ref(200); |
43 | + const logoRef = ref<any>(null); | ||
44 | const { refreshPage } = useTabs(); | 44 | const { refreshPage } = useTabs(); |
45 | 45 | ||
46 | const { getShowTopMenu, getShowHeaderTrigger, getSplit, getTopMenuAlign } = useMenuSetting(); | 46 | const { getShowTopMenu, getShowHeaderTrigger, getSplit, getTopMenuAlign } = useMenuSetting(); |
@@ -64,15 +64,17 @@ export default defineComponent({ | @@ -64,15 +64,17 @@ export default defineComponent({ | ||
64 | 64 | ||
65 | useWindowSizeFn( | 65 | useWindowSizeFn( |
66 | () => { | 66 | () => { |
67 | - if (!unref(getShowTopMenu)) return; | ||
68 | - let width = 0; | ||
69 | - if (!logoEl) { | ||
70 | - logoEl = document.querySelector('.layout-header__logo'); | ||
71 | - } | ||
72 | - if (logoEl) { | ||
73 | - width += logoEl.clientWidth; | ||
74 | - } | ||
75 | - widthRef.value = width + 60; | 67 | + nextTick(() => { |
68 | + if (!unref(getShowTopMenu)) return; | ||
69 | + let width = 0; | ||
70 | + if (!logoEl) { | ||
71 | + logoEl = logoRef.value.$el; | ||
72 | + } | ||
73 | + if (logoEl) { | ||
74 | + width += logoEl.clientWidth; | ||
75 | + } | ||
76 | + logoWidthRef.value = width + 80; | ||
77 | + }); | ||
76 | }, | 78 | }, |
77 | 200, | 79 | 200, |
78 | { immediate: true } | 80 | { immediate: true } |
@@ -105,11 +107,11 @@ export default defineComponent({ | @@ -105,11 +107,11 @@ export default defineComponent({ | ||
105 | } | 107 | } |
106 | 108 | ||
107 | function renderHeaderContent() { | 109 | function renderHeaderContent() { |
108 | - const width = unref(widthRef); | 110 | + const width = unref(logoWidthRef); |
109 | return ( | 111 | return ( |
110 | <div class="layout-header__content "> | 112 | <div class="layout-header__content "> |
111 | {unref(getShowHeaderLogo) && ( | 113 | {unref(getShowHeaderLogo) && ( |
112 | - <AppLogo class={`layout-header__logo`} theme={unref(getTheme)} /> | 114 | + <AppLogo class={`layout-header__logo`} ref={logoRef} theme={unref(getTheme)} /> |
113 | )} | 115 | )} |
114 | 116 | ||
115 | {unref(getShowContent) && ( | 117 | {unref(getShowContent) && ( |
src/layouts/default/header/index.less
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | 12 | ||
13 | &__left { | 13 | &__left { |
14 | display: flex; | 14 | display: flex; |
15 | - flex-grow: 1; | 15 | + // flex-grow: 1; |
16 | align-items: center; | 16 | align-items: center; |
17 | 17 | ||
18 | .layout-trigger { | 18 | .layout-trigger { |
@@ -184,7 +184,7 @@ | @@ -184,7 +184,7 @@ | ||
184 | } | 184 | } |
185 | 185 | ||
186 | &__menu { | 186 | &__menu { |
187 | - margin-left: 20px; | 187 | + margin-left: 4px; |
188 | overflow: hidden; | 188 | overflow: hidden; |
189 | align-items: center; | 189 | align-items: center; |
190 | } | 190 | } |