Blame view

src/layouts/default/index.vue 2.44 KB
vben authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<template>
  <Layout :class="prefixCls">
    <LayoutFeatures />
    <LayoutHeader fixed ref="headerRef" v-if="getShowFullHeaderRef" />
    <Layout>
      <LayoutSideBar v-if="getShowSidebar" />
      <Layout :class="`${prefixCls}__main`">
        <LayoutMultipleHeader />
        <LayoutContent />
        <LayoutFooter />
      </Layout>
    </Layout>
  </Layout>
</template>

<script lang="ts">
  import { defineComponent, ref } from 'vue';
  import { Layout } from 'ant-design-vue';
  import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
vben authored
21
  import LayoutHeader from './header/index.vue';
vben authored
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  import LayoutContent from './content/index.vue';
  import LayoutSideBar from './sider';
  import LayoutMultipleHeader from './header/LayoutMultipleHeader';

  import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting';
  import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
  import { useDesign } from '/@/hooks/web/useDesign';
  import { createLayoutContext } from './useLayoutContext';

  import { registerGlobComp } from '/@/components/registerGlobComp';

  export default defineComponent({
    name: 'DefaultLayout',
    components: {
      LayoutFeatures: createAsyncComponent(() => import('/@/layouts/default/feature/index.vue')),
      LayoutFooter: createAsyncComponent(() => import('/@/layouts/default/footer/index.vue')),
      LayoutHeader,
      LayoutContent,
      LayoutSideBar,
      LayoutMultipleHeader,
      Layout,
    },
    setup() {
      // ! Only register global components here
      // ! Can reduce the size of the first screen code
      // default layout It is loaded after login. So it won’t be packaged to the first screen
      registerGlobComp();
vben authored
50
51
52
53
54
55
      const headerRef = ref<ComponentRef>(null);

      const { prefixCls } = useDesign('default-layout');

      createLayoutContext({ fullHeader: headerRef });
vben authored
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
      const { getShowFullHeaderRef } = useHeaderSetting();

      const { getShowSidebar } = useMenuSetting();

      return {
        getShowFullHeaderRef,
        getShowSidebar,
        headerRef,
        prefixCls,
      };
    },
  });
</script>
<style lang="less">
  @import (reference) '../../design/index.less';
  @prefix-cls: ~'@{namespace}-default-layout';

  .@{prefix-cls} {
    display: flex;
    width: 100%;
    min-height: 100%;
    background: @content-bg;
    flex-direction: column;

    > .ant-layout {
      min-height: 100%;
    }

    &__main {
      margin-left: 1px;
    }
  }
</style>