Avatar (头像)
基于 KunUser 的用户头像,支持确定性贴纸兜底与点击跳转个人主页。
基础用法
Basic.vue
尺寸
Sizes.vue
贴纸兜底
没有头像的用户会从 avatarFallbackPool 里按名字哈希取一张,同一个人永远拿到同一张。 这个池子由宿主应用提供(KunUI 不内置任何外部地址)——不配置的话,所有人都会渲染同一张内置兜底图。 配置方法见 INTEGRATION.md §7.1。



StickerFallback.vue
可点击跳转
头像框
user.avatarDecoration 是画在头像外面的头像框:素材是头像 1.2 倍的正方形画布,头像圆居中。 头像框每边伸出 10%,不占布局、不接收点击。decoration 决定动图什么时候播放:默认 hover 只在悬停或获得焦点时播放,always 一直播放,static 只用静态图, none 不画。sm 及更小的尺寸不画头像框;开启了减弱动态效果的读者永远只看到静态图。
Decoration.vue
属性
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| user * | KunUser | null | — | Nullable — upstream user hydration can return a missing brief; Avatar falls back to a deterministic sticker. |
| className | string | "" | |
| decoration | KunAvatarDecorationMode | "hover" | How `user.avatarDecoration` is drawn. `hover` (default) shows the still frame and plays the animated one while the avatar is hovered or focused; `always` plays it continuously; `static` never animates; `none` hides the frame. Below the `md` size the frame is never drawn, and a reader who asked for reduced motion always gets the still image. |
| disableFloating | boolean | — | Legacy floating user-card toggle. 已废弃:No-op: KunAvatar renders no floating card. Accepted so existing call sites still type-check; safe to remove from them. |
| floatingPosition | "top" | "right" | "bottom" | "left" | — | Legacy floating user-card placement. 已废弃:No-op: KunAvatar renders no floating card. Accepted so existing call sites still type-check; safe to remove from them. |
| imageClassName | string | "" | |
| isNavigation | boolean | true | When true (default) and `user.id` is not 0, the avatar is a real <a>/link to the user's profile (`userLinkTemplate`). |
| size | KunAvatarSize | "md" |

