gaoluyang
5 小时以前 cb9cd49627b65a4c0e137e08063271a8cefe1826
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
<script lang="ts" setup>
import { computed } from 'vue'
 
import { IconifyIcon as Icon } from '#/packages/icons/src'
 
import { getCardLabelInfo } from '#/views/im/utils/message'
 
defineOptions({ name: 'ImCardLineLabel' })
 
const props = withDefaults(
  defineProps<{
    /** 名片数据;只读 targetType / name 派生标签 + 显示,结构性类型兼容 CardMessage / 引用预览的 partial */
    card: null | undefined | { name?: string; targetType?: number; }
    iconSize?: number
  }>(),
  { iconSize: 14 }
)
 
/** 标签 + 图标按 targetType 二分;兜底「个人名片」避免 null 时 UI 空白 */
const labelInfo = computed(() => getCardLabelInfo(props.card))
</script>
 
<template>
  <!-- 名片单行 inline label:「[icon] 群名片 / 个人名片:xx」;列表摘要 / 引用预览 / 后台预览复用 -->
  <span class="inline-flex gap-1.5 items-center">
    <Icon :icon="labelInfo.icon" :size="iconSize" />
    <span>{{ labelInfo.label }}:{{ card?.name || '' }}</span>
  </span>
</template>