소스 검색

添加卡片删除

liwei 1 년 전
부모
커밋
56d44b64b5
2개의 변경된 파일9개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 1
      src/modules/editor/module/actions/edit.tsx
  2. 2 1
      src/modules/editor/module/helpers/index.ts

+ 7 - 1
src/modules/editor/module/actions/edit.tsx

@@ -398,7 +398,13 @@ export const editActions = EditorModule.action({
   removeComp(compId: string) {
 
     const paths = this.helper.getCompTrees(compId);
-    if (!paths[2]) return;
+    if (!paths[2]) {
+      if (this.helper.isStreamCard(compId)) {
+        this.actions.removeStreamCard(compId);
+        return;
+      }
+      return;
+    }
     compId = paths[2].id;
 
     if (this.helper.isCompCanDelete(compId)) {

+ 2 - 1
src/modules/editor/module/helpers/index.ts

@@ -108,8 +108,9 @@ export const helpers = EditorModule.helper({
     return i >= 0;
   },
   isCompCanDelete(compId: string): boolean {
-    return this.helper.isStreamCardChild(compId);
+    return this.helper.isStreamCardChild(compId) || (this.helper.isStreamCard(compId) && this.store.streamCardIds.length > 1);
   },
+
   isShowSaveComp(comp: DesignComp): boolean {
     if ( !this.helper.isStreamCardChild(comp.id) ) return false;
     return true;