|
@@ -7,22 +7,33 @@ import { ICompKeys, Layout } from "../../typings";
|
|
|
export const editActions = EditorModule.action({
|
|
|
// 添加组件到画布
|
|
|
async addCompToDesign(compKey: ICompKeys, index?: number) {
|
|
|
- let compId: string;
|
|
|
- if (
|
|
|
- index === undefined &&
|
|
|
- this.store.currComp?.compKey === "Container"
|
|
|
- // this.store.pageCompIds.includes(this.store.currComp.id)
|
|
|
- ) {
|
|
|
- compId = await this.store.insertCompContainer(
|
|
|
+
|
|
|
+ if (!this.store.currStreamCardId) {//必须选中一个streamCard
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (compKey == "Container") {
|
|
|
+ const compId = await this.store.insertDesignContent(compKey, index);
|
|
|
+ this.actions.pickComp(compId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // if (
|
|
|
+ // index === undefined &&
|
|
|
+ // this.store.currComp?.compKey === "Container"
|
|
|
+ // // this.store.pageCompIds.includes(this.store.currComp.id)
|
|
|
+ // ) {
|
|
|
+
|
|
|
+ const compId = await this.store.insertCompContainer(
|
|
|
compKey,
|
|
|
- this.store.currComp
|
|
|
+ this.store.currStreamCard
|
|
|
);
|
|
|
this.actions.pickComp(compId);
|
|
|
this.actions.setCompPosition(this.store.currComp);
|
|
|
- } else {
|
|
|
- compId = await this.store.insertDesignContent(compKey, index);
|
|
|
- this.actions.pickComp(compId);
|
|
|
- }
|
|
|
+ // } else {
|
|
|
+ // compId = await this.store.insertDesignContent(compKey, index);
|
|
|
+ // this.actions.pickComp(compId);
|
|
|
+ // }
|
|
|
},
|
|
|
// 切换当前组件
|
|
|
pickComp(compId: string) {
|
|
@@ -32,6 +43,7 @@ export const editActions = EditorModule.action({
|
|
|
// nextCompId = comps[1].id;
|
|
|
// }
|
|
|
// if (compId !== this.store.currCompId) {
|
|
|
+
|
|
|
this.store.setCurrComp(compId);
|
|
|
// }
|
|
|
},
|