Skip to content

Commit

Permalink
🧣feat:案例hook语言添加
Browse files Browse the repository at this point in the history
  • Loading branch information
durunsong committed Oct 16, 2024
1 parent e4c1543 commit 1c54830
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/i18n/package/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ const en = {
character: "Character",
Please_select_your_role: "Please select your role",
Selecting_a_Character: "Selecting a Character",
Get_Success: "Get Success",
error_occurs: "Error occurs",
};

export default en;
2 changes: 2 additions & 0 deletions src/i18n/package/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ const zh = {
character: "角色",
Please_select_your_role: "请选择你的角色",
Selecting_a_Character: "选择角色",
Get_Success: "获取成功",
error_occurs: "发生错误",
};

export default zh;
7 changes: 5 additions & 2 deletions src/service/hook-demo/use-fullscreen-loading.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import i18n from "@/i18n";
const { t } = i18n.global;

/** 模拟接口响应数据 */
const SUCCESS_RESPONSE_DATA = {
code: 0,
data: {
list: [] as number[],
},
message: "获取成功",
message: t("Get_Success"),
};

/** 模拟请求接口成功 */
Expand All @@ -20,7 +23,7 @@ export function getSuccessApi(list: number[]) {
export function getErrorApi() {
return new Promise((_resolve, reject) => {
setTimeout(() => {
reject(new Error("发生错误"));
reject(new Error(t("error_occurs")));
}, 1000);
});
}

0 comments on commit 1c54830

Please sign in to comment.