Ben Lin
2024-10-30 28a53fe81cdb551d2bf2023167487a3060e0f180
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
<template>
  <BasicTitle v-if="!isDetail" :class="prefixCls">
    <slot name="title"></slot>
    {{ !$slots.title ? title : '' }}
  </BasicTitle>
 
  <div :class="[prefixCls, `${prefixCls}--detail`]" v-else>
    <span :class="`${prefixCls}__twrap`">
      <span @click="handleClose" v-if="showDetailBack">
        <ArrowLeftOutlined :class="`${prefixCls}__back`" />
      </span>
      <span v-if="title">{{ title }}</span>
    </span>
 
    <span :class="`${prefixCls}__toolbar`">
      <slot name="titleToolbar"></slot>
    </span>
  </div>
</template>
<script lang="ts" setup>
  import { BasicTitle } from '@/components/Basic';
  import { ArrowLeftOutlined } from '@ant-design/icons-vue';
  import { useDesign } from '@/hooks/web/useDesign';
  import { propTypes } from '@/utils/propTypes';
 
  defineOptions({ name: 'BasicDrawerHeader' });
 
  defineProps({
    isDetail: propTypes.bool,
    showDetailBack: propTypes.bool,
    title: propTypes.string,
  });
 
  const emit = defineEmits(['close']);
 
  const { prefixCls } = useDesign('basic-drawer-header');
 
  function handleClose() {
    emit('close');
  }
</script>
 
<style lang="less">
  @prefix-cls: ~'@{namespace}-basic-drawer-header';
  @footer-height: 60px;
  .@{prefix-cls} {
    display: flex;
    align-items: center;
    height: 100%;
 
    &__back {
      padding: 0 12px;
      cursor: pointer;
 
      &:hover {
        color: @primary-color;
      }
    }
 
    &__twrap {
      flex: 1;
    }
 
    &__toolbar {
      padding-right: 50px;
    }
  }
</style>