PresenceAvatar 在线状态头像
带在线状态指示的头像组件,状态数据由 Presence 服务订阅而来,支持点击切换自己的状态。
使用方式
组件以 EmPresenceAvatar 为名导出,全局注册后可直接使用。状态依赖 EmUIKitProvider 的 Presence 能力,需要包裹在 Provider 内:
vue
<template>
<EmUIKitProvider :auto-init="false" :enable-presence="true">
<em-presence-avatar user-id="u_alice" name="Alice" :size="40" />
</EmUIKitProvider>
</template>基础用法
可编辑状态
API
PresenceAvatar API
Props
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| userId | string | — | 用户 ID,用于自动订阅/拉取在线状态 |
| src | string | — | 头像地址 |
| name | string | — | 展示名称(无头像时生成占位文字) |
| size | number | — | 头像尺寸,默认 40 |
| shape | 'circle' | 'square' | — | 头像形状,默认跟随主题 |
| presenceSize | number | — | 指示器直径(px),默认按头像尺寸自适应 |
| editable | boolean | — | 是否可编辑,点击时打开在线状态选择 popup |
| selectorPlacement | 'bottom' | 'top' | 'left' | 'right' | — | 弹层相对头像的位置,默认 'bottom' |
Events
| 事件名 | 参数 | 说明 |
|---|---|---|
presence-click | — | 点击头像时触发(无负载);editable 为 true 时会同时打开状态选择弹层 |
presence-changed | — | 在弹层中选择新的在线状态后触发(无负载),随后自动刷新状态指示器 |
