PageHeader.vue 2.9 KB
Newer Older
wb-ct393452's avatar
wb-ct393452 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 50 51 52 53 54 55 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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
<template>
    <div :class="['page-header', layout, pageWidth]">
        <div class="page-header-wide">
            <div class="breadcrumb">
                <a-breadcrumb>
                    <a-breadcrumb-item :key="index" v-for="(item, index) in breadcrumb">
                        <span>{{item}}</span>
                    </a-breadcrumb-item>
                </a-breadcrumb>
            </div>
            <div class="detail">
                <div class="main">
                    <div class="row">
                        <h1 v-if="showPageTitle && title" class="title">{{title}}</h1>
                        <div class="action">
                            <slot name="action"></slot>
                        </div>
                    </div>
                    <div class="row">
                        <div v-if="this.$slots.content" class="content">
                            <div v-if="avatar" class="avatar">
                                <a-avatar :src="avatar" :size="72" />
                            </div>
                            <slot name="content"></slot>
                        </div>
                        <div v-if="this.$slots.extra" class="extra">
                            <slot name="extra"></slot>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { mapState } from 'vuex';
export default {
    name: 'PageHeader',
    props: {
        title: {
            type: [String, Boolean],
            required: false,
        },
        breadcrumb: {
            type: Array,
            required: false,
        },
        logo: {
            type: String,
            required: false,
        },
        avatar: {
            type: String,
            required: false,
        },
    },
    computed: {
        ...mapState('settingModule', ['layout', 'showPageTitle', 'pageWidth']),
    },
};
</script>

<style lang="less" scoped>
.page-header {
    background: @base-bg-color;
    padding: 16px 24px;
    &.head.fixed {
        margin: auto;
        max-width: 1400px;
    }
    .page-header-wide {
        .breadcrumb {
            margin-bottom: 20px;
        }
        .detail {
            display: flex;
            .row {
                display: flex;
                flex-wrap: wrap;
                justify-content: space-between;
            }
            .avatar {
                margin: 0 24px 0 0;
            }
            .main {
                width: 100%;
                .title {
                    font-size: 20px;
                    color: @title-color;
                    margin-bottom: 16px;
                }
                .content {
                    display: flex;
                    flex-wrap: wrap;
                    color: @text-color-second;
                }
                .extra {
                    display: flex;
                }
            }
        }
    }
}
</style>