chore: notice i18n

This commit is contained in:
Slinetrac
2025-10-31 13:04:21 +08:00
Unverified
parent 73e53eb33f
commit 534e8d3de6
7 changed files with 127 additions and 24 deletions

View File

@@ -66,12 +66,16 @@ export const ProviderButton = () => {
await refreshProxy();
await refreshProxyProviders();
showNotice("success", `${name} 更新成功`);
showNotice("success", {
i18nKey: "notice.provider.updateSuccess",
params: { name },
});
} catch (err: any) {
showNotice(
"error",
`${name} 更新失败: ${err?.message || err.toString()}`,
);
const message = err?.message || err?.toString?.() || String(err);
showNotice("error", {
i18nKey: "notice.provider.updateFailed",
params: { name, message },
});
} finally {
// 清除更新状态
setUpdating((prev) => ({ ...prev, [name]: false }));
@@ -84,7 +88,9 @@ export const ProviderButton = () => {
// 获取所有provider的名称
const allProviders = Object.keys(proxyProviders || {});
if (allProviders.length === 0) {
showNotice("info", "没有可更新的代理提供者");
showNotice("info", {
i18nKey: "notice.provider.none",
});
return;
}
@@ -114,9 +120,15 @@ export const ProviderButton = () => {
await refreshProxy();
await refreshProxyProviders();
showNotice("success", "全部代理提供者更新成功");
showNotice("success", {
i18nKey: "notice.provider.allUpdated",
});
} catch (err: any) {
showNotice("error", `更新失败: ${err?.message || err.toString()}`);
const message = err?.message || err?.toString?.() || String(err);
showNotice("error", {
i18nKey: "notice.provider.genericError",
params: { message },
});
} finally {
// 清除所有更新状态
setUpdating({});