diff --git a/package.json b/package.json index 1b053e1..d265e4c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "avatar", "private": true, - "version": "0.0.1", + "version": "0.0.2", "type": "module", "scripts": { "dev": "vite", diff --git a/src/components/perfect-scrollbar/index.tsx b/src/components/perfect-scrollbar/index.tsx index 0edbff1..5ee06ae 100644 --- a/src/components/perfect-scrollbar/index.tsx +++ b/src/components/perfect-scrollbar/index.tsx @@ -86,7 +86,6 @@ export default function PerfectScrollbar(props: IProps) { if (!sections) { return null; } - // @ts-ignore return (
diff --git a/src/components/react-color-avatar/index.tsx b/src/components/react-color-avatar/index.tsx index 898f959..00e2fd8 100644 --- a/src/components/react-color-avatar/index.tsx +++ b/src/components/react-color-avatar/index.tsx @@ -1,7 +1,7 @@ import { CSSProperties, RefObject, useEffect, useState } from 'react'; import { Background } from '@/components/widgets'; -import { WidgetType, WrapperShape } from '@/enums'; -import { AvatarOption } from '@/types'; +import { WidgetShape, WidgetType, WrapperShape } from '@/enums'; +import { AvatarOption, Widget } from '@/types'; import { AVATAR_LAYER, NONE } from '@/constants'; import { widgetData } from '@/utils/dynamic-data'; import './style.less'; @@ -20,24 +20,25 @@ export default function ReactColorAvatar(props: IReactColorAvatarProps) { (async () => { const sortedList = Object.entries(avatarOption.widgets).sort( ([prevShape, prev], [nextShape, next]) => { - // @ts-ignore - const ix = prev.zIndex ?? AVATAR_LAYER[prevShape]?.zIndex ?? 0; - // @ts-ignore - const iix = next.zIndex ?? AVATAR_LAYER[nextShape]?.zIndex ?? 0; - return ix - iix; + const prevZIndex = prev.zIndex ?? AVATAR_LAYER[prevShape as WidgetType]?.zIndex ?? 0; + const nextZIndex = next.zIndex ?? AVATAR_LAYER[nextShape as WidgetType]?.zIndex ?? 0; + return prevZIndex - nextZIndex; } ); - const promises = sortedList.map(async ([widgetType, opt]) => { - // @ts-ignore + const getWidgetSvg = async (widgetType: WidgetType, opt: Widget) => { if (opt.shape !== NONE && widgetData?.[widgetType]?.[opt.shape]) { - // @ts-ignore return (await widgetData[widgetType][opt.shape]()).default; } return ''; + }; + + const promises = sortedList.map(async ([widgetType, opt]) => { + return getWidgetSvg(widgetType as WidgetType, opt); }); - let skinColor: any; + + let skinColor: string | undefined; const svgRawList = await Promise.all(promises).then((raw) => raw.map((svgRaw, i) => { diff --git a/src/layouts/container/index.tsx b/src/layouts/container/index.tsx index 4bebbd3..9aeac72 100644 --- a/src/layouts/container/index.tsx +++ b/src/layouts/container/index.tsx @@ -42,7 +42,6 @@ export default function Container(props: IProps) { ) if (avatarEle) { const html2canvas = (await import('html2canvas')).default - // @ts-ignore const canvas = await html2canvas(avatarEle, { backgroundColor: null, }) diff --git a/src/types/index.ts b/src/types/index.ts index 5de85ce..6149a17 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -18,14 +18,14 @@ import { export type None = typeof NONE -interface Widget { +export interface Widget { shape: Shape | None zIndex?: number fillColor?: string strokeColor?: string } -type AvatarWidgets = { +export type AvatarWidgets = { face: Widget tops: Widget ear: Widget