-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: fix site style and enhance user experience #262
Changes from 3 commits
cbd6aaf
ed02c77
656f5af
a78275d
a6c36e4
c17f665
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -39,6 +39,10 @@ const useStyle = createStyles(({ token, css }) => { | |||||||||||||||||||
align-items: center; | ||||||||||||||||||||
position: relative; | ||||||||||||||||||||
font-family: AlibabaPuHuiTi, ${token.fontFamily}, sans-serif; | ||||||||||||||||||||
|
||||||||||||||||||||
@media only screen and (max-width: ${token.mobileMaxWidth}px) { | ||||||||||||||||||||
height: calc(100vh - ${token.paddingLG}px); | ||||||||||||||||||||
} | ||||||||||||||||||||
`, | ||||||||||||||||||||
background: css` | ||||||||||||||||||||
width: 100%; | ||||||||||||||||||||
|
@@ -51,8 +55,6 @@ const useStyle = createStyles(({ token, css }) => { | |||||||||||||||||||
height: 100%; | ||||||||||||||||||||
max-height: calc(100vh - ${token.headerHeight * 2}px); | ||||||||||||||||||||
position: relative; | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
`, | ||||||||||||||||||||
title: css` | ||||||||||||||||||||
max-width: ${minBannerWidth}px; | ||||||||||||||||||||
|
@@ -68,6 +70,8 @@ const useStyle = createStyles(({ token, css }) => { | |||||||||||||||||||
flex-direction: column; | ||||||||||||||||||||
align-items: center; | ||||||||||||||||||||
justify-content: center; | ||||||||||||||||||||
text-align: center; | ||||||||||||||||||||
gap: ${token.paddingXS}px; | ||||||||||||||||||||
} | ||||||||||||||||||||
`, | ||||||||||||||||||||
lottie: css` | ||||||||||||||||||||
|
@@ -150,6 +154,10 @@ const useStyle = createStyles(({ token, css }) => { | |||||||||||||||||||
font-weight: 600; | ||||||||||||||||||||
box-shadow: ${token.boxShadow}; | ||||||||||||||||||||
position: relative; | ||||||||||||||||||||
|
||||||||||||||||||||
@media only screen and (max-width: ${token.mobileMaxWidth}px) { | ||||||||||||||||||||
padding: 0 ${token.paddingLG}px; | ||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+157
to
+160
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议增强按钮的可访问性 移动端内边距的调整很合理,但建议考虑以下无障碍性优化:
@media only screen and (max-width: ${token.mobileMaxWidth}px) {
padding: 0 ${token.paddingLG}px;
+ min-height: 44px; // iOS 无障碍建议最小高度
+ margin: ${token.marginXS}px 0; // 增加按钮间距
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
`, | ||||||||||||||||||||
startBtn: css` | ||||||||||||||||||||
background: linear-gradient(90deg, #c7deff 0%, #ffffffd9 76%); | ||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { Button } from 'antd'; | ||
import { Button, Carousel } from 'antd'; | ||
import { createStyles } from 'antd-style'; | ||
import classnames from 'classnames'; | ||
import React from 'react'; | ||
|
||
import useLocale from '../../../../hooks/useLocale'; | ||
import Container from '../../common/Container'; | ||
import SiteContext from '../SiteContext'; | ||
import AssistantScene from './Assistant'; | ||
import Independent from './Independent'; | ||
import NestScene from './Nest'; | ||
|
@@ -48,11 +49,16 @@ const useStyle = createStyles(({ token, css }) => { | |
return { | ||
container: css` | ||
position: relative; | ||
|
||
@media screen and (max-width: ${token.mobileMaxWidth}px) { | ||
height: 80vh; | ||
} | ||
`, | ||
content_bg: css` | ||
position: absolute; | ||
top: -200px; | ||
right: -150px; | ||
top: 0; | ||
right: 0; | ||
transform: translate(10%, -20%); | ||
`, | ||
content: css` | ||
display: flex; | ||
|
@@ -61,6 +67,15 @@ const useStyle = createStyles(({ token, css }) => { | |
width: 100%; | ||
margin-top: ${token.pcContainerMargin / 2}px; | ||
`, | ||
mobile_content: css` | ||
background: #0c0e10cc; | ||
border-radius: 24px; | ||
margin: ${token.marginXXL}px 0; | ||
|
||
img { | ||
width: 100%; | ||
} | ||
`, | ||
tab: css` | ||
width: 280px; | ||
display: flex; | ||
|
@@ -134,24 +149,29 @@ const SceneBanner: React.FC = () => { | |
const { styles } = useStyle(); | ||
const [locale] = useLocale(locales); | ||
|
||
const { isMobile } = React.useContext(SiteContext); | ||
|
||
const tabItems = [ | ||
{ | ||
key: 'independent', | ||
title: locale.independent_title, | ||
desc: locale.independent_desc, | ||
content: <Independent />, | ||
img: 'https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*YVjbTqbc7ngAAAAAAAAAAAAADgCCAQ/fmt.avif', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议优化图片资源处理 建议对图片资源进行以下优化:
+ interface TabImage {
+ src: string;
+ alt: string;
+ fallback?: string;
+ }
+ interface TabItem {
+ key: string;
+ title: string;
+ desc: string;
+ content: React.ReactNode;
+ img?: TabImage;
+ disabled?: boolean;
+ }
const tabItems: TabItem[] = [
{
key: 'independent',
title: locale.independent_title,
desc: locale.independent_desc,
content: <Independent />,
- img: 'https://mdn.alipayobjects.com/...',
+ img: {
+ src: 'https://mdn.alipayobjects.com/...',
+ alt: locale.independent_title,
+ fallback: '/fallback-image.png'
+ },
},
// ... 其他项目类似更新
]; Also applies to: 178-178, 185-185 |
||
}, | ||
{ | ||
key: 'assistant', | ||
title: locale.assistant_title, | ||
desc: locale.assistant_desc, | ||
content: <AssistantScene />, | ||
img: 'https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*kCojRo0SoAAAAAAAAAAAAAAADgCCAQ/fmt.avif', | ||
}, | ||
{ | ||
key: 'nest', | ||
title: locale.nest_title, | ||
desc: locale.nest_desc, | ||
content: <NestScene />, | ||
img: 'https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*krfsT5zBSuUAAAAAAAAAAAAADgCCAQ/fmt.avif', | ||
}, | ||
{ | ||
key: 'app', | ||
|
@@ -175,27 +195,40 @@ const SceneBanner: React.FC = () => { | |
src="https://mdn.alipayobjects.com/huamei_k0vkmw/afts/img/A*aSLTSr53DPAAAAAAAAAAAAAADsR-AQ/original" | ||
alt="bg" | ||
/> | ||
<div className={styles.content}> | ||
<div className={styles.tab}> | ||
{tabItems.map((item) => ( | ||
<Button | ||
key={item.key} | ||
disabled={item.disabled} | ||
className={classnames( | ||
styles.item, | ||
active === item.key && styles['item-active'], | ||
item.disabled && styles['item-disabled'], | ||
)} | ||
type="text" | ||
onClick={genHandleActive(item.key)} | ||
> | ||
<h3 className={styles.item_title}>{item.title}</h3> | ||
<p className={styles.item_desc}>{item.desc}</p> | ||
</Button> | ||
))} | ||
{isMobile ? ( | ||
<Carousel> | ||
{tabItems.map( | ||
(item) => | ||
item.img && ( | ||
<div className={styles.mobile_content}> | ||
<img src={item.img} alt="item.img" loading="lazy" /> | ||
</div> | ||
), | ||
)} | ||
</Carousel> | ||
) : ( | ||
<div className={styles.content}> | ||
<div className={styles.tab}> | ||
{tabItems.map((item) => ( | ||
<Button | ||
key={item.key} | ||
disabled={item.disabled} | ||
className={classnames( | ||
styles.item, | ||
active === item.key && styles['item-active'], | ||
item.disabled && styles['item-disabled'], | ||
)} | ||
type="text" | ||
onClick={genHandleActive(item.key)} | ||
> | ||
<h3 className={styles.item_title}>{item.title}</h3> | ||
<p className={styles.item_desc}>{item.desc}</p> | ||
</Button> | ||
))} | ||
</div> | ||
{!!activeContent && <div className={styles.tab_content}>{activeContent}</div>} | ||
</div> | ||
{!!activeContent && <div className={styles.tab_content}>{activeContent}</div>} | ||
</div> | ||
)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 移动端轮播组件实现需要增强用户体验 当前的轮播实现比较基础,建议增加以下功能来提升用户体验:
建议按如下方式增强轮播组件: - <Carousel>
+ <Carousel
+ dots={{ className: styles.carousel_dots }}
+ autoplay
+ autoplaySpeed={5000}
+ draggable
+ swipeToSlide
+ >
{tabItems.map(
(item) =>
item.img && (
<div className={styles.mobile_content}>
- <img src={item.img} alt="item.img" loading="lazy" />
+ <img
+ src={item.img.src}
+ alt={item.img.alt}
+ loading={item.img.loading}
+ />
</div>
),
)}
</Carousel>
|
||
</Container> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,9 @@ const useStyle = createStyles(({ token, css }) => { | |
return { | ||
layout: css` | ||
width: 100%; | ||
min-width: 1000px; | ||
height: 722px; | ||
border-radius: 8px; | ||
border-radius: ${token.borderRadius}px; | ||
Comment on lines
+46
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 需要优化响应式设计 设置固定的 建议修改如下: - min-width: 1000px;
+ min-width: ${token.screenXS}px;
+ @media (min-width: ${token.screenSM}px) {
+ min-width: 1000px;
+ }
|
||
display: flex; | ||
background: ${token.colorBgContainer}; | ||
font-family: AlibabaPuHuiTi, ${token.fontFamily}, sans-serif; | ||
|
@@ -72,7 +73,7 @@ const useStyle = createStyles(({ token, css }) => { | |
box-sizing: border-box; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 24px 0; | ||
padding: ${token.paddingLG}px; | ||
gap: 16px; | ||
`, | ||
messages: css` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
移动端适配验证完成,建议进一步优化!
根据代码库分析,发现以下情况:
.dumi/pages/index/common/Container.tsx
中的移动端适配是合适的建议:
🔗 Analysis chain
响应式设计实现得当!
媒体查询的添加很好地解决了移动端标题字体大小的适配问题,使用 token 来控制断点和字体大小也符合设计系统规范。
建议运行以下脚本,确认其他相关组件是否也需要类似的移动端适配:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 50
Script:
Length of output: 234
Script:
Length of output: 14518