translate comment
This commit is contained in:
@@ -28,7 +28,7 @@ export default function HomeClient({ messages,lang }: PageContentProps) {
|
||||
{/* App Section */}
|
||||
<section id="clipboard-app" className="py-12" aria-label="File Transfer Application">
|
||||
<div className="container mx-auto px-4">
|
||||
{/* sr-only--screen-only:视觉不可见 */}
|
||||
{/* sr-only--screen-only: visually hidden */}
|
||||
<h2 className={cn("sr-only", "text-3xl font-bold mb-8 text-center")}>
|
||||
{messages.text.home.h2_screenOnly}
|
||||
</h2>
|
||||
@@ -82,7 +82,7 @@ export default function HomeClient({ messages,lang }: PageContentProps) {
|
||||
<FAQSection
|
||||
messages={messages}
|
||||
isMainPage
|
||||
titleClassName="text-2xl md:text-3xl" // 可选:在首页使用稍小的字号
|
||||
titleClassName="text-2xl md:text-3xl"
|
||||
/>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
@@ -11,7 +11,7 @@ export async function generateMetadata({
|
||||
const post = await getPostBySlug(params.slug)
|
||||
|
||||
if (!post) {//blog not found
|
||||
// 调用博客首页的 generateMetadata 函数并传入参数
|
||||
// Call the generateMetadata function of the blog homepage and pass in the parameters
|
||||
return generateBlogMetadata({ params: { lang: params.lang } })
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//文章详情页
|
||||
//Article detail page
|
||||
import { MDXRemote } from 'next-mdx-remote/rsc'
|
||||
import { getPostBySlug } from '@/lib/blog'
|
||||
import * as React from 'react'
|
||||
@@ -18,9 +18,9 @@ export default async function BlogPost({ params }: { params: { slug: string } })
|
||||
|
||||
return (
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 py-8">
|
||||
{/* 使用 md: 前缀来处理中等屏幕及以上的flex布局 */}
|
||||
{/* Use md: prefix to handle flex layout for medium screens and above */}
|
||||
<div className="block md:flex md:gap-8">
|
||||
{/* 文章内容区域 */}
|
||||
{/* Article content area */}
|
||||
<article className="w-full md:flex-1 max-w-4xl">
|
||||
<header className="mb-8">
|
||||
<h1 className="text-3xl sm:text-4xl font-bold mb-4 text-gray-900">
|
||||
|
||||
@@ -14,17 +14,17 @@ export default async function BlogPage({
|
||||
const posts = await getAllPosts(lang)
|
||||
|
||||
return (
|
||||
<div className="max-w-[1400px] mx-auto px-4 sm:px-6 lg:px-8 py-12"> {/* 增大最大宽度和内边距 */}
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-12"> {/* 增大列间距 */}
|
||||
<div className="max-w-[1400px] mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-12">
|
||||
{/* Main Content */}
|
||||
<main className="lg:col-span-8">
|
||||
<div className="mb-12"> {/* 增大标题区域间距 */}
|
||||
<h1 className="text-4xl font-bold mb-4">Blog</h1> {/* 增大标题字号 */}
|
||||
<div className="mb-12">
|
||||
<h1 className="text-4xl font-bold mb-4">Blog</h1>
|
||||
<p className="text-gray-600 text-lg">Latest articles and updates</p>
|
||||
</div>
|
||||
|
||||
{/* Articles List */}
|
||||
<div className="space-y-12"> {/* 增大文章间距 */}
|
||||
<div className="space-y-12">
|
||||
{posts.map((post) => (
|
||||
<ArticleListItem key={post.slug} post={post} />
|
||||
))}
|
||||
@@ -35,7 +35,7 @@ export default async function BlogPage({
|
||||
<aside className="lg:col-span-4">
|
||||
<div className="sticky top-8">
|
||||
{/* Recent Posts */}
|
||||
<div className="bg-white rounded-xl shadow-lg p-8 mb-8"> {/* 修改圆角和内边距 */}
|
||||
<div className="bg-white rounded-xl shadow-lg p-8 mb-8">
|
||||
<h2 className="text-xl font-bold mb-6">Recent Posts</h2>
|
||||
<div className="space-y-4">
|
||||
{posts.slice(0, 5).map((post) => (
|
||||
@@ -53,11 +53,11 @@ export default async function BlogPage({
|
||||
<div className="bg-white rounded-xl shadow-lg p-8">
|
||||
<h2 className="text-xl font-bold mb-6">Tags</h2>
|
||||
<div className="space-y-3">
|
||||
{/* 获取所有标签并去重 */}
|
||||
{/* Get all tags and deduplicate */}
|
||||
{Array.from(new Set(posts.flatMap(p => p.frontmatter.tags))).map((tag) => (
|
||||
<Link
|
||||
key={tag}
|
||||
href={`/${lang}/blog/tag/${slugifyTag(tag)}`} // 跳转到标签过滤页面
|
||||
href={`/${lang}/blog/tag/${slugifyTag(tag)}`} // Jump to the tag filtering page
|
||||
className="flex items-center justify-between hover:text-blue-600"
|
||||
>
|
||||
<span className="text-gray-700 font-medium">{tag}</span>
|
||||
|
||||
@@ -37,7 +37,7 @@ export default async function RootLayout({
|
||||
<>
|
||||
<Script
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${googleAnalyticsId}`}
|
||||
strategy="afterInteractive" // 脚本在页面加载后执行
|
||||
strategy="afterInteractive" // The script executes after the page is interactive.
|
||||
/>
|
||||
<Script id="google-analytics" strategy="afterInteractive">
|
||||
{`
|
||||
|
||||
@@ -21,7 +21,7 @@ export async function generateMetadata({
|
||||
supportedLocales.map(lang => [lang, `/${lang}`])
|
||||
),
|
||||
},
|
||||
//OpenGraph元数据可以优化社交媒体分享
|
||||
//OpenGraph metadata can optimize social media sharing
|
||||
openGraph: {
|
||||
title: messages.meta.home.title,
|
||||
description: messages.meta.home.description,
|
||||
|
||||
+10
-10
@@ -9,7 +9,7 @@ export const API_ROUTES = {
|
||||
set_track: `${API_URL}/api/set_track`,
|
||||
logs_debug: `${API_URL}/api/logs_debug`,
|
||||
};
|
||||
// 统一的 API 调用处理器
|
||||
// Unified API call handler
|
||||
async function apiCall<T>(
|
||||
url: string,
|
||||
options: RequestInit = {}
|
||||
@@ -18,14 +18,14 @@ async function apiCall<T>(
|
||||
const response = await fetch(url, options);
|
||||
|
||||
if (!response.ok) {
|
||||
// 如果服务器返回非 2xx 状态码, 抛出错误
|
||||
const errorData = await response.text(); // 尝试获取错误文本
|
||||
// If the server returns a non-2xx status code, throw an error
|
||||
const errorData = await response.text(); // Attempt to get the error text
|
||||
throw new Error(
|
||||
`API call failed with status ${response.status}: ${errorData}`
|
||||
);
|
||||
}
|
||||
|
||||
// 某些响应可能没有内容体(例如 204 No Content), 需特殊处理
|
||||
// Some responses may not have a body (e.g., 204 No Content), which needs special handling
|
||||
if (
|
||||
response.status === 204 ||
|
||||
response.headers.get("content-length") === "0"
|
||||
@@ -36,11 +36,11 @@ async function apiCall<T>(
|
||||
return (await response.json()) as T;
|
||||
} catch (error) {
|
||||
console.error(`Error in apiCall for URL: ${url}`, error);
|
||||
return null; // 在发生任何错误时返回 null, 使调用方可以优雅地处理
|
||||
return null; // Return null on any error, so the caller can handle it gracefully
|
||||
}
|
||||
}
|
||||
|
||||
// 获取一个随机的可用房间ID
|
||||
// Get a random available room ID
|
||||
export const fetchRoom = async (): Promise<string | null> => {
|
||||
const data = await apiCall<{ roomId: string }>(
|
||||
API_ROUTES.get_room,
|
||||
@@ -49,7 +49,7 @@ export const fetchRoom = async (): Promise<string | null> => {
|
||||
return data?.roomId ?? null;
|
||||
};
|
||||
|
||||
// 创建指定ID的房间
|
||||
// Create a room with a specified ID
|
||||
export const createRoom = async (roomId: string): Promise<boolean> => {
|
||||
const options = getFetchOptions({
|
||||
method: "POST",
|
||||
@@ -62,7 +62,7 @@ export const createRoom = async (roomId: string): Promise<boolean> => {
|
||||
return data?.success ?? false;
|
||||
};
|
||||
|
||||
// 检查房间是否可用
|
||||
// Check if a room is available
|
||||
export const checkRoom = async (roomId: string): Promise<boolean> => {
|
||||
const options = getFetchOptions({
|
||||
method: "POST",
|
||||
@@ -75,7 +75,7 @@ export const checkRoom = async (roomId: string): Promise<boolean> => {
|
||||
return data?.available ?? false;
|
||||
};
|
||||
|
||||
// 设置追踪信息
|
||||
// Set tracking information
|
||||
export const setTrack = async (ref: string, path: string) => {
|
||||
const options = getFetchOptions({
|
||||
method: "POST",
|
||||
@@ -84,7 +84,7 @@ export const setTrack = async (ref: string, path: string) => {
|
||||
return apiCall<void>(API_ROUTES.set_track, options);
|
||||
};
|
||||
|
||||
// 记录调试日志
|
||||
// Log debug messages
|
||||
export const postLogInDebug = async (message: string) => {
|
||||
const options = getFetchOptions({
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user