Browse Source

feat(live-stream): add deletion restrictions for Live Streams

- Implemented checks to ensure only stopped Live Streams can be deleted.
- Added validation to prevent deletion of Live Streams stopped for less than 24 hours.
- Updated localization files with new messages for deletion restrictions in both English and Chinese.
yb 6 days ago
parent
commit
3d67310ad6
3 changed files with 24 additions and 0 deletions
  1. 2 0
      src/locales/en.json
  2. 2 0
      src/locales/zh-cn.json
  3. 20 0
      src/views/live-stream/index.vue

+ 2 - 0
src/locales/en.json

@@ -74,6 +74,8 @@
   "删除": "Delete",
   "删除失败": "Delete failed",
   "删除成功": "Deleted successfully",
+  "只能删除已停止的 Live Stream": "Can only delete stopped Live Stream",
+  "停止时间未超过24小时,暂时无法删除": "Cannot delete: stopped less than 24 hours ago",
   "刷新数据": "Refresh",
   "协议支持": "Protocol Support",
   "厂商": "Vendor",

+ 2 - 0
src/locales/zh-cn.json

@@ -74,6 +74,8 @@
   "删除": "删除",
   "删除失败": "删除失败",
   "删除成功": "删除成功",
+  "只能删除已停止的 Live Stream": "只能删除已停止的 Live Stream",
+  "停止时间未超过24小时,暂时无法删除": "停止时间未超过24小时,暂时无法删除",
   "刷新数据": "刷新数据",
   "协议支持": "协议支持",
   "厂商": "厂商",

+ 20 - 0
src/views/live-stream/index.vue

@@ -697,6 +697,26 @@ function handleEdit(row: LiveStreamDTO) {
 }
 
 async function handleDelete(row: LiveStreamDTO) {
+  // 检查 status 必须为 0(已停止)
+  if (row.status !== '0') {
+    ElMessage.warning(t('只能删除已停止的 Live Stream'))
+    return
+  }
+
+  // 检查 stoppedAt 必须超过 24 小时
+  if (row.stoppedAt) {
+    const stoppedTime = dayjs(row.stoppedAt)
+    const hoursDiff = dayjs().diff(stoppedTime, 'hour')
+    if (hoursDiff < 24) {
+      ElMessage.warning(t('停止时间未超过24小时,暂时无法删除'))
+      return
+    }
+  } else {
+    // 没有 stoppedAt 时间,不允许删除
+    ElMessage.warning(t('停止时间未超过24小时,暂时无法删除'))
+    return
+  }
+
   try {
     await ElMessageBox.confirm(t('确定要删除该 Live Stream 吗?'), t('提示'), {
       type: 'warning',