|
@@ -10,6 +10,7 @@ import { ObjsContainer } from "../../controllers/SelectCtrl/ObjsContainer";
|
|
|
import { getKeyThenIncreaseKey } from "ant-design-vue/lib/message";
|
|
|
import { Matrix } from "../../controllers/SelectCtrl/matrix";
|
|
|
import { nanoid } from "nanoid";
|
|
|
+import { createObj, history } from "../../objects/DesignTemp/factory";
|
|
|
|
|
|
const ctrlState = {
|
|
|
selected: [] as string[],
|
|
@@ -22,31 +23,26 @@ const ctrlState = {
|
|
|
};
|
|
|
|
|
|
export const editActions = EditorModule.action({
|
|
|
- pickComp(compId: string, selected = true) {
|
|
|
- if (compId == "") {
|
|
|
- //空的时候,就选择根页面
|
|
|
- compId = "root";
|
|
|
- }
|
|
|
- const selectCardChild = (id: string) => {
|
|
|
- const paths = this.helper.getCompTrees(id);
|
|
|
- const cardChilds = paths[2];
|
|
|
- if (cardChilds) {
|
|
|
- this.actions.selectObjs([cardChilds.id]);
|
|
|
- } else {
|
|
|
- this.actions.selectObjs([]);
|
|
|
- if (id != "root") {
|
|
|
- this.store.setCurrComp(this.store.currStreamCardId);
|
|
|
- }
|
|
|
+
|
|
|
+ async addImageToDesign(url) {
|
|
|
+ queenApi.showLoading("图片加载中")
|
|
|
+ const maxW = this.controls.screenCtrl.getCurrScreenWidth();
|
|
|
+ try {
|
|
|
+ const temImg :any = await this.helper.loadImage(url);
|
|
|
+ const ratio = temImg.width / temImg.height;
|
|
|
+ const W = temImg.width > maxW ? maxW : temImg.width;
|
|
|
+ const H = W / ratio;
|
|
|
+ await this.actions.clickCompToDesign("Image", (comp)=>{
|
|
|
+
|
|
|
+ comp.setSize(W, H );
|
|
|
+ comp.value.url = url;
|
|
|
+ })
|
|
|
+ } catch(e) {
|
|
|
+ queenApi.hideLoading();
|
|
|
+ queenApi.messageError("图片加载失败");
|
|
|
+ return
|
|
|
}
|
|
|
- };
|
|
|
-
|
|
|
- if (this.store.currCompId == compId) {
|
|
|
- return;
|
|
|
- }
|
|
|
- this.store.setCurrComp(compId);
|
|
|
- if (selected) {
|
|
|
- selectCardChild(compId);
|
|
|
- }
|
|
|
+ queenApi.hideLoading();
|
|
|
},
|
|
|
|
|
|
// 通过点击添加组件到画布
|
|
@@ -55,54 +51,30 @@ export const editActions = EditorModule.action({
|
|
|
queenApi.messageError("请先选中一个卡片");
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- //点击默认都创建一个容器
|
|
|
- //创建容器
|
|
|
- const isCreatCard =
|
|
|
- compKey != "Text" &&
|
|
|
- compKey != "Image" &&
|
|
|
- compKey != "Rectage" &&
|
|
|
- compKey != "Line" &&
|
|
|
- compKey != "Arc" &&
|
|
|
- compKey != "Triangle" &&
|
|
|
- compKey != "Ellipse" &&
|
|
|
- compKey != "Polygon" &&
|
|
|
- compKey != "PolygonNormal" &&
|
|
|
- compKey != "Curve";
|
|
|
+
|
|
|
+ const page = this.controls.pageCtrl;
|
|
|
|
|
|
let yOffset = 0;
|
|
|
if (
|
|
|
- this.store.currCompId != this.store.currStreamCardId &&
|
|
|
- !isCreatCard &&
|
|
|
- this.store.currCompId != "root"
|
|
|
+ page.state.currCompId != page.state.currStreamCardId &&
|
|
|
+ page.state.currCompId != "root"
|
|
|
) {
|
|
|
- const bound = this.helper.getCardCompBound(this.store.currCompId);
|
|
|
+ const bound = this.helper.getCardCompBound(page.state.currCompId);
|
|
|
yOffset = bound.y + bound.h;
|
|
|
}
|
|
|
+ let currCard = page.currStreamCard;
|
|
|
|
|
|
- let currCard = this.store.currStreamCard;
|
|
|
+ const currComp = createObj({compKey}, false);
|
|
|
|
|
|
- if (isCreatCard) {
|
|
|
- //先创建卡片
|
|
|
- const currCardIndex =
|
|
|
- this.store.streamCardIds.indexOf(this.store.currStreamCardId) + 1;
|
|
|
- const compId = await this.store.insertDesignContent(
|
|
|
- "Container",
|
|
|
- currCardIndex
|
|
|
- );
|
|
|
- currCard = this.helper.findComp(compId) as DesignComp;
|
|
|
- currCard.layout.size[0] = this.controls.screenCtrl.getCurrScreenWidth();
|
|
|
- }
|
|
|
-
|
|
|
- const compId = await this.store.insertCompContainer(compKey, currCard);
|
|
|
- const addedComp = this.store.compMap[compId];
|
|
|
- addedComp.layout.position = "absolute";
|
|
|
-
|
|
|
- const currComp = this.helper.findComp(compId) as DesignComp;
|
|
|
+ page.designData.compMap[currComp.id] = currComp;
|
|
|
+ page.setCompPid(currComp.id, currCard.id);
|
|
|
+ const childIds = [...currCard.children.default];
|
|
|
+ childIds.push(currComp.id);
|
|
|
+ currCard.children.setDefault(childIds);
|
|
|
+ const compId = currComp.id;
|
|
|
cb?.(currComp);
|
|
|
|
|
|
const w = this.controls.screenCtrl.getCurrScreenWidth();
|
|
|
-
|
|
|
//添加组件到当前选中的组件下面
|
|
|
let xOffset = this.helper.designSizeToPx(
|
|
|
w / 2.0 - (currComp.layout.size?.[0] || w) / 2
|
|
@@ -118,46 +90,44 @@ export const editActions = EditorModule.action({
|
|
|
obj.worldTransform.translate(xOffset, yOffset);
|
|
|
currComp.layout.transformMatrix = obj.worldTransform.getMatrixStr();
|
|
|
|
|
|
- this.actions.pickComp(compId);
|
|
|
+ this.controls.editorCtrl.clickPickComp(compId);
|
|
|
this.helper.extendStreamCard(currCard.id);
|
|
|
|
|
|
if (compKey == "Text") {
|
|
|
this.actions.textFocus(compId, true);
|
|
|
}
|
|
|
this.controls.cropCtrl.close();
|
|
|
+
|
|
|
+ this.history.submit();
|
|
|
},
|
|
|
|
|
|
// 通过点击添加组件到画布
|
|
|
async clickCompUserToDesign(id: string, isSys) {
|
|
|
+
|
|
|
+ const page = this.controls.pageCtrl;
|
|
|
+
|
|
|
if (!this.store.currStreamCardId) {
|
|
|
queenApi.messageError("请先选中一个卡片");
|
|
|
return;
|
|
|
}
|
|
|
const { result } = await this.https.getCompDetail(id, isSys);
|
|
|
|
|
|
- //先创建卡片
|
|
|
- // const currCardIndex = this.store.streamCardIds.indexOf(this.store.currStreamCardId) + 1;
|
|
|
- // const cardId = await this.store.insertDesignContent(
|
|
|
- // "Container",
|
|
|
- // currCardIndex
|
|
|
- // );
|
|
|
- // const currCard = this.helper.findComp(cardId) as DesignComp;
|
|
|
- const currCard = this.store.currStreamCard;
|
|
|
- const comp = this.store.addUserCard(result);
|
|
|
+ const currCard = page.currStreamCard;
|
|
|
+ const comp = page.addUserCard(result);
|
|
|
|
|
|
const compId = comp.id;
|
|
|
const childIds = [...(currCard.children.default || [])];
|
|
|
childIds.push(compId);
|
|
|
- currCard.children.default = childIds;
|
|
|
+ currCard.children.setDefault(childIds);
|
|
|
|
|
|
- this.store.setCompPid(compId, currCard.id);
|
|
|
+ page.setCompPid(compId, currCard.id);
|
|
|
|
|
|
- const addedComp = this.store.compMap[compId];
|
|
|
- addedComp.layout.position = "absolute";
|
|
|
|
|
|
this.actions.initAddedCompPos(this.store.currCompId, compId, currCard.id);
|
|
|
|
|
|
- this.actions.pickComp(compId);
|
|
|
+ this.controls.editorCtrl.clickPickComp(compId);
|
|
|
+
|
|
|
+ history.submit();
|
|
|
},
|
|
|
|
|
|
initAddedCompPos(currId: string, addedId: string, cardId: string) {
|
|
@@ -195,22 +165,22 @@ export const editActions = EditorModule.action({
|
|
|
// 通过拖拽添加组件到画布
|
|
|
async dragCompToDesign(event: MouseEvent, compKey: string, data: any) {
|
|
|
const currCardDom = this.store.currStreamCard.$el;
|
|
|
+ const page = this.controls.pageCtrl;
|
|
|
|
|
|
if (compKey == "CompCard") {
|
|
|
const { result } = await this.https.getCompDetail(data.id, data.isSys);
|
|
|
- const comp = this.store.addUserCard(result);
|
|
|
+ const comp = page.addUserCard(result);
|
|
|
|
|
|
- const currCard = this.store.currStreamCard;
|
|
|
+ const currCard = page.currStreamCard;
|
|
|
const compId = comp.id;
|
|
|
const childIds = [...(currCard.children.default || [])];
|
|
|
childIds.push(compId);
|
|
|
- currCard.children.default = childIds;
|
|
|
+ currCard.children.setDefault(childIds);
|
|
|
|
|
|
- const addedComp = this.store.compMap[compId];
|
|
|
- addedComp.layout.position = "absolute";
|
|
|
- this.store.setCompPid(compId, currCard.id);
|
|
|
+ page.setCompPid(compId, currCard.id);
|
|
|
|
|
|
- this.actions.pickComp(compId);
|
|
|
+ this.controls.editorCtrl.clickPickComp(compId);
|
|
|
+
|
|
|
} else {
|
|
|
await this.actions.addCompToDesign(compKey as any);
|
|
|
}
|
|
@@ -229,7 +199,7 @@ export const editActions = EditorModule.action({
|
|
|
cardPoints.y
|
|
|
);
|
|
|
|
|
|
- this.helper.extendStreamCard(this.store.currStreamCardId);
|
|
|
+ this.helper.extendStreamCard(page.state.currStreamCardId);
|
|
|
|
|
|
if (compKey == "Text") {
|
|
|
this.actions.selectObjs([]);
|
|
@@ -237,6 +207,8 @@ export const editActions = EditorModule.action({
|
|
|
}
|
|
|
this.controls.cropCtrl.close();
|
|
|
}, 100);
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
|
|
|
async selectObjs(ids: string[], last = "") {
|
|
@@ -251,34 +223,23 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
// 添加组件到画布
|
|
|
async addCompToDesign(compKey: ICompKeys, index?: number) {
|
|
|
- if (!this.store.currStreamCardId) {
|
|
|
+ const page = this.controls.pageCtrl;
|
|
|
+ if (!page.state.currStreamCardId) {
|
|
|
//必须选中一个streamCard
|
|
|
return;
|
|
|
}
|
|
|
if (compKey == "Container") {
|
|
|
- // index = this.store.streamCardIds.indexOf(this.store.currStreamCardId) + 1;
|
|
|
- const compId = await this.store.insertDesignContent(compKey, index);
|
|
|
- this.actions.pickComp(compId);
|
|
|
-
|
|
|
- const c = this.helper.findComp(compId) as DesignComp;
|
|
|
- c.layout.size[0] = this.controls.screenCtrl.getCurrScreenWidth();
|
|
|
- c.layout.size[1] = this.controls.screenCtrl.getCurrScreenHeight();
|
|
|
-
|
|
|
- this.helper.extendStreamCard(compId);
|
|
|
-
|
|
|
- this.actions.selectObjs([]);
|
|
|
-
|
|
|
+ const compId = page.insertDesignCard(index);
|
|
|
+ this.controls.editorCtrl.clickPickComp(compId);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const compId = await this.store.insertCompContainer(
|
|
|
+ const compId = page.insertCompContainer(
|
|
|
compKey,
|
|
|
this.store.currStreamCard
|
|
|
);
|
|
|
- const addedComp = this.store.compMap[compId];
|
|
|
- this.actions.setCompPositionFloat(addedComp);
|
|
|
|
|
|
- this.actions.pickComp(compId);
|
|
|
+ this.controls.editorCtrl.clickPickComp(compId);
|
|
|
},
|
|
|
|
|
|
// 切换当前组件
|
|
@@ -322,8 +283,9 @@ export const editActions = EditorModule.action({
|
|
|
// },
|
|
|
// 切换到父组件
|
|
|
pickParentComp(compId: string) {
|
|
|
+ const page = this.controls.pageCtrl;
|
|
|
const parentComp = this.helper.findParentComp(compId);
|
|
|
- parentComp && this.store.setCurrComp(parentComp.id);
|
|
|
+ parentComp && page.setCurrComp(parentComp.id);
|
|
|
},
|
|
|
|
|
|
ctrlc() {
|
|
@@ -337,7 +299,7 @@ export const editActions = EditorModule.action({
|
|
|
ctrlState.screenId = this.controls.screenCtrl.currScreenId;
|
|
|
ctrlState.cardId = this.store.currStreamCardId;
|
|
|
ctrlState.type = 1;
|
|
|
- const objc = this.controls.selectCtrl.objContainer as ObjsContainer;
|
|
|
+ const objc = this.controls.selectCtrl.objContainer;
|
|
|
ctrlState.selWidth = this.helper.pxToDesignSize(objc.width);
|
|
|
objc.setPivot(0);
|
|
|
const currX = objc.parent.x,
|
|
@@ -357,16 +319,25 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
setSameSize(isWidth: boolean) {
|
|
|
const selectCtrl = this.controls.selectCtrl;
|
|
|
- const objc = selectCtrl.objContainer as ObjsContainer;
|
|
|
- const w = this.controls.screenCtrl.getCurrScreenWidth();
|
|
|
- if (this.store.selected.length == 1) {
|
|
|
- if (isWidth) this.store.currComp.layout.size[0] = w;
|
|
|
- else
|
|
|
- this.store.currComp.layout.size[1] =
|
|
|
- this.store.currStreamCard.layout.size[1];
|
|
|
+ const objc = selectCtrl.objContainer;
|
|
|
+ const layout = this.store.currComp.layout;
|
|
|
|
|
|
- objc.updateSize();
|
|
|
- selectCtrl.upgateGizmoStyle();
|
|
|
+ const w = this.controls.screenCtrl.getCurrScreenWidth();
|
|
|
+ if (this.selected.length == 1) {
|
|
|
+ const size :any = layout.size.slice(0);
|
|
|
+ let isSame = false;
|
|
|
+ if (isWidth) {
|
|
|
+ isSame = w == size[0]
|
|
|
+ size[0] = w;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ isSame = size[1] == this.store.currStreamCard.layout.size[1]
|
|
|
+ size[1] = this.store.currStreamCard.layout.size[1];
|
|
|
+ }
|
|
|
+ if (!isSame) {
|
|
|
+ layout.setSize(size);
|
|
|
+ this.history.submit();
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -413,7 +384,7 @@ export const editActions = EditorModule.action({
|
|
|
ctrlState.cardId = this.store.currStreamCardId;
|
|
|
ctrlState.type = 2;
|
|
|
ctrlState.screenId = this.controls.screenCtrl.currScreenId;
|
|
|
- const objc = this.controls.selectCtrl.objContainer as ObjsContainer;
|
|
|
+ const objc = this.controls.selectCtrl.objContainer;
|
|
|
ctrlState.selWidth = this.helper.pxToDesignSize(objc.width);
|
|
|
objc.setPivot(0);
|
|
|
const currX = objc.parent.x,
|
|
@@ -425,6 +396,7 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
ctrlv() {
|
|
|
if (ctrlState.selected.length < 1) return;
|
|
|
+ const ctrl = this.controls.pageCtrl;
|
|
|
|
|
|
const news: string[] = [];
|
|
|
|
|
@@ -435,8 +407,8 @@ export const editActions = EditorModule.action({
|
|
|
const cp = this.helper.findComp(id) as DesignComp;
|
|
|
const cp1 = cloneDeep(cp);
|
|
|
cp1.id = nanoid();
|
|
|
- this.store.compMap[cp1.id] = cp1;
|
|
|
- this.store.setCompPid(cp1.id, c.id);
|
|
|
+ ctrl.compMap[cp1.id] = cp1;
|
|
|
+ ctrl.setCompPid(cp1.id, c.id);
|
|
|
childs[index] = cp1.id;
|
|
|
|
|
|
deepCopy(cp);
|
|
@@ -449,8 +421,8 @@ export const editActions = EditorModule.action({
|
|
|
const cp1 = cloneDeep(cp);
|
|
|
cp1.id = nanoid();
|
|
|
news.push(cp1.id);
|
|
|
- this.store.compMap[cp1.id] = cp1;
|
|
|
- this.store.setCompPid(cp1.id, this.store.currStreamCardId);
|
|
|
+ ctrl.compMap[cp1.id] = cp1;
|
|
|
+ ctrl.setCompPid(cp1.id, this.store.currStreamCardId);
|
|
|
|
|
|
deepCopy(cp);
|
|
|
});
|
|
@@ -517,6 +489,8 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
// 删除组件
|
|
|
removeComp(compId: string) {
|
|
|
+ const ctrl = this.controls.pageCtrl;
|
|
|
+
|
|
|
const paths = this.helper.getCompTrees(compId);
|
|
|
if (!paths[2]) {
|
|
|
if (this.helper.isStreamCard(compId)) {
|
|
@@ -534,9 +508,9 @@ export const editActions = EditorModule.action({
|
|
|
}
|
|
|
const cardid = this.store.currStreamCardId;
|
|
|
if (compId === this.store.currCompId) {
|
|
|
- this.store.setCurrComp(this.store.currStreamCardId);
|
|
|
+ ctrl.setCurrComp(this.store.currStreamCardId);
|
|
|
}
|
|
|
- this.store.deleteComp(compId);
|
|
|
+ ctrl.deleteComp(compId);
|
|
|
|
|
|
this.helper.extendStreamCard(cardid);
|
|
|
|
|
@@ -545,35 +519,36 @@ export const editActions = EditorModule.action({
|
|
|
},
|
|
|
|
|
|
async removeStreamCard(compId: string) {
|
|
|
+ const ctrl = this.controls.pageCtrl;
|
|
|
+
|
|
|
await queenApi.showConfirm({ title: "删除", content: "确认删除当前页面?" });
|
|
|
|
|
|
- // if (this.store.streamCardIds.length < 2) {
|
|
|
- // queenApi.messageError("")
|
|
|
- // return;
|
|
|
- // }
|
|
|
- let nextCard = this.store.currStreamCardId;
|
|
|
- if (compId == this.store.currStreamCardId) {
|
|
|
- const i = this.store.streamCardIds.indexOf(compId);
|
|
|
- nextCard = this.store.streamCardIds[i + 1];
|
|
|
+ let nextCard = ctrl.state.currStreamCardId;
|
|
|
+ if (compId == ctrl.state.currStreamCardId) {
|
|
|
+ const i = ctrl.streamCardIds.indexOf(compId);
|
|
|
+ nextCard =ctrl.streamCardIds[i + 1];
|
|
|
if (!nextCard) {
|
|
|
- nextCard = this.store.streamCardIds[i - 1];
|
|
|
+ nextCard = ctrl.streamCardIds[i - 1];
|
|
|
}
|
|
|
}
|
|
|
- this.controls.selectCtrl.selecteObjs([]);
|
|
|
+ this.controls.selectCtrl.gizmo.selectObjs([]);
|
|
|
+ this.controls.propsCtrl.showProp("root");
|
|
|
|
|
|
- this.store.setCurrComp(nextCard);
|
|
|
-
|
|
|
- this.store.deleteComp(compId);
|
|
|
+ ctrl.setCurrComp(nextCard);
|
|
|
+ ctrl.deleteComp(compId);
|
|
|
},
|
|
|
// 移动组件顺序
|
|
|
moveComp(selIndex: number, targetIndex: number) {
|
|
|
this.actions.selectObjs([]);
|
|
|
if (selIndex === targetIndex) return;
|
|
|
- this.store.moveComp(selIndex, targetIndex);
|
|
|
+
|
|
|
+ this.controls.pageCtrl.moveComp(selIndex, targetIndex);
|
|
|
},
|
|
|
|
|
|
// 保存容器为组件
|
|
|
async saveAsComp(comp: DesignComp) {
|
|
|
+ const ctrl = this.controls.pageCtrl;
|
|
|
+
|
|
|
try {
|
|
|
const CompSave = this.components.CompSave as any;
|
|
|
let title = "";
|
|
@@ -611,7 +586,7 @@ export const editActions = EditorModule.action({
|
|
|
title,
|
|
|
type,
|
|
|
thumbnail,
|
|
|
- compMap: cloneDeep(this.store.designData.compMap),
|
|
|
+ compMap: cloneDeep(ctrl.designData.compMap),
|
|
|
};
|
|
|
this.helper.clearUnusedComps(data.compMap, comp.id);
|
|
|
data.compMap.root = data.compMap[comp.id];
|
|
@@ -640,9 +615,11 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
// 保存项目
|
|
|
async saveDesign() {
|
|
|
+ const ctrl = this.controls.pageCtrl;
|
|
|
+
|
|
|
try {
|
|
|
// 清除无用组件
|
|
|
- this.helper.clearProjectUnusedComps(this.store.designData.compMap);
|
|
|
+ this.helper.clearProjectUnusedComps(ctrl.designData.compMap);
|
|
|
const c = this.controls.screenCtrl;
|
|
|
c.saveScreenPage();
|
|
|
const root = this.helper.findRootComp() as DesignComp;
|
|
@@ -651,21 +628,20 @@ export const editActions = EditorModule.action({
|
|
|
root.value.pageSizeType = c.state.screen.pageSizeType;
|
|
|
|
|
|
// 封面截屏
|
|
|
- if (!this.store.designData.thumbnail) {
|
|
|
+ if (!ctrl.designData.thumbnail) {
|
|
|
await this.actions.updateThumbnailByScreenshot();
|
|
|
}
|
|
|
queenApi.showLoading("保存中");
|
|
|
- await this.controls.uploader.uploadBlobs(this.store.designData);
|
|
|
+ await this.controls.uploader.uploadBlobs(ctrl.designData);
|
|
|
if (this.store.isWk) {
|
|
|
await this.https[this.store.isEditPage ? "saveWkDesign" : "saveComp"](
|
|
|
- this.store.designData
|
|
|
+ ctrl.designData
|
|
|
);
|
|
|
} else {
|
|
|
await this.https[this.store.isEditPage ? "saveDesign" : "saveComp"](
|
|
|
- this.store.designData
|
|
|
+ ctrl.designData
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
queenApi.messageSuccess("保存成功");
|
|
|
} catch (error: any) {
|
|
|
throw Exception.error(error.toString());
|
|
@@ -676,6 +652,8 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
// 截屏保存封面
|
|
|
async updateThumbnailByScreenshot(autoSave?: boolean) {
|
|
|
+ const ctrl = this.controls.pageCtrl;
|
|
|
+
|
|
|
try {
|
|
|
const rootComp = this.helper.findRootComp();
|
|
|
if (!rootComp) return;
|
|
@@ -688,9 +666,9 @@ export const editActions = EditorModule.action({
|
|
|
this.store.setDesignThumbnail(thumbnail);
|
|
|
|
|
|
if (autoSave) {
|
|
|
- await this.controls.uploader.uploadBlobs(this.store.designData);
|
|
|
+ await this.controls.uploader.uploadBlobs(ctrl.designData);
|
|
|
await this.https[this.store.isEditPage ? "saveDesign" : "saveComp"](
|
|
|
- pick(this.store.designData, ["_id", "thumbnail"])
|
|
|
+ pick(ctrl.designData, ["_id", "thumbnail"])
|
|
|
);
|
|
|
queenApi.messageSuccess("保存成功");
|
|
|
}
|
|
@@ -701,14 +679,6 @@ export const editActions = EditorModule.action({
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- // 设置组件变换
|
|
|
- setCompTransform(comp: DesignComp, transform: Layout["transform"]) {
|
|
|
- if (!comp) return;
|
|
|
-
|
|
|
- comp.layout.transform = transform;
|
|
|
- console.log(comp);
|
|
|
- },
|
|
|
-
|
|
|
// 设置组件变换
|
|
|
setCompTransformMatrix(comp: DesignComp, transformMatrix: string) {
|
|
|
if (!comp) return;
|
|
@@ -716,16 +686,7 @@ export const editActions = EditorModule.action({
|
|
|
comp.layout.transformMatrix = transformMatrix;
|
|
|
},
|
|
|
|
|
|
- // 设置组件浮动
|
|
|
- setCompPositionFloat(comp: DesignComp) {
|
|
|
- comp.layout.position = "absolute";
|
|
|
- },
|
|
|
|
|
|
- // 设置组件浮动
|
|
|
- setCompPosition(comp: DesignComp) {
|
|
|
- comp.layout.position =
|
|
|
- comp.layout.position === "absolute" ? undefined : "absolute";
|
|
|
- },
|
|
|
// 设置组件显示隐藏
|
|
|
setCompVisible(comp: DesignComp) {
|
|
|
comp.layout.visible = comp.layout.visible === false ? true : false;
|
|
@@ -740,13 +701,13 @@ export const editActions = EditorModule.action({
|
|
|
comp.title = res;
|
|
|
},
|
|
|
// 清除组件变换
|
|
|
- clearCompTransform(comp: DesignComp) {
|
|
|
- comp.layout.margin = "";
|
|
|
- comp.layout.transform = undefined;
|
|
|
- },
|
|
|
+ // clearCompTransform(comp: DesignComp) {
|
|
|
+ // comp.layout.margin = "";
|
|
|
+ // comp.layout.transform = undefined;
|
|
|
+ // },
|
|
|
// 设置组件锁定状态
|
|
|
setCompLock(comp: DesignComp) {
|
|
|
- comp.layout.locked = !comp.layout.locked;
|
|
|
+ comp.layout.setLocked(!comp.layout.locked);
|
|
|
},
|
|
|
// 设置组件层级
|
|
|
setCompLayer(comp: DesignComp, offset: number) {
|
|
@@ -780,9 +741,10 @@ export const editActions = EditorModule.action({
|
|
|
const w = this.helper.designSizeToPx(
|
|
|
this.controls.screenCtrl.getCurrScreenWidth()
|
|
|
);
|
|
|
+ const gizmo = selectCtrl.gizmo;
|
|
|
|
|
|
- if (this.store.selected.length == 1 || isGroup) {
|
|
|
- const objc = selectCtrl.objContainer as ObjsContainer;
|
|
|
+ if (gizmo.selected.length == 1 || isGroup) {
|
|
|
+ const objc = selectCtrl.objContainer;
|
|
|
const box = objc.getBound();
|
|
|
|
|
|
switch (flag) {
|
|
@@ -796,6 +758,7 @@ export const editActions = EditorModule.action({
|
|
|
selectCtrl.translate(w - box.right, 0);
|
|
|
break;
|
|
|
}
|
|
|
+ history.submit();
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -806,7 +769,7 @@ export const editActions = EditorModule.action({
|
|
|
const anchor = new CompObject(anchorBox);
|
|
|
const anchorRect = anchor.getBox();
|
|
|
|
|
|
- const objc = selectCtrl.objContainer as ObjsContainer;
|
|
|
+ const objc = selectCtrl.objContainer;
|
|
|
let min = 10000,
|
|
|
max = -10000;
|
|
|
let step = 0;
|
|
@@ -844,6 +807,7 @@ export const editActions = EditorModule.action({
|
|
|
});
|
|
|
objc.updateSize();
|
|
|
selectCtrl.upgateGizmoStyle();
|
|
|
+ history.submit();
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -868,12 +832,14 @@ export const editActions = EditorModule.action({
|
|
|
});
|
|
|
objc.updateSize();
|
|
|
selectCtrl.upgateGizmoStyle();
|
|
|
+ history.submit();
|
|
|
},
|
|
|
|
|
|
setAlignY(flag: 0 | 1 | 2 | 3, isGroup = false) {
|
|
|
const selectCtrl = this.controls.selectCtrl;
|
|
|
- if (this.store.selected.length == 1 || isGroup) {
|
|
|
- const objc = selectCtrl.objContainer as ObjsContainer;
|
|
|
+ const gizmo = selectCtrl.gizmo;
|
|
|
+ if (gizmo.selected.length == 1 || isGroup) {
|
|
|
+ const objc = selectCtrl.objContainer;
|
|
|
const box = objc.getBound();
|
|
|
|
|
|
const card = new CompObject(this.store.currStreamCard);
|
|
@@ -890,6 +856,7 @@ export const editActions = EditorModule.action({
|
|
|
selectCtrl.translate(0, cardBox.h - box.bottom);
|
|
|
break;
|
|
|
}
|
|
|
+ history.submit();
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -899,7 +866,7 @@ export const editActions = EditorModule.action({
|
|
|
const anchor = new CompObject(anchorBox);
|
|
|
const anchorRect = anchor.getBox();
|
|
|
|
|
|
- const objc = selectCtrl.objContainer as ObjsContainer;
|
|
|
+ const objc = selectCtrl.objContainer;
|
|
|
|
|
|
let min = 10000;
|
|
|
let max = -10000;
|
|
@@ -939,6 +906,7 @@ export const editActions = EditorModule.action({
|
|
|
});
|
|
|
objc.updateSize();
|
|
|
selectCtrl.upgateGizmoStyle();
|
|
|
+ history.submit();
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -963,40 +931,19 @@ export const editActions = EditorModule.action({
|
|
|
});
|
|
|
objc.updateSize();
|
|
|
selectCtrl.upgateGizmoStyle();
|
|
|
+ history.submit();
|
|
|
},
|
|
|
|
|
|
// 宽度铺满
|
|
|
fullCompWidth(comp: DesignComp) {
|
|
|
comp.layout.size[0] = this.controls.screenCtrl.getCurrScreenWidth();
|
|
|
},
|
|
|
- //
|
|
|
- setCompAlign(comp: DesignComp, align: string) {
|
|
|
- comp.layout.alignSelf = align;
|
|
|
- if (comp.layout.transform?.x) {
|
|
|
- comp.layout.transform.x = 0;
|
|
|
- }
|
|
|
- },
|
|
|
+
|
|
|
|
|
|
- // 开启组合模式
|
|
|
- enableGroupMode() {
|
|
|
- this.store.setGroupIds(
|
|
|
- this.store.currCompId ? [this.store.currCompId] : []
|
|
|
- );
|
|
|
- this.store.setGroupMode(true);
|
|
|
- },
|
|
|
- // 关闭组合模式
|
|
|
- async disableGroupMode() {
|
|
|
- const groupId = await this.controls.transferCtrl.groupCtrl.combineGroup();
|
|
|
- if (groupId) {
|
|
|
- this.store.setCurrComp(groupId);
|
|
|
- }
|
|
|
- this.store.setGroupIds([]);
|
|
|
- this.store.setGroupMode(false);
|
|
|
- },
|
|
|
// 取消打组
|
|
|
cancelGroupComps(groupComp: DesignComp) {
|
|
|
const childs = groupComp.children.default || [];
|
|
|
- const objC = this.controls.selectCtrl.objContainer as ObjsContainer;
|
|
|
+ const objC = this.controls.selectCtrl.objContainer;
|
|
|
const parentMtrx = objC.parent.worldTransform.clone();
|
|
|
childs.forEach((o) => {
|
|
|
const obj = this.helper.findComp(o) as DesignComp;
|
|
@@ -1018,15 +965,15 @@ export const editActions = EditorModule.action({
|
|
|
},
|
|
|
|
|
|
createGroupComps() {
|
|
|
- const selectCtrl = this.controls.selectCtrl;
|
|
|
- const Objc = this.controls.selectCtrl.objContainer as ObjsContainer;
|
|
|
+
|
|
|
+ const gizmo = this.controls.selectCtrl.gizmo;
|
|
|
+ const page = this.controls.pageCtrl;
|
|
|
+
|
|
|
+ const sels = gizmo.selected.map(item=>item.comp.id);
|
|
|
const id = this.controls.compUICtrl.createCompId("Group");
|
|
|
+
|
|
|
const comp = this.helper.findComp(id) as DesignComp;
|
|
|
- comp.layout.position = "absolute";
|
|
|
-
|
|
|
- //先删除现有的节点
|
|
|
- const sels = this.store.selected.slice(0);
|
|
|
- const chils = this.store.currStreamCard.children.default || [];
|
|
|
+ const chils = this.controls.pageCtrl.currStreamCard.children.default || [];
|
|
|
const newChilds: any = [];
|
|
|
const groupChilds: any = [];
|
|
|
chils.forEach((c) => {
|
|
@@ -1037,10 +984,11 @@ export const editActions = EditorModule.action({
|
|
|
});
|
|
|
|
|
|
newChilds.push(id);
|
|
|
- this.store.currStreamCard.children.default = newChilds;
|
|
|
+ page.currStreamCard.children.setDefault(newChilds);
|
|
|
+ page.setCompPid(id, page.currStreamCard.id);
|
|
|
|
|
|
//更新节点的新位置
|
|
|
- Objc.parent.children.forEach((obj) => {
|
|
|
+ gizmo.parent.children.forEach((obj) => {
|
|
|
const cobj = obj as CompObject;
|
|
|
const comp = cobj.comp;
|
|
|
comp.layout.transformMatrix = cobj.localTransform.getMatrixStr();
|
|
@@ -1048,17 +996,19 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
//再添加新的节点
|
|
|
comp.layout.size = [
|
|
|
- this.helper.pxToDesignSize(Objc.width),
|
|
|
- this.helper.pxToDesignSize(Objc.height),
|
|
|
+ this.helper.pxToDesignSize(gizmo.width),
|
|
|
+ this.helper.pxToDesignSize(gizmo.height),
|
|
|
];
|
|
|
- comp.layout.transformMatrix = selectCtrl.transferStyle.matrix;
|
|
|
+
|
|
|
+ comp.layout.transformMatrix = gizmo.parent.worldTransform.getMatrixStr();
|
|
|
|
|
|
comp.children.default = groupChilds;
|
|
|
|
|
|
- this.actions.selectObjs([]);
|
|
|
- setTimeout(() => {
|
|
|
- this.actions.pickComp(comp.id);
|
|
|
- }, 0);
|
|
|
+ this.controls.propsCtrl.showProp(comp.id);
|
|
|
+
|
|
|
+ this.controls.selectCtrl.gizmo.selectObjs([comp.id]);
|
|
|
+
|
|
|
+ history.submit();
|
|
|
},
|
|
|
|
|
|
handleSelectMoving(key: string) {
|
|
@@ -1085,6 +1035,8 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
// 点击模板
|
|
|
async clickTplToDesign(record) {
|
|
|
+ const ctrl = this.controls.pageCtrl;
|
|
|
+
|
|
|
const res = await queenApi.showConfirm({
|
|
|
title: "",
|
|
|
content: "要替换正在编辑的内容?",
|
|
@@ -1096,7 +1048,7 @@ export const editActions = EditorModule.action({
|
|
|
const { compMap, content, desc, thumbnail, title } = frameData.result;
|
|
|
|
|
|
const designData = {
|
|
|
- ...this.store.designData,
|
|
|
+ ...ctrl.designData,
|
|
|
compMap,
|
|
|
content,
|
|
|
desc,
|
|
@@ -1105,8 +1057,7 @@ export const editActions = EditorModule.action({
|
|
|
};
|
|
|
|
|
|
this.actions.selectObjs([]);
|
|
|
- this.store.setCurrComp("root");
|
|
|
- this.store.setDesignData(designData);
|
|
|
- this.store.currStreamCardId = this.store.streamCardIds[0];
|
|
|
+ ctrl.setCurrComp("root");
|
|
|
+ ctrl.setDesignData(designData);
|
|
|
},
|
|
|
});
|