diff --git a/backend/package.json b/backend/package.json index 75802b2..ce9f91e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.55", + "version": "2.14.56", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/file.js b/backend/src/restful/file.js index 64ea95f..80357c9 100644 --- a/backend/src/restful/file.js +++ b/backend/src/restful/file.js @@ -18,14 +18,17 @@ export default function register($app) { // file API function createFile(req, res) { const file = req.body; + file.name = `${file.name ?? Date.now()}`; $.info(`正在创建文件:${file.name}`); const allFiles = $.read(FILES_KEY); if (findByName(allFiles, file.name)) { - failed( + return failed( res, new RequestInvalidError( 'DUPLICATE_KEY', - `File ${file.name} already exists.`, + req.body.name + ? `已存在 name 为 ${file.name} 的文件` + : `无法同时创建相同的文件 可稍后重试`, ), ); } diff --git a/backend/src/restful/module.js b/backend/src/restful/module.js index cd64c25..2df6648 100644 --- a/backend/src/restful/module.js +++ b/backend/src/restful/module.js @@ -22,15 +22,17 @@ export default function register($app) { // module API function createModule(req, res) { const module = req.body; - module.name = module.name ?? hex_md5(JSON.stringify(module)); + module.name = `${module.name ?? hex_md5(JSON.stringify(module))}`; $.info(`正在创建模块:${module.name}`); const allModules = $.read(MODULES_KEY); if (findByName(allModules, module.name)) { - failed( + return failed( res, new RequestInvalidError( 'DUPLICATE_KEY', - `已存在相同的模块 请勿重复添加`, + req.body.name + ? `已存在 name 为 ${module.name} 的模块` + : `已存在相同的模块 请勿重复添加`, ), ); }