11import { CSSProperties , RefObject , useEffect , useState } from 'react' ;
22import { Background } from '@/components/widgets' ;
3- import { WidgetType , WrapperShape } from '@/enums' ;
4- import { AvatarOption } from '@/types' ;
3+ import { WidgetShape , WidgetType , WrapperShape } from '@/enums' ;
4+ import { AvatarOption , Widget } from '@/types' ;
55import { AVATAR_LAYER , NONE } from '@/constants' ;
66import { widgetData } from '@/utils/dynamic-data' ;
77import './style.less' ;
@@ -20,24 +20,25 @@ export default function ReactColorAvatar(props: IReactColorAvatarProps) {
2020 ( async ( ) => {
2121 const sortedList = Object . entries ( avatarOption . widgets ) . sort (
2222 ( [ prevShape , prev ] , [ nextShape , next ] ) => {
23- // @ts -ignore
24- const ix = prev . zIndex ?? AVATAR_LAYER [ prevShape ] ?. zIndex ?? 0 ;
25- // @ts -ignore
26- const iix = next . zIndex ?? AVATAR_LAYER [ nextShape ] ?. zIndex ?? 0 ;
27- return ix - iix ;
23+ const prevZIndex = prev . zIndex ?? AVATAR_LAYER [ prevShape as WidgetType ] ?. zIndex ?? 0 ;
24+ const nextZIndex = next . zIndex ?? AVATAR_LAYER [ nextShape as WidgetType ] ?. zIndex ?? 0 ;
25+ return prevZIndex - nextZIndex ;
2826 }
2927 ) ;
3028
31- const promises = sortedList . map ( async ( [ widgetType , opt ] ) => {
32- // @ts -ignore
29+ const getWidgetSvg = async ( widgetType : WidgetType , opt : Widget < WidgetShape > ) => {
3330 if ( opt . shape !== NONE && widgetData ?. [ widgetType ] ?. [ opt . shape ] ) {
34- // @ts -ignore
3531 return ( await widgetData [ widgetType ] [ opt . shape ] ( ) ) . default ;
3632 }
3733 return '' ;
34+ } ;
35+
36+ const promises = sortedList . map ( async ( [ widgetType , opt ] ) => {
37+ return getWidgetSvg ( widgetType as WidgetType , opt ) ;
3838 } ) ;
3939
40- let skinColor : any ;
40+
41+ let skinColor : string | undefined ;
4142
4243 const svgRawList = await Promise . all ( promises ) . then ( ( raw ) =>
4344 raw . map ( ( svgRaw , i ) => {
0 commit comments