diff --git a/README.en.md b/README.en.md
index 7683db8..a2238de 100644
--- a/README.en.md
+++ b/README.en.md
@@ -35,9 +35,9 @@ Visit: [https://mirror.starset.fans](https://mirror.starset.fans)
```
homepage
├── data/ # Content files
-│ ├── zh-CN/ # Simplified Chinese data
-│ ├── zh-TW/ # Traditional Chinese data
-│ └── en-US/ # English data
+│ ├── zh-Hans/ # Simplified Chinese data
+│ ├── zh-Hant/ # Traditional Chinese data
+│ └── en/ # English data
├── src/ # Source code
├── public/ # Static assets
├── docs/ # Documentation
diff --git a/README.md b/README.md
index 373b908..4aaf999 100644
--- a/README.md
+++ b/README.md
@@ -35,9 +35,9 @@ pnpm build
```
homepage
├── data/ # 内容文件
-│ ├── zh-CN/ # 简体中文数据
-│ ├── zh-TW/ # 繁体中文数据
-│ └── en-US/ # 英文数据
+│ ├── zh-Hans/ # 简体中文数据
+│ ├── zh-Hant/ # 繁体中文数据
+│ └── en/ # 英文数据
├── src/ # 源代码
├── public/ # 静态资源
├── docs/ # 文档
diff --git a/README.zh-Hant.md b/README.zh-Hant.md
index 43f0500..bd520a8 100644
--- a/README.zh-Hant.md
+++ b/README.zh-Hant.md
@@ -35,9 +35,9 @@ pnpm build
```
homepage
├── data/ # 內容文件
-│ ├── zh-CN/ # 簡體中文資料
-│ ├── zh-TW/ # 繁體中文資料
-│ └── en-US/ # 英文資料
+│ ├── zh-Hans/ # 簡體中文資料
+│ ├── zh-Hant/ # 繁體中文資料
+│ └── en/ # 英文資料
├── src/ # 原始碼
├── public/ # 靜態資源
├── docs/ # 文件
diff --git a/src/components/Timeline.tsx b/src/components/Timeline.tsx
index 582f08c..dbf51fa 100644
--- a/src/components/Timeline.tsx
+++ b/src/components/Timeline.tsx
@@ -216,7 +216,8 @@ const Timeline = () => {
>
) : (
-
{t('updates.notFound.title')}
+
{t('updates.notFound.title')}
+
{t('updates.notFound.description')}
)}
diff --git a/src/utils/updates.ts b/src/utils/updates.ts
index e65cbcf..0a115f2 100644
--- a/src/utils/updates.ts
+++ b/src/utils/updates.ts
@@ -18,19 +18,28 @@ interface UpdatesIndex {
years: string[];
}
+// Map i18n language codes to data directory paths
+const LANGUAGE_CODE_MAP: Record = {
+ 'zh-CN': 'zh-Hans',
+ 'zh-TW': 'zh-Hant',
+ 'en': 'en',
+ 'en-US': 'en'
+};
+
// 获取更新年份列表
const getUpdateYears = async (language: string): Promise => {
try {
- const response = await fetch(`/data/${language}/updates.json`);
+ // Map the language code to the correct data directory path
+ const dataLanguage = LANGUAGE_CODE_MAP[language] || language;
+
+ const response = await fetch(`/data/${dataLanguage}/updates.json`);
if (!response.ok) {
throw new Error(`Failed to load updates index, status: ${response.status}`);
}
const index: UpdatesIndex = await response.json();
return index.years || [];
} catch (error) {
- if (process.env.NODE_ENV === 'development') {
- console.warn(`Failed to load updates index:`, error);
- }
+ console.warn(`Failed to load updates index:`, error);
return [];
}
};
@@ -38,16 +47,17 @@ const getUpdateYears = async (language: string): Promise => {
// 动态获取指定的年度更新
const getYearUpdates = async (yearFile: string, language: string): Promise => {
try {
- const response = await fetch(`/data/${language}/updates/${yearFile}`);
+ // Map the language code to the correct data directory path
+ const dataLanguage = LANGUAGE_CODE_MAP[language] || language;
+
+ const response = await fetch(`/data/${dataLanguage}/updates/${yearFile}`);
if (!response.ok) {
throw new Error(`Failed to load updates from ${yearFile}, status: ${response.status}`);
}
const data: YearUpdates = await response.json();
return data;
} catch (error) {
- if (process.env.NODE_ENV === 'development') {
- console.warn(`Failed to load updates from ${yearFile}:`, error);
- }
+ console.warn(`Failed to load updates from ${yearFile}:`, error);
return null;
}
};
@@ -85,6 +95,9 @@ export const useUpdates = (page: number = 1, pageSize: number = 10) => {
const { data: allUpdates = [], isLoading, error } = useQuery({
queryKey: ['updates', i18n.language],
queryFn: () => getAllUpdates(i18n.language),
+ staleTime: 5 * 60 * 1000, // Cache for 5 minutes
+ retry: 3, // Retry failed requests up to 3 times
+ retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 10000), // Exponential backoff
});
const getPaginatedUpdates = (selectedTags: string[] = []) => {