|
@@ -23,70 +23,68 @@ const ctrlState = {
|
|
};
|
|
};
|
|
|
|
|
|
export const editActions = EditorModule.action({
|
|
export const editActions = EditorModule.action({
|
|
-
|
|
|
|
async addImageToDesign(url) {
|
|
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
|
|
|
|
- }
|
|
|
|
|
|
+ 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.hideLoading();
|
|
|
|
+ queenApi.messageError("图片加载失败");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ queenApi.hideLoading();
|
|
},
|
|
},
|
|
- async dragAddImageToDesign(e:MouseEvent, url) {
|
|
|
|
- const page = this.controls.pageCtrl;
|
|
|
|
- if (!page.currStreamCardId) {
|
|
|
|
- queenApi.messageError("请先选中一个卡片");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ async dragAddImageToDesign(e: MouseEvent, url) {
|
|
|
|
+ const page = this.controls.pageCtrl;
|
|
|
|
+ if (!page.currStreamCardId) {
|
|
|
|
+ queenApi.messageError("请先选中一个卡片");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- 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;
|
|
|
|
-
|
|
|
|
- const currCard = page.currStreamCard;
|
|
|
|
- const currComp = createObj({compKey:"Image"}, false);
|
|
|
|
- currComp.setSize(W, H );
|
|
|
|
- currComp.value.url = url;
|
|
|
|
- page.designData.compMap[currComp.id] = currComp;
|
|
|
|
- // page.setCompPid(currComp.id, page.currStreamCardId);
|
|
|
|
- const childIds = [...page.currStreamCard.children.default];
|
|
|
|
- childIds.push(currComp.id);
|
|
|
|
- currCard.children.setDefault(childIds);
|
|
|
|
- this.controls.editorCtrl.clickPickComp(currComp.id);
|
|
|
|
- this.actions.centerLastComp(e);
|
|
|
|
- } catch(e) {
|
|
|
|
- queenApi.hideLoading();
|
|
|
|
- queenApi.messageError("图片加载失败");
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ 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;
|
|
|
|
+
|
|
|
|
+ const currCard = page.currStreamCard;
|
|
|
|
+ const currComp = createObj({ compKey: "Image" }, false);
|
|
|
|
+ currComp.setSize(W, H);
|
|
|
|
+ currComp.value.url = url;
|
|
|
|
+ page.designData.compMap[currComp.id] = currComp;
|
|
|
|
+ // page.setCompPid(currComp.id, page.currStreamCardId);
|
|
|
|
+ const childIds = [...page.currStreamCard.children.default];
|
|
|
|
+ childIds.push(currComp.id);
|
|
|
|
+ currCard.children.setDefault(childIds);
|
|
|
|
+ this.controls.editorCtrl.clickPickComp(currComp.id);
|
|
|
|
+ this.actions.centerLastComp(e);
|
|
|
|
+ } catch (e) {
|
|
queenApi.hideLoading();
|
|
queenApi.hideLoading();
|
|
- history.submit();
|
|
|
|
|
|
+ queenApi.messageError("图片加载失败");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ queenApi.hideLoading();
|
|
|
|
+ history.submit();
|
|
},
|
|
},
|
|
|
|
|
|
- async dragAddVideoToDesign(e:MouseEvent, url) {
|
|
|
|
|
|
+ async dragAddVideoToDesign(e: MouseEvent, url) {
|
|
const page = this.controls.pageCtrl;
|
|
const page = this.controls.pageCtrl;
|
|
if (!page.currStreamCardId) {
|
|
if (!page.currStreamCardId) {
|
|
- queenApi.messageError("请先选中一个卡片");
|
|
|
|
- return;
|
|
|
|
|
|
+ queenApi.messageError("请先选中一个卡片");
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
- queenApi.showLoading("视频加载中")
|
|
|
|
|
|
+ queenApi.showLoading("视频加载中");
|
|
// const maxW = this.controls.screenCtrl.getCurrScreenWidth();
|
|
// const maxW = this.controls.screenCtrl.getCurrScreenWidth();
|
|
try {
|
|
try {
|
|
// const temImg :any = await this.helper.loadImage(url);
|
|
// const temImg :any = await this.helper.loadImage(url);
|
|
@@ -95,7 +93,7 @@ export const editActions = EditorModule.action({
|
|
// const H = W / ratio;
|
|
// const H = W / ratio;
|
|
|
|
|
|
const currCard = page.currStreamCard;
|
|
const currCard = page.currStreamCard;
|
|
- const currComp = createObj({compKey:"Video"}, false);
|
|
|
|
|
|
+ const currComp = createObj({ compKey: "Video" }, false);
|
|
// currComp.setSize(W, H );
|
|
// currComp.setSize(W, H );
|
|
currComp.value.url = url;
|
|
currComp.value.url = url;
|
|
page.designData.compMap[currComp.id] = currComp;
|
|
page.designData.compMap[currComp.id] = currComp;
|
|
@@ -105,22 +103,26 @@ export const editActions = EditorModule.action({
|
|
currCard.children.setDefault(childIds);
|
|
currCard.children.setDefault(childIds);
|
|
this.controls.editorCtrl.clickPickComp(currComp.id);
|
|
this.controls.editorCtrl.clickPickComp(currComp.id);
|
|
this.actions.centerLastComp(e);
|
|
this.actions.centerLastComp(e);
|
|
- } catch(e) {
|
|
|
|
|
|
+ } catch (e) {
|
|
queenApi.hideLoading();
|
|
queenApi.hideLoading();
|
|
queenApi.messageError("图片加载失败");
|
|
queenApi.messageError("图片加载失败");
|
|
- return
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
queenApi.hideLoading();
|
|
queenApi.hideLoading();
|
|
history.submit();
|
|
history.submit();
|
|
-},
|
|
|
|
|
|
+ },
|
|
|
|
|
|
// 通过点击添加组件到画布
|
|
// 通过点击添加组件到画布
|
|
- async clickCompToDesign(compKey: ICompKeys, cb?: (comp: DesignComp) => void, history=true) {
|
|
|
|
|
|
+ async clickCompToDesign(
|
|
|
|
+ compKey: ICompKeys,
|
|
|
|
+ cb?: (comp: DesignComp) => void,
|
|
|
|
+ history = true
|
|
|
|
+ ) {
|
|
const page = this.controls.pageCtrl;
|
|
const page = this.controls.pageCtrl;
|
|
|
|
|
|
if (!page.currStreamCardId) {
|
|
if (!page.currStreamCardId) {
|
|
- queenApi.messageError("请先选中一个卡片");
|
|
|
|
- return;
|
|
|
|
|
|
+ queenApi.messageError("请先选中一个卡片");
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
let yOffset = 0;
|
|
let yOffset = 0;
|
|
@@ -133,15 +135,15 @@ export const editActions = EditorModule.action({
|
|
}
|
|
}
|
|
let currCard = page.currStreamCard;
|
|
let currCard = page.currStreamCard;
|
|
|
|
|
|
- const currComp = createObj({compKey}, false);
|
|
|
|
|
|
+ const currComp = createObj({ compKey }, false);
|
|
// debugger
|
|
// debugger
|
|
//@ts-ignore
|
|
//@ts-ignore
|
|
- const objs :any[] = currComp.children.objs || [];
|
|
|
|
|
|
+ const objs: any[] = currComp.children.objs || [];
|
|
if (objs.length > 0) {
|
|
if (objs.length > 0) {
|
|
- objs.forEach(o=>{
|
|
|
|
|
|
+ objs.forEach((o) => {
|
|
page.designData.compMap[o.id] = o;
|
|
page.designData.compMap[o.id] = o;
|
|
page.setCompPid(o.id, currComp.id);
|
|
page.setCompPid(o.id, currComp.id);
|
|
- })
|
|
|
|
|
|
+ });
|
|
}
|
|
}
|
|
page.designData.compMap[currComp.id] = currComp;
|
|
page.designData.compMap[currComp.id] = currComp;
|
|
page.setCompPid(currComp.id, currCard.id);
|
|
page.setCompPid(currComp.id, currCard.id);
|
|
@@ -180,7 +182,6 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
// 通过点击添加组件到画布
|
|
// 通过点击添加组件到画布
|
|
async clickCompUserToDesign(id: string, isSys) {
|
|
async clickCompUserToDesign(id: string, isSys) {
|
|
-
|
|
|
|
const page = this.controls.pageCtrl;
|
|
const page = this.controls.pageCtrl;
|
|
|
|
|
|
if (!page.currStreamCardId) {
|
|
if (!page.currStreamCardId) {
|
|
@@ -199,11 +200,10 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
page.setCompPid(compId, currCard.id);
|
|
page.setCompPid(compId, currCard.id);
|
|
|
|
|
|
-
|
|
|
|
this.actions.initAddedCompPos(this.store.currCompId, compId, currCard.id);
|
|
this.actions.initAddedCompPos(this.store.currCompId, compId, currCard.id);
|
|
|
|
|
|
this.controls.editorCtrl.clickPickComp(compId);
|
|
this.controls.editorCtrl.clickPickComp(compId);
|
|
-
|
|
|
|
|
|
+
|
|
history.submit();
|
|
history.submit();
|
|
},
|
|
},
|
|
|
|
|
|
@@ -241,7 +241,6 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
// 通过拖拽添加组件到画布
|
|
// 通过拖拽添加组件到画布
|
|
async dragCompToDesign(event: MouseEvent, compKey: string, data: any) {
|
|
async dragCompToDesign(event: MouseEvent, compKey: string, data: any) {
|
|
-
|
|
|
|
const page = this.controls.pageCtrl;
|
|
const page = this.controls.pageCtrl;
|
|
|
|
|
|
if (compKey == "CompCard") {
|
|
if (compKey == "CompCard") {
|
|
@@ -257,13 +256,12 @@ export const editActions = EditorModule.action({
|
|
page.setCompPid(compId, currCard.id);
|
|
page.setCompPid(compId, currCard.id);
|
|
|
|
|
|
this.controls.editorCtrl.clickPickComp(compId);
|
|
this.controls.editorCtrl.clickPickComp(compId);
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
await this.actions.addCompToDesign(compKey as any);
|
|
await this.actions.addCompToDesign(compKey as any);
|
|
}
|
|
}
|
|
|
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
- this.actions.centerLastComp(event)
|
|
|
|
|
|
+ this.actions.centerLastComp(event);
|
|
const currComp = this.controls.pageCtrl.currComp;
|
|
const currComp = this.controls.pageCtrl.currComp;
|
|
if (compKey == "Text") {
|
|
if (compKey == "Text") {
|
|
this.actions.textFocus(currComp.id, true);
|
|
this.actions.textFocus(currComp.id, true);
|
|
@@ -273,10 +271,10 @@ export const editActions = EditorModule.action({
|
|
}, 100);
|
|
}, 100);
|
|
},
|
|
},
|
|
|
|
|
|
- centerLastComp(event:MouseEvent) {
|
|
|
|
|
|
+ centerLastComp(event: MouseEvent) {
|
|
const currCardDom = this.controls.pageCtrl.currStreamCard.$el;
|
|
const currCardDom = this.controls.pageCtrl.currStreamCard.$el;
|
|
const cardPoints = this.helper.getPointOffsetWith(event, currCardDom);
|
|
const cardPoints = this.helper.getPointOffsetWith(event, currCardDom);
|
|
- const page = this.controls.pageCtrl;
|
|
|
|
|
|
+ const page = this.controls.pageCtrl;
|
|
let selCtrl = this.controls.selectCtrl;
|
|
let selCtrl = this.controls.selectCtrl;
|
|
|
|
|
|
const w = this.controls.screenCtrl.getCurrScreenWidth();
|
|
const w = this.controls.screenCtrl.getCurrScreenWidth();
|
|
@@ -299,7 +297,7 @@ export const editActions = EditorModule.action({
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (compKey == "Container") {
|
|
if (compKey == "Container") {
|
|
- const compId = page.insertDesignCard(index);
|
|
|
|
|
|
+ const compId = page.insertDesignCard(index);
|
|
this.controls.editorCtrl.clickPickComp(compId);
|
|
this.controls.editorCtrl.clickPickComp(compId);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -324,7 +322,7 @@ export const editActions = EditorModule.action({
|
|
ctrlState.selected = [];
|
|
ctrlState.selected = [];
|
|
const children = page.currStreamCard.children.default || [];
|
|
const children = page.currStreamCard.children.default || [];
|
|
const gizmo = this.controls.selectCtrl.gizmo;
|
|
const gizmo = this.controls.selectCtrl.gizmo;
|
|
- const selected = gizmo.selected.map(item=>item.comp.id);
|
|
|
|
|
|
+ const selected = gizmo.selected.map((item) => item.comp.id);
|
|
|
|
|
|
children.forEach((c) => {
|
|
children.forEach((c) => {
|
|
if (selected.indexOf(c) > -1) {
|
|
if (selected.indexOf(c) > -1) {
|
|
@@ -359,14 +357,14 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
const w = this.controls.screenCtrl.getCurrScreenWidth();
|
|
const w = this.controls.screenCtrl.getCurrScreenWidth();
|
|
if (this.selected.length == 1) {
|
|
if (this.selected.length == 1) {
|
|
- const size :any = layout.size.slice(0);
|
|
|
|
|
|
+ const size: any = layout.size.slice(0);
|
|
let isSame = false;
|
|
let isSame = false;
|
|
if (isWidth) {
|
|
if (isWidth) {
|
|
- isSame = w == size[0]
|
|
|
|
|
|
+ isSame = w == size[0];
|
|
size[0] = w;
|
|
size[0] = w;
|
|
- }
|
|
|
|
- else {
|
|
|
|
- isSame = size[1] == this.controls.pageCtrl.currStreamCard.layout.size[1]
|
|
|
|
|
|
+ } else {
|
|
|
|
+ isSame =
|
|
|
|
+ size[1] == this.controls.pageCtrl.currStreamCard.layout.size[1];
|
|
size[1] = this.controls.pageCtrl.currStreamCard.layout.size[1];
|
|
size[1] = this.controls.pageCtrl.currStreamCard.layout.size[1];
|
|
}
|
|
}
|
|
if (!isSame) {
|
|
if (!isSame) {
|
|
@@ -375,7 +373,7 @@ export const editActions = EditorModule.action({
|
|
}
|
|
}
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
const anchorBox = this.helper.findComp(gizmo.state.lastId);
|
|
const anchorBox = this.helper.findComp(gizmo.state.lastId);
|
|
if (!anchorBox) return;
|
|
if (!anchorBox) return;
|
|
|
|
|
|
@@ -413,14 +411,13 @@ export const editActions = EditorModule.action({
|
|
ctrlState.screenId = this.controls.screenCtrl.currScreenId;
|
|
ctrlState.screenId = this.controls.screenCtrl.currScreenId;
|
|
ctrlState.cardId = page.currStreamCardId;
|
|
ctrlState.cardId = page.currStreamCardId;
|
|
ctrlState.type = 3;
|
|
ctrlState.type = 3;
|
|
-
|
|
|
|
},
|
|
},
|
|
ctrlx() {
|
|
ctrlx() {
|
|
//console.log("ctrlv ", this.store.selected);
|
|
//console.log("ctrlv ", this.store.selected);
|
|
//console.log("ctrlv ", this.store.selected);
|
|
//console.log("ctrlv ", this.store.selected);
|
|
- const page = this.controls.pageCtrl;
|
|
|
|
|
|
+ const page = this.controls.pageCtrl;
|
|
const gizmo = this.controls.selectCtrl.gizmo;
|
|
const gizmo = this.controls.selectCtrl.gizmo;
|
|
- const selected = gizmo.selected.map(item=>item.comp.id);
|
|
|
|
|
|
+ const selected = gizmo.selected.map((item) => item.comp.id);
|
|
|
|
|
|
//保持图层顺序
|
|
//保持图层顺序
|
|
ctrlState.selected = [];
|
|
ctrlState.selected = [];
|
|
@@ -477,51 +474,52 @@ export const editActions = EditorModule.action({
|
|
this.controls.selectCtrl.gizmo.selectObjs(news);
|
|
this.controls.selectCtrl.gizmo.selectObjs(news);
|
|
|
|
|
|
//剪辑
|
|
//剪辑
|
|
-
|
|
|
|
- if (ctrlState.type == 2) {
|
|
|
|
- //剪辑删除原来的组件
|
|
|
|
- const card = this.helper.findComp(ctrlState.cardId) as DesignComp;
|
|
|
|
- const childs = card.children.default?.slice(0) || [];
|
|
|
|
- ctrlState.selected.forEach((s) => {
|
|
|
|
- let i = childs.indexOf(s);
|
|
|
|
- if (i != -1) {
|
|
|
|
- childs.splice(i, 1);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- card.children.default = childs;
|
|
|
|
- this.helper.extendStreamCard(ctrlState.cardId);
|
|
|
|
- ctrlState.selected = [];
|
|
|
|
- }
|
|
|
|
|
|
|
|
- //获取当前选中的内容
|
|
|
|
- if (ctrlState.cardId != ctrl.currStreamCardId) {
|
|
|
|
- //跨卡片拷贝
|
|
|
|
- let pox = this.helper.getCardNextPosY(
|
|
|
|
- ctrl.currStreamCardId,
|
|
|
|
- ctrlState.selWidth
|
|
|
|
- );
|
|
|
|
- this.controls.selectCtrl.translate(0, pox.y - ctrlState.selY);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ if (ctrlState.type == 2) {
|
|
|
|
+ //剪辑删除原来的组件
|
|
|
|
+ const card = this.helper.findComp(ctrlState.cardId) as DesignComp;
|
|
|
|
+ const childs = card.children.default?.slice(0) || [];
|
|
|
|
+ ctrlState.selected.forEach((s) => {
|
|
|
|
+ let i = childs.indexOf(s);
|
|
|
|
+ if (i != -1) {
|
|
|
|
+ childs.splice(i, 1);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ card.children.default = childs;
|
|
|
|
+ this.helper.extendStreamCard(ctrlState.cardId);
|
|
|
|
+ ctrlState.selected = [];
|
|
|
|
+ }
|
|
|
|
|
|
- if (ctrlState.screenId == this.controls.screenCtrl.currScreenId) {
|
|
|
|
- this.controls.selectCtrl.translate(20, 20);
|
|
|
|
- }
|
|
|
|
|
|
+ //获取当前选中的内容
|
|
|
|
+ if (ctrlState.cardId != ctrl.currStreamCardId) {
|
|
|
|
+ //跨卡片拷贝
|
|
|
|
+ let pox = this.helper.getCardNextPosY(
|
|
|
|
+ ctrl.currStreamCardId,
|
|
|
|
+ ctrlState.selWidth
|
|
|
|
+ );
|
|
|
|
+ this.controls.selectCtrl.translate(0, pox.y - ctrlState.selY);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- history.submit();
|
|
|
|
|
|
+ if (ctrlState.screenId == this.controls.screenCtrl.currScreenId) {
|
|
|
|
+ this.controls.selectCtrl.translate(20, 20);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ history.submit();
|
|
},
|
|
},
|
|
|
|
|
|
addComps(ids: string[]) {
|
|
addComps(ids: string[]) {
|
|
- const childs = this.controls.pageCtrl.currStreamCard.children.default.slice(0);
|
|
|
|
|
|
+ const childs =
|
|
|
|
+ this.controls.pageCtrl.currStreamCard.children.default.slice(0);
|
|
childs.push(...ids);
|
|
childs.push(...ids);
|
|
this.controls.pageCtrl.currStreamCard.children.setDefault(childs);
|
|
this.controls.pageCtrl.currStreamCard.children.setDefault(childs);
|
|
},
|
|
},
|
|
|
|
|
|
ctrlAndA() {
|
|
ctrlAndA() {
|
|
- const childrens = (this.controls.pageCtrl.currStreamCard.children.default || []).slice(
|
|
|
|
- 0
|
|
|
|
- );
|
|
|
|
- this.controls.selectCtrl.gizmo.selectObjs(childrens)
|
|
|
|
|
|
+ const childrens = (
|
|
|
|
+ this.controls.pageCtrl.currStreamCard.children.default || []
|
|
|
|
+ ).slice(0);
|
|
|
|
+ this.controls.selectCtrl.gizmo.selectObjs(childrens);
|
|
},
|
|
},
|
|
|
|
|
|
// 删除组件
|
|
// 删除组件
|
|
@@ -536,9 +534,9 @@ export const editActions = EditorModule.action({
|
|
},
|
|
},
|
|
|
|
|
|
// 删除组件
|
|
// 删除组件
|
|
- removeComp(compId: string, submitHistory= false) {
|
|
|
|
|
|
+ removeComp(compId: string, submitHistory = false) {
|
|
const ctrl = this.controls.pageCtrl;
|
|
const ctrl = this.controls.pageCtrl;
|
|
-
|
|
|
|
|
|
+
|
|
const paths = this.helper.getCompTrees(compId);
|
|
const paths = this.helper.getCompTrees(compId);
|
|
if (!paths[2]) {
|
|
if (!paths[2]) {
|
|
if (this.helper.isStreamCard(compId)) {
|
|
if (this.helper.isStreamCard(compId)) {
|
|
@@ -578,7 +576,7 @@ export const editActions = EditorModule.action({
|
|
let nextCard = ctrl.currStreamCardId;
|
|
let nextCard = ctrl.currStreamCardId;
|
|
if (compId == ctrl.currStreamCardId) {
|
|
if (compId == ctrl.currStreamCardId) {
|
|
const i = ctrl.streamCardIds.indexOf(compId);
|
|
const i = ctrl.streamCardIds.indexOf(compId);
|
|
- nextCard =ctrl.streamCardIds[i + 1];
|
|
|
|
|
|
+ nextCard = ctrl.streamCardIds[i + 1];
|
|
if (!nextCard) {
|
|
if (!nextCard) {
|
|
nextCard = ctrl.streamCardIds[i - 1];
|
|
nextCard = ctrl.streamCardIds[i - 1];
|
|
}
|
|
}
|
|
@@ -688,7 +686,7 @@ export const editActions = EditorModule.action({
|
|
}
|
|
}
|
|
|
|
|
|
queenApi.showLoading("保存中");
|
|
queenApi.showLoading("保存中");
|
|
-
|
|
|
|
|
|
+
|
|
await this.controls.uploader.uploadBlobs(ctrl.designData);
|
|
await this.controls.uploader.uploadBlobs(ctrl.designData);
|
|
if (this.store.isWk) {
|
|
if (this.store.isWk) {
|
|
await this.https[this.store.isEditPage ? "saveWkDesign" : "saveComp"](
|
|
await this.https[this.store.isEditPage ? "saveWkDesign" : "saveComp"](
|
|
@@ -710,7 +708,7 @@ export const editActions = EditorModule.action({
|
|
// 截屏保存封面
|
|
// 截屏保存封面
|
|
async updateThumbnailByScreenshot(autoSave?: boolean) {
|
|
async updateThumbnailByScreenshot(autoSave?: boolean) {
|
|
const ctrl = this.controls.pageCtrl;
|
|
const ctrl = this.controls.pageCtrl;
|
|
-
|
|
|
|
|
|
+
|
|
try {
|
|
try {
|
|
const rootComp = ctrl.rootPage;
|
|
const rootComp = ctrl.rootPage;
|
|
if (!rootComp) return;
|
|
if (!rootComp) return;
|
|
@@ -743,7 +741,6 @@ export const editActions = EditorModule.action({
|
|
comp.layout.transformMatrix = transformMatrix;
|
|
comp.layout.transformMatrix = transformMatrix;
|
|
},
|
|
},
|
|
|
|
|
|
-
|
|
|
|
// 设置组件显示隐藏
|
|
// 设置组件显示隐藏
|
|
setCompVisible(comp: DesignComp) {
|
|
setCompVisible(comp: DesignComp) {
|
|
comp.layout.visible = comp.layout.visible === false ? true : false;
|
|
comp.layout.visible = comp.layout.visible === false ? true : false;
|
|
@@ -752,10 +749,10 @@ export const editActions = EditorModule.action({
|
|
async resetCompName(comp: DesignComp) {
|
|
async resetCompName(comp: DesignComp) {
|
|
const res = await queenApi.showInput({
|
|
const res = await queenApi.showInput({
|
|
title: "重命名",
|
|
title: "重命名",
|
|
- defaultValue: comp.title,
|
|
|
|
|
|
+ defaultValue: comp.layout.cusName,
|
|
});
|
|
});
|
|
if (!res) return;
|
|
if (!res) return;
|
|
- comp.title = res;
|
|
|
|
|
|
+ comp.layout.cusName = res;
|
|
},
|
|
},
|
|
// 清除组件变换
|
|
// 清除组件变换
|
|
// clearCompTransform(comp: DesignComp) {
|
|
// clearCompTransform(comp: DesignComp) {
|
|
@@ -768,8 +765,7 @@ export const editActions = EditorModule.action({
|
|
},
|
|
},
|
|
// 设置组件层级
|
|
// 设置组件层级
|
|
setCompLayer(comp: DesignComp, offset: number) {
|
|
setCompLayer(comp: DesignComp, offset: number) {
|
|
-
|
|
|
|
- const currCard = this.controls.pageCtrl.currStreamCard
|
|
|
|
|
|
+ const currCard = this.controls.pageCtrl.currStreamCard;
|
|
const cards = currCard.children.default.slice(0);
|
|
const cards = currCard.children.default.slice(0);
|
|
|
|
|
|
const i = cards.indexOf(comp.id);
|
|
const i = cards.indexOf(comp.id);
|
|
@@ -795,7 +791,6 @@ export const editActions = EditorModule.action({
|
|
},
|
|
},
|
|
//横向对齐
|
|
//横向对齐
|
|
setAlignX(flag: 0 | 1 | 2 | 3, isGroup = false) {
|
|
setAlignX(flag: 0 | 1 | 2 | 3, isGroup = false) {
|
|
-
|
|
|
|
console.log("alignX");
|
|
console.log("alignX");
|
|
|
|
|
|
const selectCtrl = this.controls.selectCtrl;
|
|
const selectCtrl = this.controls.selectCtrl;
|
|
@@ -805,7 +800,6 @@ export const editActions = EditorModule.action({
|
|
const gizmo = selectCtrl.gizmo;
|
|
const gizmo = selectCtrl.gizmo;
|
|
|
|
|
|
if (gizmo.selected.length == 1 || isGroup) {
|
|
if (gizmo.selected.length == 1 || isGroup) {
|
|
-
|
|
|
|
const box = gizmo.getBound();
|
|
const box = gizmo.getBound();
|
|
|
|
|
|
switch (flag) {
|
|
switch (flag) {
|
|
@@ -921,7 +915,6 @@ export const editActions = EditorModule.action({
|
|
const anchorBox = this.helper.findComp(gizmo.state.lastId);
|
|
const anchorBox = this.helper.findComp(gizmo.state.lastId);
|
|
if (!anchorBox) return;
|
|
if (!anchorBox) return;
|
|
|
|
|
|
-
|
|
|
|
const anchor = new CompObject(anchorBox);
|
|
const anchor = new CompObject(anchorBox);
|
|
const anchorRect = anchor.getBox();
|
|
const anchorRect = anchor.getBox();
|
|
|
|
|
|
@@ -965,7 +958,7 @@ export const editActions = EditorModule.action({
|
|
});
|
|
});
|
|
|
|
|
|
gizmo.parent.updateTransform();
|
|
gizmo.parent.updateTransform();
|
|
- history.submit()
|
|
|
|
|
|
+ history.submit();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1002,7 +995,7 @@ export const editActions = EditorModule.action({
|
|
const gizmo = this.controls.selectCtrl.gizmo;
|
|
const gizmo = this.controls.selectCtrl.gizmo;
|
|
|
|
|
|
const parentMtrx = gizmo.parent.worldTransform.clone();
|
|
const parentMtrx = gizmo.parent.worldTransform.clone();
|
|
- gizmo.selectObjs([]);//取消选择
|
|
|
|
|
|
+ gizmo.selectObjs([]); //取消选择
|
|
|
|
|
|
childs.forEach((o) => {
|
|
childs.forEach((o) => {
|
|
const obj = this.helper.findComp(o) as DesignComp;
|
|
const obj = this.helper.findComp(o) as DesignComp;
|
|
@@ -1020,9 +1013,9 @@ export const editActions = EditorModule.action({
|
|
);
|
|
);
|
|
parentChilds.push(...childs);
|
|
parentChilds.push(...childs);
|
|
const page = this.controls.pageCtrl;
|
|
const page = this.controls.pageCtrl;
|
|
- childs.forEach(item=>{
|
|
|
|
|
|
+ childs.forEach((item) => {
|
|
page.setCompPid(item, card.id);
|
|
page.setCompPid(item, card.id);
|
|
- })
|
|
|
|
|
|
+ });
|
|
card.children.setDefault(parentChilds);
|
|
card.children.setDefault(parentChilds);
|
|
this.controls.editorCtrl.clickPickComp(childs[0]);
|
|
this.controls.editorCtrl.clickPickComp(childs[0]);
|
|
|
|
|
|
@@ -1030,11 +1023,10 @@ export const editActions = EditorModule.action({
|
|
},
|
|
},
|
|
|
|
|
|
createGroupComps() {
|
|
createGroupComps() {
|
|
-
|
|
|
|
const gizmo = this.controls.selectCtrl.gizmo;
|
|
const gizmo = this.controls.selectCtrl.gizmo;
|
|
const page = this.controls.pageCtrl;
|
|
const page = this.controls.pageCtrl;
|
|
|
|
|
|
- const sels = gizmo.selected.map(item=>item.comp.id);
|
|
|
|
|
|
+ const sels = gizmo.selected.map((item) => item.comp.id);
|
|
const id = this.controls.compUICtrl.createCompId("Group");
|
|
const id = this.controls.compUICtrl.createCompId("Group");
|
|
page.setCompPid(id, page.currStreamCardId);
|
|
page.setCompPid(id, page.currStreamCardId);
|
|
const comp = this.helper.findComp(id) as DesignComp;
|
|
const comp = this.helper.findComp(id) as DesignComp;
|
|
@@ -1050,14 +1042,14 @@ export const editActions = EditorModule.action({
|
|
newChilds.push(id);
|
|
newChilds.push(id);
|
|
|
|
|
|
//更新节点的新位置
|
|
//更新节点的新位置
|
|
- const newMatrixMap:any= {};
|
|
|
|
|
|
+ const newMatrixMap: any = {};
|
|
gizmo.parent.children.forEach((obj) => {
|
|
gizmo.parent.children.forEach((obj) => {
|
|
const cobj = obj as CompObject;
|
|
const cobj = obj as CompObject;
|
|
const comp = cobj.comp;
|
|
const comp = cobj.comp;
|
|
newMatrixMap[comp.id] = cobj.localTransform.getMatrixStr();
|
|
newMatrixMap[comp.id] = cobj.localTransform.getMatrixStr();
|
|
});
|
|
});
|
|
page.currStreamCard.children.setDefault(newChilds);
|
|
page.currStreamCard.children.setDefault(newChilds);
|
|
-
|
|
|
|
|
|
+
|
|
//再添加新的节点
|
|
//再添加新的节点
|
|
comp.layout.setSize([
|
|
comp.layout.setSize([
|
|
this.helper.pxToDesignSize(gizmo.width),
|
|
this.helper.pxToDesignSize(gizmo.width),
|
|
@@ -1067,10 +1059,10 @@ export const editActions = EditorModule.action({
|
|
|
|
|
|
this.controls.selectCtrl.gizmo.selectObjs([]);
|
|
this.controls.selectCtrl.gizmo.selectObjs([]);
|
|
|
|
|
|
- groupChilds.forEach((c)=> {
|
|
|
|
- const comp = this.helper.findComp(c) as DesignComp;
|
|
|
|
- comp.layout.setTransformMatrix(newMatrixMap[c]);
|
|
|
|
- page.setCompPid(c, id);
|
|
|
|
|
|
+ groupChilds.forEach((c) => {
|
|
|
|
+ const comp = this.helper.findComp(c) as DesignComp;
|
|
|
|
+ comp.layout.setTransformMatrix(newMatrixMap[c]);
|
|
|
|
+ page.setCompPid(c, id);
|
|
});
|
|
});
|
|
comp.children.setDefault(groupChilds);
|
|
comp.children.setDefault(groupChilds);
|
|
|
|
|
|
@@ -1114,11 +1106,11 @@ export const editActions = EditorModule.action({
|
|
content: "要替换正在编辑的内容?",
|
|
content: "要替换正在编辑的内容?",
|
|
});
|
|
});
|
|
if (!res) return;
|
|
if (!res) return;
|
|
-
|
|
|
|
|
|
+
|
|
const frameData = await this.https.getDesignDetail(record._id, {
|
|
const frameData = await this.https.getDesignDetail(record._id, {
|
|
isSys: true,
|
|
isSys: true,
|
|
});
|
|
});
|
|
- const { compMap, content, desc, thumbnail, title , _id} = frameData.result;
|
|
|
|
|
|
+ const { compMap, content, desc, thumbnail, title, _id } = frameData.result;
|
|
|
|
|
|
const designData = {
|
|
const designData = {
|
|
_id: ctrl.designData._id,
|
|
_id: ctrl.designData._id,
|