From 8bace630e0228454832da4fb3f87ff6acb2eb0bc Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Wed, 20 Jul 2022 19:56:56 +0800 Subject: [PATCH] i18n: file operation --- public/locales/en-US/common.json | 7 +++++++ public/locales/zh-CN/common.json | 7 +++++++ src/component/Uploader/core/errors/index.ts | 10 ++++------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/public/locales/en-US/common.json b/public/locales/en-US/common.json index bf7c1c0..b8947df 100644 --- a/public/locales/en-US/common.json +++ b/public/locales/en-US/common.json @@ -16,12 +16,17 @@ "artPlayerLocaleCode": "en", "errors": { "404": "Resource not found.", + "409": "Conflict. ({{message}})", "40001": "Invalid input parameters ({{message}}).", "40002": "Upload failed.", "40003": "Failed to create folder.", "40004": "Object with the same name already exist.", "40006": "Not supported policy type.", "40007": "Current group have no permission to perform such action.", + "40011": "Upload session not exist or expired.", + "40012": "Invalid chunk index. ({{message}})", + "40013": "Invalid content length. ({{message}})", + "40014": "Exceed batch size limit of getting source link.", "40015": "Exceed aria2 batch size limit.", "40016": "Path not found.", "40017": "This account has been blocked.", @@ -54,6 +59,8 @@ "40053": "Cannot perform such action on root folder", "40054": "File with the same name is already being uploaded under this folder, please cleanup upload sessions.", "40055": "File metadata mismatch.", + "40056": "Unsupported compressed file type.", + "40057": "Available storage policy has changed, please refresh the file list and add this task again.", "50001": "Database operation failed. ({{message}})", "50002": "Failed to sign the URL or request. ({{message}})", "50004": "I/O operation failed. ({{message}})", diff --git a/public/locales/zh-CN/common.json b/public/locales/zh-CN/common.json index 041bacc..dc6a048 100644 --- a/public/locales/zh-CN/common.json +++ b/public/locales/zh-CN/common.json @@ -16,12 +16,17 @@ "artPlayerLocaleCode": "zh-cn", "errors": { "404": "资源不存在", + "409": "发生冲突 ({{message}})", "40001": "输入参数有误 ({{message}})", "40002": "上传失败", "40003": "目录创建失败", "40004": "同名对象已存在", "40006": "不支持的存储策略类型", "40007": "当前用户组无法进行此操作", + "40011": "上传会话不存在或已过期", + "40012": "分片序号无效 ({{message}})", + "40013": "正文长度无效 ({{message}})", + "40014": "超出批量获取外链限制", "40015": "超出最大离线下载任务数量限制", "40016": "路径不存在", "40017": "该账号已被封禁", @@ -54,6 +59,8 @@ "40053": "不支持对根目录执行此操作", "40054": "话当前目录下已经有同名文件正在上传中,请尝试清空上传会话", "40055": "文件信息不一致", + "40056": "不支持该格式的压缩文件", + "40057": "可用存储策略发生变化,请刷新文件列表并重新添加此任务", "50001": "数据库操作失败 ({{message}})", "50002": "URL 或请求签名失败 ({{message}})", "50004": "I/O 操作失败 ({{message}})", diff --git a/src/component/Uploader/core/errors/index.ts b/src/component/Uploader/core/errors/index.ts index 0988d32..4af87db 100644 --- a/src/component/Uploader/core/errors/index.ts +++ b/src/component/Uploader/core/errors/index.ts @@ -7,6 +7,7 @@ import { } from "../types"; import { sizeToString } from "../utils"; import i18next from "../../../../i18n"; +import { AppError } from "../../../../middleware/Api"; export enum UploaderErrorName { InvalidFile = "InvalidFile", @@ -107,21 +108,18 @@ export class UnknownPolicyError extends UploaderError { // 后端 API 出错 export class APIError extends UploaderError { + private appError: AppError; constructor( name: UploaderErrorName, message: string, protected response: Response ) { super(name, message); + this.appError = new AppError(response.msg, response.code, response.msg); } public Message(): string { - let msg = `${this.message}: ${this.response.msg}`; - if (this.response.error) { - msg += ` (${this.response.error})`; - } - - return msg; + return `${this.message}: ${this.appError.message}`; } public Retryable(): boolean {