fix(n-result): show icons on re-render after hydration (#5686)

* fix(n-result): show icons on re-render after hydration

* refactor: change iconMap name

---------

Co-authored-by: 07akioni <07akioni2@gmail.com>
This commit is contained in:
Becem 2024-02-23 11:07:13 +01:00 committed by GitHub
parent b6c4be771e
commit 53ebcbe6d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 10 deletions

View File

@ -5,6 +5,7 @@
### Fixes
- Fix `n-split`'s `min` attribute does not take effect
- Fix `n-result` built-in icons not re-rendered after hydration.
### Features

View File

@ -5,6 +5,7 @@
### Fixes
- 修复 `n-split``min` 属性未生效
- Fix `n-result` built-in icons not re-rendered after hydration.
### Features

View File

@ -24,15 +24,15 @@ import image418 from './418'
import image403 from './403'
import style from './styles/index.cssr'
const iconMap = {
403: image403,
404: image404,
418: image418,
500: image500,
info: <InfoIcon />,
success: <SuccessIcon />,
warning: <WarningIcon />,
error: <ErrorIcon />
const iconRenderMap = {
403: () => image403,
404: () => image404,
418: () => image418,
500: () => image500,
info: () => <InfoIcon />,
success: () => <SuccessIcon />,
warning: () => <WarningIcon />,
error: () => <ErrorIcon />
}
export const resultProps = {
@ -130,7 +130,7 @@ export default defineComponent({
<div class={`${mergedClsPrefix}-result-icon`}>
{$slots.icon?.() || (
<NBaseIcon clsPrefix={mergedClsPrefix}>
{{ default: () => iconMap[status] }}
{{ default: () => iconRenderMap[status]() }}
</NBaseIcon>
)}
</div>