From 6d8a2ddd75a95a10b361eca849dc3374e766c89f Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Tue, 18 Oct 2022 00:45:38 +0800 Subject: [PATCH] perf: refine the fallback of the avatar component (#649) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement /milestone 2.0 #### What this PR does / why we need it: 优化 Avatar 组件在图片加载失败的状态,以及添加加载状态的动画。目前的策略为,如果图片加载异常,那么会取 `alt` 属性生成占位样式。如果没有设置 `alt`,会显示失败的图标。 #### Screenshots: image #### Special notes for your reviewer: /cc @halo-dev/sig-halo-console 测试方式: 1. 需要 `pnpm build:packages` 2. 测试修改个人资料的头像,观测不同效果。 3. 访问 https://halo-admin-ui-git-fork-ruibaby-perf-avatar-fallback-halo-dev.vercel.app/story/src-components-avatar-avatar-story-vue?variantId=_default 测试不同参数的效果。 #### Does this PR introduce a user-facing change? ```release-note 优化 Avatar 组件在图片加载失败的状态 ``` --- .../src/components/avatar/Avatar.story.vue | 43 +++++++- .../src/components/avatar/Avatar.vue | 103 ++++++++++++++++-- .../comments/components/CommentListItem.vue | 7 +- .../comments/components/ReplyListItem.vue | 7 +- .../users/layouts/UserProfileLayout.vue | 1 + 5 files changed, 150 insertions(+), 11 deletions(-) diff --git a/packages/components/src/components/avatar/Avatar.story.vue b/packages/components/src/components/avatar/Avatar.story.vue index 6b61fe3d..328ca38d 100644 --- a/packages/components/src/components/avatar/Avatar.story.vue +++ b/packages/components/src/components/avatar/Avatar.story.vue @@ -1,8 +1,49 @@ diff --git a/packages/components/src/components/avatar/Avatar.vue b/packages/components/src/components/avatar/Avatar.vue index 9439dbd3..b1952e1f 100644 --- a/packages/components/src/components/avatar/Avatar.vue +++ b/packages/components/src/components/avatar/Avatar.vue @@ -1,8 +1,7 @@