Skip to content

Commit 7cbec41

Browse files
committed
fix: v0.6.4 fix some bugs of infobox,add api error alert i18n support
1 parent c2debe6 commit 7cbec41

18 files changed

Lines changed: 686 additions & 603 deletions

File tree

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "reinamanager",
33
"private": true,
4-
"version": "0.6.3",
4+
"version": "0.6.4",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
@@ -12,12 +12,12 @@
1212
"dependencies": {
1313
"@emotion/react": "^11.14.0",
1414
"@emotion/styled": "^11.14.1",
15-
"@mui/icons-material": "^7.0.0",
16-
"@mui/material": "^7.0.0",
17-
"@mui/x-charts": "^8.0.0",
15+
"@mui/icons-material": "^7.3.1",
16+
"@mui/material": "^7.3.1",
17+
"@mui/x-charts": "^8.10.1",
1818
"@tauri-apps/api": "2.7.0",
1919
"@tauri-apps/plugin-autostart": "~2.5.0",
20-
"@tauri-apps/plugin-dialog": "~2.3.1",
20+
"@tauri-apps/plugin-dialog": "~2.3.2",
2121
"@tauri-apps/plugin-fs": "~2.4.1",
2222
"@tauri-apps/plugin-http": "^2.5.1",
2323
"@tauri-apps/plugin-shell": "~2.3.0",
@@ -30,20 +30,20 @@
3030
"react-activation": "^0.13.4",
3131
"react-dom": "^18.3.1",
3232
"react-i18next": "^15.6.1",
33-
"react-router": "^7.7.1",
34-
"zustand": "^5.0.6"
33+
"react-router": "^7.8.1",
34+
"zustand": "^5.0.7"
3535
},
3636
"devDependencies": {
37-
"@biomejs/biome": "^1.9.4",
38-
"@tauri-apps/cli": "^2.7.1",
39-
"@types/node": "^22.16.5",
37+
"@biomejs/biome": "^2.2.0",
38+
"@tauri-apps/cli": "^2.8.1",
39+
"@types/node": "^22.17.2",
4040
"@types/react": "^18.3.23",
4141
"@types/react-dom": "^18.3.7",
42-
"@vitejs/plugin-react-swc": "^4.0.0",
42+
"@vitejs/plugin-react-swc": "^4.0.1",
4343
"globals": "^15.15.0",
4444
"typescript": "~5.6.3",
4545
"unocss": "^66.4.2",
46-
"vite": "^7.0.0"
46+
"vite": "^7.1.3"
4747
},
4848
"pnpm": {
4949
"onlyBuiltDependencies": [

pnpm-lock.yaml

Lines changed: 500 additions & 540 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ReinaManager"
3-
version = "0.6.3"
3+
version = "0.6.4"
44
description = "A lightweight visual novel manager"
55
authors = ["huoshen80"]
66
license = "GNU AFFERO GENERAL PUBLIC LICENSE"
@@ -24,7 +24,7 @@ log = "0.4"
2424
tauri = { version = "^2.7.0", features = ["tray-icon"] }
2525
tauri-plugin-http = "2.5.1"
2626
tauri-plugin-log = "2.0.0-rc"
27-
tauri-plugin-dialog = "2"
27+
tauri-plugin-dialog = "^2.3.2"
2828
tauri-plugin-sql = { version = "2", features = ["sqlite"] }
2929
tauri-plugin-fs = "2"
3030
tauri-plugin-shell = "2"

src/api/bgm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import { tauriHttp } from './http'
1717
import pkg from '../../package.json'
18+
import i18n from '@/utils/i18n'
1819

1920
/**
2021
* 过滤掉包含敏感关键词的标签。
@@ -118,7 +119,7 @@ export async function fetchFromBgm(
118119
const BGMdata = Array.isArray(resp.data) ? resp.data[0] : undefined;
119120

120121
if (!BGMdata?.id) {
121-
return "未找到相关条目,请确认游戏名字后重试,或未设置BGM_TOKEN";
122+
return i18n.t('api.bgm.notFound', '未找到相关条目,请确认游戏名字后重试,或未设置BGM_TOKEN');
122123
}
123124

124125
// 直接从搜索结果构建返回对象

src/api/http.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import axios, { type AxiosError } from 'axios';
1919
import { fetch as tauriFetch } from '@tauri-apps/plugin-http';
20+
import i18n from '@/utils/i18n';
2021

2122
/**
2223
* 创建一个带有响应拦截器的 Axios 实例。
@@ -40,14 +41,14 @@ export const createHttp = ()=> {
4041
(error: AxiosError) => {
4142
if (error.response?.status === 401) {
4243
// 抛出自定义错误对象
43-
return Promise.reject(new Error("认证失败,请检查你的BGM_TOKEN是否正确"));
44+
return Promise.reject(new Error(i18n.t('api.http.authFailed', '认证失败,请检查你的BGM_TOKEN是否正确')));
4445
}
4546
if (error.response?.status === 400) {
4647
// 抛出自定义错误对象
47-
return Promise.reject(new Error("未找到相关条目,请确认ID或游戏名字后重试"));
48+
return Promise.reject(new Error(i18n.t('api.http.notFound', '未找到相关条目,请确认ID或游戏名字后重试')));
4849
}
4950
// 其他错误
50-
return Promise.reject(new Error("请求错误,请检查你的网络连接"));
51+
return Promise.reject(new Error(i18n.t('api.http.networkError', '请求错误,请检查你的网络连接')));
5152
}
5253
);
5354

@@ -124,16 +125,16 @@ export const tauriHttp = {
124125
* @param error 错误对象
125126
*/
126127
function handleTauriHttpError(error: unknown): never {
127-
const errorMessage = error instanceof Error ? error.message : '请求错误';
128+
const errorMessage = error instanceof Error ? error.message : i18n.t('api.http.requestError', '请求错误');
128129

129130
if (errorMessage.includes('401')) {
130-
throw new Error("认证失败,请检查你的BGM_TOKEN是否正确");
131+
throw new Error(i18n.t('api.http.authFailed', '认证失败,请检查你的BGM_TOKEN是否正确'));
131132
}
132133
if (errorMessage.includes('400')) {
133-
throw new Error("未找到相关条目,请确认ID或游戏名字后重试");
134+
throw new Error(i18n.t('api.http.notFound', '未找到相关条目,请确认ID或游戏名字后重试'));
134135
}
135136
console.error('Tauri HTTP 请求失败:', error);
136-
throw new Error("请求错误,请检查你的网络连接");
137+
throw new Error(i18n.t('api.http.networkError', '请求错误,请检查你的网络连接'));
137138
}
138139

139140
/**

src/api/mixed.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import { fetchFromBgm } from "./bgm";
2222
import { fetchFromVNDB } from "./vndb";
2323
import type { GameData } from "../types";
24+
import i18n from '@/utils/i18n';
2425

2526
const fetchMixedData = async (
2627
name: string,
@@ -63,15 +64,15 @@ const fetchMixedData = async (
6364

6465
// 确保至少有一个数据源成功
6566
if (!BGMdata && !VNDBdata) {
66-
throw new Error("无法从任何数据源获取游戏信息");
67+
throw new Error(i18n.t('api.mixed.noDataSource', '无法从任何数据源获取游戏信息'));
6768
}
6869

6970
// 合并数据
7071
return mergeData(BGMdata, VNDBdata);
7172

7273
} catch (error) {
7374
console.error("Mixed API 调用失败:", error instanceof Error ? error.message : error);
74-
return "获取数据失败,请稍后重试";
75+
return i18n.t('api.mixed.fetchError', '获取数据失败,请稍后重试');
7576
}
7677
};
7778

@@ -80,7 +81,7 @@ async function getBangumiData(name: string, BGM_TOKEN: string, bgm_id?: string):
8081
const BGMdata = await fetchFromBgm(name, BGM_TOKEN, bgm_id);
8182

8283
if (!BGMdata || typeof BGMdata === "string") {
83-
throw new Error(`Bangumi 数据获取失败: ${BGMdata}`);
84+
throw new Error(`${i18n.t('api.mixed.bgmFetchFailed', 'Bangumi 数据获取失败')}: ${BGMdata}`);
8485
}
8586

8687
return BGMdata;
@@ -100,7 +101,7 @@ async function getVNDBData(searchName: string, vndb_id?: string): Promise<GameDa
100101
const VNDBdata = await fetchFromVNDB(searchName, vndb_id);
101102

102103
if (!VNDBdata || typeof VNDBdata === "string") {
103-
throw new Error(`VNDB 数据获取失败: ${VNDBdata}`);
104+
throw new Error(`${i18n.t('api.mixed.vndbFetchFailed', 'VNDB 数据获取失败')}: ${VNDBdata}`);
104105
}
105106

106107
return VNDBdata;
@@ -121,7 +122,7 @@ function mergeData(BGMdata: GameData | null, VNDBdata: GameData | null): GameDat
121122
if (!BGMdata && VNDBdata) return VNDBdata;
122123
if (BGMdata && !VNDBdata) return BGMdata;
123124
if (!BGMdata && !VNDBdata) {
124-
throw new Error("没有可用的数据进行合并");
125+
throw new Error(i18n.t('api.mixed.noDataForMerge', '没有可用的数据进行合并'));
125126
}
126127

127128
// 两个数据源都有,进行合并(BGM 数据优先)

src/api/vndb.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* - time_now: 获取当前时间的工具函数
1515
*/
1616

17+
18+
import i18n from '@/utils/i18n'
1719
import http from './http'
1820

1921
/**
@@ -50,7 +52,7 @@ export async function fetchFromVNDB(name: string, id?: string) {
5052
'Content-Type': 'application/json'
5153
}
5254
})).data.results[0];
53-
if(!VNDBdata) return "未找到相关条目,请确认ID或游戏名字后重试";
55+
if(!VNDBdata) return i18n.t('api.vndb.notFound', '未找到相关条目,请确认ID或游戏名字后重试');
5456

5557
// 处理标题信息
5658
const titles = VNDBdata.titles.map((title:VNDB_title) => ({
@@ -89,11 +91,11 @@ export async function fetchFromVNDB(name: string, id?: string) {
8991
aveage_hours: Number((VNDBdata.length_minutes / 60).toFixed(1)),
9092
};
9193
} catch (error) {
92-
Promise.reject(new Error("VNDB API 调用失败"));
94+
Promise.reject(new Error(i18n.t('api.vndb.apiCallFailed', 'VNDB API 调用失败')));
9395
if (error instanceof Error) {
9496
console.error("错误消息:", error.message);
9597
}
96-
return "获取数据失败,请稍后重试";
98+
return i18n.t('api.vndb.fetchFailed', '获取数据失败,请稍后重试');
9799
}
98100
}
99101

src/components/AddModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const AddModal: React.FC = () => {
217217
<RadioGroup className='ml-2' row value={apiSource} onChange={(e) => setApiSource(e.target.value as 'bgm' | 'vndb' | 'mixed')}>
218218
<FormControlLabel value="bgm" control={<Radio />} label="Bangumi" />
219219
<FormControlLabel value="vndb" control={<Radio />} label="VNDB" />
220-
<FormControlLabel value="mixed" control={<Radio />} label="Mixed" disabled={!bgmToken} />
220+
<FormControlLabel value="mixed" control={<Radio />} label="Mixed" />
221221
</RadioGroup>
222222
<Switch checked={isID} onChange={() => {
223223
setisID(!isID)

src/locales/en_US.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@
77
"settings": "Settings"
88
}
99
},
10+
"api": {
11+
"bgm": {
12+
"notFound": "No related entries found, please check the game name and try again, or BGM_TOKEN is not set"
13+
},
14+
"vndb": {
15+
"notFound": "No related entries found, please check the ID or game name and try again",
16+
"fetchFailed": "Failed to fetch data, please try again later",
17+
"apiCallFailed": "VNDB API call failed"
18+
},
19+
"http": {
20+
"notFound": "No related entries found, please check the ID or game name and try again",
21+
"authFailed": "Authentication failed, please check your BGM_TOKEN",
22+
"networkError": "Request error, please check your network connection",
23+
"requestError": "Request error"
24+
},
25+
"mixed": {
26+
"fetchError": "Failed to fetch data",
27+
"noDataSource": "Unable to get game information from any data source",
28+
"bgmFetchFailed": "Failed to fetch Bangumi data",
29+
"vndbFetchFailed": "Failed to fetch VNDB data",
30+
"noDataForMerge": "No available data for merging"
31+
}
32+
},
1033
"pages": {
1134
"Settings": {
1235
"language": "Language",
@@ -118,7 +141,9 @@
118141
"pathUpdateFailed": "Failed to update path",
119142
"autoSaveEnabled": "Auto backup enabled",
120143
"autoSaveDisabled": "Auto backup disabled",
121-
"autoSaveUpdateFailed": "Failed to update auto backup setting"
144+
"autoSaveUpdateFailed": "Failed to update auto backup setting",
145+
"openBackupFolder": "Open Backup Folder",
146+
"openSaveDataFolder": "Open Save Data Folder"
122147
}
123148
}
124149
},

0 commit comments

Comments
 (0)