-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: use internal footer resources #40
Conversation
Walkthrough此次更改引入了两个新的 HTML 文件,分别为英文和中文的页脚组件。每个文件都包含完整的 HTML 结构,包括头部和主体,主体中有多个链接和社交媒体图标。CSS 样式确保了响应式设计,适应不同屏幕尺寸。同时, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant FooterComponent
participant FetchService
User->>FooterComponent: 请求页脚内容
FooterComponent->>FetchService: 获取对应语言的页脚
FetchService-->>FooterComponent: 返回页脚 HTML
FooterComponent-->>User: 显示页脚内容
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 5
🧹 Outside diff range comments (2)
src/components/Footer/Footer.tsx (1)
Line range hint
18-31
: 建议添加错误处理和加载状态当前实现可以通过以下方面进行增强:
- 添加加载状态指示
- 在获取失败时显示备用内容
- 添加重试机制
建议按如下方式重构:
+ const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState<Error | null>(null); useEffect(() => { + setIsLoading(true); + setError(null); fetch(`/footer/${LOCALE_MAPPING[intl.locale as ILocale]}.html`) .then((response) => { + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } return response.text(); }) .then((data) => { const element = containerRef.current; if (!element) { return; } const shadowRoot = element.shadowRoot ?? element.attachShadow({ mode: 'open' }); shadowRoot.innerHTML = data; + setIsLoading(false); }) - .catch(console.error); + .catch((error) => { + setError(error); + setIsLoading(false); + console.error('Footer loading failed:', error); + }); }, [intl.locale]); + if (isLoading) { + return <div>加载中...</div>; + } + if (error) { + return <div>页脚加载失败,请刷新页面重试</div>; + }public/footer/en.html (1)
Line range hint
1460-1465
: 优化社交媒体链接的可访问性在社交媒体链接的
<a>
标签中,建议添加aria-label
属性,以提高辅助技术对链接的识别。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (3)
public/footer/en.html
(1 hunks)public/footer/zh.html
(1 hunks)src/components/Footer/Footer.tsx
(1 hunks)
🔇 Additional comments (3)
src/components/Footer/Footer.tsx (2)
8-9
: 区域映射更新简化了命名方式
区域映射值的更改更加简洁明了,与文件系统的组织结构相匹配。
18-18
: URL 构建方式更加清晰
移除 BASE_URL 常量并使用相对路径是个很好的改进,使代码更加简洁和可维护。
public/footer/en.html (1)
991-1261
: 检查链接的有效性
请确认所有的超链接都指向正确的URL,避免出现死链或错误链接。
Summary by CodeRabbit
新功能
改进
修复