From 37d408f6bd9d70a928719a8440ca90edf7dc1ee4 Mon Sep 17 00:00:00 2001 From: "web@ppanel" Date: Fri, 13 Dec 2024 23:33:11 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(request):=20Locale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/locales/en-US/common.json | 49 ++++++++++++++++------------ apps/admin/locales/zh-CN/common.json | 47 +++++++++++++++----------- apps/admin/utils/request.ts | 5 ++- apps/user/locales/en-US/common.json | 49 ++++++++++++++++------------ apps/user/locales/zh-CN/common.json | 47 +++++++++++++++----------- apps/user/utils/request.ts | 5 ++- 6 files changed, 122 insertions(+), 80 deletions(-) diff --git a/apps/admin/locales/en-US/common.json b/apps/admin/locales/en-US/common.json index 3262bb1..edcda9a 100644 --- a/apps/admin/locales/en-US/common.json +++ b/apps/admin/locales/en-US/common.json @@ -16,26 +16,35 @@ "This empty space is waiting for its star to take the stage!" ], "request": { - "10001": "Database query failed, please try again later", - "10002": "Data update failed, please try again later", - "10003": "Data save failed, please try again later", - "10004": "Data deletion failed, please try again later", - "20001": "The username is already registered", - "20002": "User not found", - "20003": "Incorrect password, please try again", - "20004": "Your account has been disabled", - "30001": "Node already exists", - "30002": "Node not found", - "30003": "Node group already exists", - "30004": "Node group not found", - "30005": "There is data in the node group, cannot be deleted", - "400": "Invalid request parameters, please check and resubmit", - "40002": "Please retry after logging in", - "40003": "Invalid login information, please log in again", - "40004": "Login session expired, please log in again", - "401": "Request is too frequent, please try again later", - "500": "Internal server error, we are working on fixing it urgently", - "undefined": "System error occurred, please try again later" + "10001": "Query was not successful, please try again later or check your conditions.", + "10002": "Update operation was not successful, please try again later.", + "10003": "Insert operation cannot be completed at the moment, please try again later.", + "10004": "Deletion operation could not be completed, please try again later.", + "20001": "The user information already exists, please retry with different information.", + "20002": "User not found, please check the information and try again.", + "20003": "Incorrect password, please re-enter.", + "20004": "The user is disabled, please contact customer service if you have questions.", + "20005": "Insufficient balance, please recharge and try again.", + "20006": "The registration function is temporarily unavailable, please try again later.", + "30001": "The node already exists, please do not add it again.", + "30002": "Related node not found, please check and try again.", + "30003": "Group already exists, please try using a different name.", + "30004": "Group not found, please verify the information and try again.", + "30005": "There is still content in the group, please clear it and try again.", + "400": "The request parameters are incorrect, please check and resubmit.", + "40002": "Valid Token not found, please log in before retrying.", + "40003": "Current Token is invalid, please reacquire before trying again.", + "40004": "Token has expired, please log in again.", + "40005": "You do not have access permission, please contact the administrator if you have any questions.", + "401": "Request is too frequent, please try again later.", + "500": "The server is having some issues, please try again later.", + "50001": "Corresponding coupon information not found, please check and try again.", + "50002": "The coupon has been used, cannot be used again.", + "60001": "Subscription has expired, please renew before using.", + "60002": "Unable to use the subscription at the moment, please try again later.", + "70001": "Incorrect verification code, please re-enter.", + "80001": "Task was not successfully queued, please try again later.", + "undefined": "An error occurred in the system, please try again later." }, "table": { "actions": "Actions", diff --git a/apps/admin/locales/zh-CN/common.json b/apps/admin/locales/zh-CN/common.json index 2e3578b..fdcd60c 100644 --- a/apps/admin/locales/zh-CN/common.json +++ b/apps/admin/locales/zh-CN/common.json @@ -16,25 +16,34 @@ "这片空地在等它的主角登场!" ], "request": { - "10001": "数据库查询失败,请稍后重试", - "10002": "数据更新失败,请稍后重试", - "10003": "数据保存失败,请稍后重试", - "10004": "数据删除失败,请稍后重试", - "20001": "该用户名已被注册", - "20002": "找不到该用户", - "20003": "密码错误,请重新输入", - "20004": "您的账号已被禁用", - "30001": "该节点已存在", - "30002": "找不到该节点", - "30003": "该节点组已存在", - "30004": "找不到该节点组", - "30005": "节点组中还有数据,无法删除", - "400": "请求参数有误,请检查后重新提交", - "40002": "请登录后重试", - "40003": "登录信息无效,请重新登录", - "40004": "登录已过期,请重新登录", - "401": "请求过于频繁,请稍后重试", - "500": "系统内部错误,我们正在紧急修复", + "10001": "查询暂未成功,请稍后重试或检查您的条件。", + "10002": "更新操作未成功,请稍后再试。", + "10003": "暂时无法完成插入操作,请稍后再试。", + "10004": "删除操作未能完成,请稍后再试。", + "20001": "该用户信息已存在,请更换信息后重试。", + "20002": "未找到该用户,请核对信息后再试。", + "20003": "您输入的密码不正确,请重新输入。", + "20004": "该用户已被禁用,如有疑问请联系客服。", + "20005": "余额不足,请充值后再次尝试。", + "20006": "注册功能暂不可用,请稍后再试。", + "30001": "该节点已存在,请勿重复添加。", + "30002": "未找到相关节点,请检查后重试。", + "30003": "分组已存在,请尝试使用其他名称。", + "30004": "未找到该分组,请确认信息后重试。", + "30005": "该分组内仍有内容,请清空后再试。", + "400": "请求参数不正确,请检查并重新提交。", + "40002": "未找到有效的Token,请先登录再重试。", + "40003": "当前Token无效,请重新获取后再尝试。", + "40004": "Token已过期,请重新登录。", + "40005": "您暂无访问权限,如有疑问请联系管理员。", + "401": "请求过于频繁,请稍后再尝试。", + "500": "服务器遇到一些问题,请稍后再试。", + "50001": "找不到对应的优惠券信息,请检查后再试。", + "50002": "该优惠券已被使用,无法重复使用。", + "60001": "订阅已过期,请续订后再使用。", + "60002": "暂时无法使用该订阅,请稍后再试。", + "70001": "验证码有误,请重新输入。", + "80001": "任务未成功加入队列,请稍后重试。", "undefined": "系统发生错误,请稍后重试" }, "table": { diff --git a/apps/admin/utils/request.ts b/apps/admin/utils/request.ts index 4bb3d6d..33d32e3 100644 --- a/apps/admin/utils/request.ts +++ b/apps/admin/utils/request.ts @@ -40,7 +40,10 @@ requset.interceptors.request.use( requset.interceptors.response.use( async (response) => { const { code } = response.data; - if (code !== 200) throw response; + if (code !== 200) { + await handleError(response); + throw response; + } return response; }, async (error) => { diff --git a/apps/user/locales/en-US/common.json b/apps/user/locales/en-US/common.json index 32df615..d90e6c2 100644 --- a/apps/user/locales/en-US/common.json +++ b/apps/user/locales/en-US/common.json @@ -18,26 +18,35 @@ }, "login": "Log in / Sign up", "request": { - "10001": "Database query failed, please try again later", - "10002": "Data update failed, please try again later", - "10003": "Data save failed, please try again later", - "10004": "Data deletion failed, please try again later", - "20001": "The username has already been registered", - "20002": "User not found", - "20003": "Incorrect password, please re-enter", - "20004": "Your account has been disabled", - "30001": "The node already exists", - "30002": "Node not found", - "30003": "The node group already exists", - "30004": "Node group not found", - "30005": "There is still data in the node group, cannot be deleted", - "400": "Request parameters are incorrect, please check and resubmit", - "40002": "Please retry after logging in", - "40003": "Invalid login information, please log in again", - "40004": "Login session has expired, please log in again", - "401": "Request is too frequent, please try again later", - "500": "Internal system error, we are urgently fixing it", - "undefined": "System error occurred, please try again later" + "10001": "Unable to retrieve data at the moment, please try again later or check your conditions.", + "10002": "Update operation was unsuccessful, please try again later.", + "10003": "Insert operation cannot be completed at the moment, please try again later.", + "10004": "Delete operation was not successful, please try again later.", + "20001": "User information already exists, please try again with different information.", + "20002": "User not found, please verify the information and try again.", + "20003": "Incorrect password, please re-enter.", + "20004": "User is disabled, please contact customer service if you have any questions.", + "20005": "Insufficient balance, please recharge and try again.", + "20006": "Registration function is temporarily unavailable, please try again later.", + "30001": "Node already exists, please do not add it again.", + "30002": "Related node not found, please check and try again.", + "30003": "Group already exists, please try using a different name.", + "30004": "Group not found, please verify the information and try again.", + "30005": "The group still contains content, please clear it and try again.", + "400": "Request parameters are incorrect, please check and resubmit.", + "40002": "Valid token not found, please log in first and try again.", + "40003": "Current token is invalid, please get a new one and try again.", + "40004": "Token has expired, please log in again.", + "40005": "You do not have permission to access, please contact an administrator if you have any questions.", + "401": "Request is too frequent, please try again later.", + "500": "The server is experiencing some issues, please try again later.", + "50001": "Coupon information not found, please check and try again.", + "50002": "The coupon has already been used and cannot be reused.", + "60001": "Subscription has expired, please renew before using.", + "60002": "Unable to use the subscription at the moment, please try again later.", + "70001": "Incorrect verification code, please re-enter.", + "80001": "Task could not be successfully added to the queue, please try again later.", + "undefined": "An error occurred in the system, please try again later." }, "unlimited": "Unlimited" } diff --git a/apps/user/locales/zh-CN/common.json b/apps/user/locales/zh-CN/common.json index 24943af..2c82a65 100644 --- a/apps/user/locales/zh-CN/common.json +++ b/apps/user/locales/zh-CN/common.json @@ -18,25 +18,34 @@ }, "login": "登录/注册", "request": { - "10001": "数据库查询失败,请稍后重试", - "10002": "数据更新失败,请稍后重试", - "10003": "数据保存失败,请稍后重试", - "10004": "数据删除失败,请稍后重试", - "20001": "该用户名已被注册", - "20002": "找不到该用户", - "20003": "密码错误,请重新输入", - "20004": "您的账号已被禁用", - "30001": "该节点已存在", - "30002": "找不到该节点", - "30003": "该节点组已存在", - "30004": "找不到该节点组", - "30005": "节点组中还有数据,无法删除", - "400": "请求参数有误,请检查后重新提交", - "40002": "请登录后重试", - "40003": "登录信息无效,请重新登录", - "40004": "登录已过期,请重新登录", - "401": "请求过于频繁,请稍后重试", - "500": "系统内部错误,我们正在紧急修复", + "10001": "查询暂未成功,请稍后重试或检查您的条件。", + "10002": "更新操作未成功,请稍后再试。", + "10003": "暂时无法完成插入操作,请稍后再试。", + "10004": "删除操作未能完成,请稍后再试。", + "20001": "该用户信息已存在,请更换信息后重试。", + "20002": "未找到该用户,请核对信息后再试。", + "20003": "您输入的密码不正确,请重新输入。", + "20004": "该用户已被禁用,如有疑问请联系客服。", + "20005": "余额不足,请充值后再次尝试。", + "20006": "注册功能暂不可用,请稍后再试。", + "30001": "该节点已存在,请勿重复添加。", + "30002": "未找到相关节点,请检查后重试。", + "30003": "分组已存在,请尝试使用其他名称。", + "30004": "未找到该分组,请确认信息后重试。", + "30005": "该分组内仍有内容,请清空后再试。", + "400": "请求参数不正确,请检查并重新提交。", + "40002": "未找到有效的Token,请先登录再重试。", + "40003": "当前Token无效,请重新获取后再尝试。", + "40004": "Token已过期,请重新登录。", + "40005": "您暂无访问权限,如有疑问请联系管理员。", + "401": "请求过于频繁,请稍后再尝试。", + "500": "服务器遇到一些问题,请稍后再试。", + "50001": "找不到对应的优惠券信息,请检查后再试。", + "50002": "该优惠券已被使用,无法重复使用。", + "60001": "订阅已过期,请续订后再使用。", + "60002": "暂时无法使用该订阅,请稍后再试。", + "70001": "验证码有误,请重新输入。", + "80001": "任务未成功加入队列,请稍后重试。", "undefined": "系统发生错误,请稍后重试" }, "unlimited": "无限制" diff --git a/apps/user/utils/request.ts b/apps/user/utils/request.ts index 7f7fc37..1f05383 100644 --- a/apps/user/utils/request.ts +++ b/apps/user/utils/request.ts @@ -41,7 +41,10 @@ requset.interceptors.request.use( requset.interceptors.response.use( async (response) => { const { code } = response.data; - if (code !== 200) throw response; + if (code !== 200) { + await handleError(response); + throw response; + } return response; }, async (error) => {