Commit f81c401959dda4b8d568c00786b691c21abbb59c
1 parent
27e50b47
perf(tabs): perf multiple-tabs
Showing
3 changed files
with
3 additions
and
95 deletions
src/layouts/default/index.less deleted
100644 → 0
1 | -@import (reference) '../../design/index.less'; | |
2 | - | |
3 | -.default-layout { | |
4 | - display: flex; | |
5 | - width: 100%; | |
6 | - min-height: 100%; | |
7 | - background: @content-bg; | |
8 | - flex-direction: column; | |
9 | - | |
10 | - > .ant-layout { | |
11 | - min-height: 100%; | |
12 | - } | |
13 | - | |
14 | - &__main { | |
15 | - margin-left: 1px; | |
16 | - } | |
17 | -} |
src/layouts/default/index.tsx deleted
100644 → 0
1 | -import './index.less'; | |
2 | - | |
3 | -import { defineComponent, unref, ref } from 'vue'; | |
4 | -import { Layout } from 'ant-design-vue'; | |
5 | -import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; | |
6 | - | |
7 | -import LayoutHeader from './header/LayoutHeader'; | |
8 | -import LayoutContent from './content/index.vue'; | |
9 | -import LayoutSideBar from './sider'; | |
10 | -import LayoutMultipleHeader from './header/LayoutMultipleHeader'; | |
11 | - | |
12 | -import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting'; | |
13 | -import { useMenuSetting } from '/@/hooks/setting/useMenuSetting'; | |
14 | -import { createLayoutContext } from './useLayoutContext'; | |
15 | - | |
16 | -import { registerGlobComp } from '/@/components/registerGlobComp'; | |
17 | -import { createBreakpointListen } from '/@/hooks/event/useBreakpoint'; | |
18 | -import { isMobile } from '/@/utils/is'; | |
19 | - | |
20 | -const LayoutFeatures = createAsyncComponent(() => import('/@/layouts/default/feature/index.vue')); | |
21 | -const LayoutFooter = createAsyncComponent(() => import('/@/layouts/default/footer/index.vue')); | |
22 | - | |
23 | -export default defineComponent({ | |
24 | - name: 'DefaultLayout', | |
25 | - setup() { | |
26 | - const headerRef = ref<ComponentRef>(null); | |
27 | - const isMobileRef = ref(false); | |
28 | - | |
29 | - createLayoutContext({ fullHeader: headerRef, isMobile: isMobileRef }); | |
30 | - | |
31 | - createBreakpointListen(() => { | |
32 | - isMobileRef.value = isMobile(); | |
33 | - }); | |
34 | - | |
35 | - // ! Only register global components here | |
36 | - // ! Can reduce the size of the first screen code | |
37 | - // default layout It is loaded after login. So it won’t be packaged to the first screen | |
38 | - registerGlobComp(); | |
39 | - | |
40 | - const { getShowFullHeaderRef } = useHeaderSetting(); | |
41 | - | |
42 | - const { getShowSidebar } = useMenuSetting(); | |
43 | - | |
44 | - return () => { | |
45 | - return ( | |
46 | - <Layout class="default-layout"> | |
47 | - {() => ( | |
48 | - <> | |
49 | - <LayoutFeatures /> | |
50 | - | |
51 | - {unref(getShowFullHeaderRef) && <LayoutHeader fixed={true} ref={headerRef} />} | |
52 | - | |
53 | - <Layout> | |
54 | - {() => ( | |
55 | - <> | |
56 | - {unref(getShowSidebar) && <LayoutSideBar />} | |
57 | - <Layout class="default-layout__main"> | |
58 | - {() => ( | |
59 | - <> | |
60 | - <LayoutMultipleHeader /> | |
61 | - <LayoutContent /> | |
62 | - <LayoutFooter /> | |
63 | - </> | |
64 | - )} | |
65 | - </Layout> | |
66 | - </> | |
67 | - )} | |
68 | - </Layout> | |
69 | - </> | |
70 | - )} | |
71 | - </Layout> | |
72 | - ); | |
73 | - }; | |
74 | - }, | |
75 | -}); |
src/layouts/default/useLayoutContext.ts
... | ... | @@ -6,12 +6,12 @@ export interface LayoutContextProps { |
6 | 6 | isMobile: Ref<boolean>; |
7 | 7 | } |
8 | 8 | |
9 | -const layoutContextInjectKey: InjectionKey<LayoutContextProps> = Symbol(); | |
9 | +const key: InjectionKey<LayoutContextProps> = Symbol(); | |
10 | 10 | |
11 | 11 | export function createLayoutContext(context: LayoutContextProps) { |
12 | - return createContext<LayoutContextProps>(context, layoutContextInjectKey); | |
12 | + return createContext<LayoutContextProps>(context, key); | |
13 | 13 | } |
14 | 14 | |
15 | 15 | export function useLayoutContext() { |
16 | - return useContext<LayoutContextProps>(layoutContextInjectKey); | |
16 | + return useContext<LayoutContextProps>(key); | |
17 | 17 | } | ... | ... |