Avatar (头像)

基于 KunUser 的用户头像,支持确定性贴纸兜底与点击跳转个人主页。

基础用法

Kun
Basic.vue

尺寸

Kun
Kun
Kun
Kun
Kun
Kun
Kun
Sizes.vue

贴纸兜底

没有头像的用户会从 avatarFallbackPool 里按名字哈希取一张,同一个人永远拿到同一张。 这个池子由宿主应用提供(KunUI 不内置任何外部地址)——不配置的话,所有人都会渲染同一张内置兜底图。 配置方法见 INTEGRATION.md §7.1。

Alice
Bob
Carol
StickerFallback.vue

可点击跳转

Kun
Navigation.vue

头像框

user.avatarDecoration 是画在头像外面的头像框:素材是头像 1.2 倍的正方形画布,头像圆居中。 头像框每边伸出 10%,不占布局、不接收点击。decoration 决定动图什么时候播放:默认 hover 只在悬停或获得焦点时播放,always 一直播放,static 只用静态图, none 不画。sm 及更小的尺寸不画头像框;开启了减弱动态效果的读者永远只看到静态图。

Kun
hover
Kun
always
Kun
static
Kun
Kun
Kun
Kun
Decoration.vue

属性

属性类型默认值说明
user *KunUser | null—Nullable — upstream user hydration can return a missing brief; Avatar falls back to a deterministic sticker.
classNamestring""
decorationKunAvatarDecorationMode"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.
disableFloatingboolean—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.
imageClassNamestring""
isNavigationbooleantrueWhen true (default) and `user.id` is not 0, the avatar is a real <a>/link to the user's profile (`userLinkTemplate`).
sizeKunAvatarSize"md"