mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-04-03 16:03:18 +08:00
fix: 修复文件和模块命名/重复添加的逻辑
This commit is contained in:
@@ -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} 的模块`
|
||||
: `已存在相同的模块 请勿重复添加`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user