schangxiang@126.com
2025-05-07 cace264ad9d86a7831099810b079da1141957add
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
import { defineComponent, SetupContext } from 'vue'
import styles from './Title.module.scss'
import { _t } from '@/libs/Language/Language'
 
export default defineComponent({
  name: 'Title',
  emits: ['click'],
  props: {
    desc: {
      type: String,
      default: '',
    },
    top: {
      type: Number,
      default: 0,
    },
    bottom: {
      type: Number,
      default: 0,
    },
  },
  setup(props, { attrs, slots, emit }: SetupContext) {
    return () => (
      <h3
        style={{ margin: `${props.top}px 0 ${props.bottom}px 0` }}
        class={styles.title}
        onClick={() => emit('click')}
      >
        <div class={styles.label}>{slots.default && slots.default()}</div>
        {slots.content ? (
          <div class={styles.label}>{slots.content()}</div>
        ) : (
          <el-tooltip
            effect="dark"
            content={props.desc}
            placement="top"
            disabled={!props.desc}
            show-after={200}
          >
            <div class={styles.desc}>{_t(props.desc)}</div>
          </el-tooltip>
        )}
      </h3>
    )
  },
})