fix(排期): 发布按钮不再兼任删除,清空排期改为显式操作并加服务端守卫
This commit is contained in:
@@ -48,8 +48,16 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
// 获取所有涉及的歌曲详情(用于通知)
|
||||
const songIds = body.songs.map((s: any) => s.songId)
|
||||
if (songIds.length === 0) {
|
||||
// 如果列表为空,说明是清空排期,直接执行删除逻辑即可
|
||||
/*
|
||||
* ⚠️ 空 songs = 「清空该日期排期」:下面第 3 步会先删光该日期(含草稿)的排期,再插入 0 条。
|
||||
* 这是个**破坏性操作**,绝不能因为前端列表没加载出来(数组恰好是空)就被误触发 ——
|
||||
* 以前点「发布」就能把一整天删掉。所以清空必须由调用方显式带 confirmClear: true。
|
||||
*/
|
||||
if (songIds.length === 0 && body.confirmClear !== true) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: '歌曲列表为空:发布需要至少一首歌;若要清空当天排期,请显式传 confirmClear: true'
|
||||
})
|
||||
}
|
||||
|
||||
const songDetails =
|
||||
|
||||
Reference in New Issue
Block a user