Skip to content

Commit ff07c9d

Browse files
committed
chore: nav 新增功能动效
1 parent 5ed99a1 commit ff07c9d

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

.dumi/theme/slots/Header/Navigation.tsx

+28
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
useSiteData,
1313
} from 'dumi';
1414
import { INavItem } from 'dumi/dist/client/theme-api/types';
15+
import { motion } from 'framer-motion';
1516
import { useCallback, useContext, useEffect, useRef } from 'react';
1617
import useAdditionalThemeConfig from '../../hooks/useAdditionalThemeConfig';
1718
import useLocaleValue from '../../hooks/useLocaleValue';
@@ -82,6 +83,9 @@ const useStyle = () => {
8283
`,
8384
navItem: css`
8485
position: relative;
86+
display: flex;
87+
align-items: center;
88+
justify-content: center;
8589
`,
8690
newPlayer: css`
8791
width: 100px;
@@ -91,6 +95,12 @@ const useStyle = () => {
9195
left: 50%;
9296
transform: translateX(-50%);
9397
z-index: 9;
98+
pointer-events: none;
99+
`,
100+
rightIcon: css`
101+
margin-left: 8px;
102+
width: 16px;
103+
height: 16px;
94104
`,
95105
popoverMenuNav: css`
96106
${antCls}-menu-item,
@@ -184,6 +194,24 @@ export default function Navigation({ isMobile, responsive }: NavigationProps) {
184194
{navItem.isNew ? (
185195
<div ref={playerDom} css={style.newPlayer}></div>
186196
) : null}
197+
{navItem.rightIcon && (
198+
<motion.div
199+
style={{ display: 'inline-block' }}
200+
animate={{
201+
rotate: [-5, 5, -5, 5, 0], // 轻微旋转
202+
x: [-2, 2, -2, 2, 0], // 轻微水平移动
203+
y: [-1, 1, -1, 1, 0], // 轻微垂直移动
204+
transition: {
205+
duration: 1.0, // 增加持续时间,使晃动更加平滑
206+
repeat: Infinity, // 无限循环
207+
ease: 'easeInOut', // 使用平滑的缓动函数
208+
repeatDelay: 3,
209+
},
210+
}}
211+
>
212+
<img css={style.rightIcon} src={navItem.rightIcon} alt="" />
213+
</motion.div>
214+
)}
187215
</div>
188216
),
189217
key: isExternalLinks(navItem.link) ? navItem.link : linkKeyValue,

.dumirc.ts

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export default defineConfig({
6161
link: '/copilots/conversations',
6262
// @ts-ignore
6363
isNew: true,
64+
rightIcon:
65+
'https://mdn.alipayobjects.com/huamei_2jrq4g/afts/img/A*iiKoT73_9ucAAAAAAAAAAAAAetF8AQ/original',
6466
},
6567
{
6668
title: '资源',

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"eslint-config-prettier": "^8.3.0",
9393
"eslint-plugin-import": "^2.25.3",
9494
"extract-changelog-release": "^1.0.2",
95+
"framer-motion": "^12.0.1",
9596
"gh-pages": "^3.0.0",
9697
"glob": "^9.0.1",
9798
"gulp": "^4.0.2",

0 commit comments

Comments
 (0)