1
1
mirror of https://github.com/ZeroCatDev/ClassworksKV.git synced 2025-12-07 13:03:09 +00:00

Fix: 允许保存空数组,修复无法删除最后一条通知的Bug

This commit is contained in:
tempChanghong 2025-12-01 15:06:52 +08:00
parent e73ff53f58
commit d52ed81a29
5 changed files with 39 additions and 2 deletions

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

12
.idea/FixClassworksKV.iml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/FixClassworksKV.iml" filepath="$PROJECT_DIR$/.idea/FixClassworksKV.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -356,7 +356,10 @@ router.post(
const {key} = req.params; const {key} = req.params;
const value = req.body; const value = req.body;
if (!value || Object.keys(value).length === 0) { // 【修改点】允许空数组通过校验,但继续拦截真正的空对象 {}
// 如果 value 是空数组 []Object.keys 为 0但 !Array.isArray 为 false条件为 false -> 通过
// 如果 value 是空对象 {}Object.keys 为 0且 !Array.isArray 为 true条件为 true -> 拦截
if (!value || (Object.keys(value).length === 0 && !Array.isArray(value))) {
return next(errors.createError(400, "请提供有效的JSON值")); return next(errors.createError(400, "请提供有效的JSON值"));
} }
@ -429,4 +432,4 @@ router.delete(
}) })
); );
export default router; export default router;v