-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83672da
commit 5f58738
Showing
3 changed files
with
29 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,13 @@ | ||
import WaterLightAnimation from '@/views/WaterLight' | ||
import TimeLineAniamtion from '@/views/TimeLine' | ||
import BubbleAnimation from '@/views/Bubble' | ||
import CheckOnAnimation from '@/views/CheckOn' | ||
import MouseFollowAnimation from '@/views/MouseFollow' | ||
import CardAnimation from '@/views/Card' | ||
import ImageWallAnimation from '@/views/ImageWall' | ||
import ClockAnimation from '@/views/Clock' | ||
import BugWordAnimation from '@/views/BugWord' | ||
import Calendar from '@/views/Calendar' | ||
import { VIEW_COMPONENTS } from './type' | ||
import type { IView } from '@/types/view' | ||
import { ViewType } from '@/types/view' | ||
import './style.css' | ||
|
||
export default function Views({ activeView }: { activeView: IView }) { | ||
const ActiveComponent = VIEW_COMPONENTS[activeView.value] | ||
return ( | ||
<div className="views"> | ||
{activeView.value === ViewType.Clock && <ClockAnimation />} | ||
{activeView.value === ViewType.Image && <ImageWallAnimation />} | ||
{activeView.value === ViewType.Card && <CardAnimation />} | ||
{activeView.value === ViewType.MouseFollow && <MouseFollowAnimation />} | ||
{activeView.value === ViewType.CheckOn && <CheckOnAnimation />} | ||
{activeView.value === ViewType.Bubble && <BubbleAnimation />} | ||
{activeView.value === ViewType.TimeLine && <TimeLineAniamtion />} | ||
{activeView.value === ViewType.WaterLight && <WaterLightAnimation />} | ||
{activeView.value === ViewType.BugWord && <BugWordAnimation />} | ||
{activeView.value === ViewType.Calendar && ( | ||
<Calendar | ||
value={new Date()} | ||
onChange={(date: Date) => { | ||
alert(date.toLocaleDateString()) | ||
}} | ||
/> | ||
)} | ||
<ActiveComponent /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type React from 'react' | ||
import WaterLightAnimation from '@/views/WaterLight' | ||
import TimeLineAniamtion from '@/views/TimeLine' | ||
import BubbleAnimation from '@/views/Bubble' | ||
import CheckOnAnimation from '@/views/CheckOn' | ||
import MouseFollowAnimation from '@/views/MouseFollow' | ||
import CardAnimation from '@/views/Card' | ||
import ImageWallAnimation from '@/views/ImageWall' | ||
import ClockAnimation from '@/views/Clock' | ||
import BugWordAnimation from '@/views/BugWord' | ||
import Calendar from '@/views/Calendar' | ||
import { ViewType } from '@/types/view' | ||
|
||
// 创建映射对象 | ||
export const VIEW_COMPONENTS: Record<ViewType, React.ElementType> = { | ||
[ViewType.Clock]: ClockAnimation, | ||
[ViewType.Image]: ImageWallAnimation, | ||
[ViewType.Card]: CardAnimation, | ||
[ViewType.MouseFollow]: MouseFollowAnimation, | ||
[ViewType.CheckOn]: CheckOnAnimation, | ||
[ViewType.Bubble]: BubbleAnimation, | ||
[ViewType.TimeLine]: TimeLineAniamtion, | ||
[ViewType.WaterLight]: WaterLightAnimation, | ||
[ViewType.BugWord]: BugWordAnimation, | ||
[ViewType.Calendar]: Calendar, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters