|
@@ -1,4 +1,4 @@
|
|
|
-import { cloneDeep, pick } from "lodash";
|
|
|
+import { cloneDeep, curry, pick } from "lodash";
|
|
|
import { Exception, queenApi } from "queenjs";
|
|
|
import { EditorModule } from "..";
|
|
|
import { ScreenshotCtrl } from "../../controllers/ScreenshotCtrl";
|
|
@@ -10,9 +10,17 @@ 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 { string } from "vue-types";
|
|
|
|
|
|
-let ctrlcselected: string[] = [];
|
|
|
+
|
|
|
+const ctrlState = {
|
|
|
+ selected: [] as string[],
|
|
|
+ type: 0, // 1 ctrlc 2 ctrlx
|
|
|
+ cardId: "", //当前的卡片Id
|
|
|
+ screenId: "", //屏幕Id
|
|
|
+ selWidth: 0,
|
|
|
+ selX: 0,
|
|
|
+ selY: 0
|
|
|
+}
|
|
|
|
|
|
export const editActions = EditorModule.action({
|
|
|
pickComp(compId: string, selected = true) {
|
|
@@ -259,7 +267,7 @@ export const editActions = EditorModule.action({
|
|
|
this.helper.extendStreamCard(compId);
|
|
|
|
|
|
this.actions.selectObjs([]);
|
|
|
-
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -319,12 +327,30 @@ export const editActions = EditorModule.action({
|
|
|
},
|
|
|
|
|
|
ctrlc() {
|
|
|
- // console.log("contrc ", this.store.selected);
|
|
|
- ctrlcselected = this.store.selected.slice(0);
|
|
|
+ ctrlState.selected = [];
|
|
|
+ const children = this.store.currStreamCard.children.default || [];
|
|
|
+ children.forEach(c=>{
|
|
|
+ if (this.store.selected.indexOf(c) > -1) {
|
|
|
+ ctrlState.selected.push(c);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ctrlState.screenId = this.controls.screenCtrl.currScreenId;
|
|
|
+ ctrlState.cardId = this.store.currStreamCardId;
|
|
|
+ ctrlState.type = 1;
|
|
|
+ const objc = this.controls.selectCtrl.objContainer as ObjsContainer;
|
|
|
+ ctrlState.selWidth = this.helper.pxToDesignSize(objc.width);
|
|
|
+ objc.setPivot(0);
|
|
|
+ const currX = objc.parent.x, currY = objc.parent.y;
|
|
|
+ ctrlState.selX = currX;
|
|
|
+ ctrlState.selY = currY;
|
|
|
+ objc.setPivot(4);
|
|
|
},
|
|
|
+
|
|
|
copyLastSelected() {
|
|
|
if (this.store.currCompId && this.store.currCompId != "root") {
|
|
|
- ctrlcselected = [this.store.currCompId];
|
|
|
+ ctrlState.selected = [this.store.currCompId];
|
|
|
+ ctrlState.cardId = this.store.currStreamCardId;
|
|
|
+ ctrlState.type = 1;
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -368,10 +394,33 @@ export const editActions = EditorModule.action({
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ ctrlx() {
|
|
|
+ //console.log("ctrlv ", this.store.selected);
|
|
|
+ //console.log("ctrlv ", this.store.selected);
|
|
|
+
|
|
|
+ //保持图层顺序
|
|
|
+ ctrlState.selected = [];
|
|
|
+ const children = this.store.currStreamCard.children.default || [];
|
|
|
+ children.forEach(c=>{
|
|
|
+ if (this.store.selected.indexOf(c) > -1) {
|
|
|
+ ctrlState.selected.push(c);
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ ctrlState.cardId = this.store.currStreamCardId;
|
|
|
+ ctrlState.type = 2;
|
|
|
+ ctrlState.screenId = this.controls.screenCtrl.currScreenId;
|
|
|
+ const objc = this.controls.selectCtrl.objContainer as ObjsContainer;
|
|
|
+ ctrlState.selWidth = this.helper.pxToDesignSize(objc.width);
|
|
|
+ objc.setPivot(0);
|
|
|
+ const currX = objc.parent.x, currY = objc.parent.y;
|
|
|
+ ctrlState.selX = currX;
|
|
|
+ ctrlState.selY = currY;
|
|
|
+ objc.setPivot(4);
|
|
|
+ },
|
|
|
|
|
|
ctrlv() {
|
|
|
- console.log("ctrlv ", this.store.selected);
|
|
|
- if (ctrlcselected.length < 1) return;
|
|
|
+ if (ctrlState.selected.length < 1) return;
|
|
|
|
|
|
const news: string[] = [];
|
|
|
|
|
@@ -391,24 +440,46 @@ export const editActions = EditorModule.action({
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- ctrlcselected.forEach((c) => {
|
|
|
+
|
|
|
+ ctrlState.selected.forEach((c) => {
|
|
|
const cp = this.helper.findComp(c) as DesignComp;
|
|
|
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);
|
|
|
|
|
|
deepCopy(cp);
|
|
|
});
|
|
|
-
|
|
|
this.actions.addComps(news);
|
|
|
|
|
|
this.actions.selectObjs(news);
|
|
|
|
|
|
setTimeout(() => {
|
|
|
- this.controls.selectCtrl.translate(20, 20);
|
|
|
+ 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 != this.store.currStreamCardId) {//跨卡片拷贝
|
|
|
+ let pox = this.helper.getCardNextPosY(this.store.currStreamCardId, ctrlState.selWidth);
|
|
|
+ this.controls.selectCtrl.translate(0, pox.y - ctrlState.selY);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ctrlState.screenId == this.controls.screenCtrl.currScreenId) {
|
|
|
+ this.controls.selectCtrl.translate(20, 20);
|
|
|
+ }
|
|
|
}, 100);
|
|
|
},
|
|
|
|
|
@@ -554,14 +625,14 @@ export const editActions = EditorModule.action({
|
|
|
async saveDesign() {
|
|
|
try {
|
|
|
// 清除无用组件
|
|
|
- this.helper.clearUnusedComps(this.store.designData.compMap);
|
|
|
+ this.helper.clearProjectUnusedComps(this.store.designData.compMap);
|
|
|
const c = this.controls.screenCtrl;
|
|
|
-
|
|
|
+ c.saveScreenPage();
|
|
|
const root = this.helper.findRootComp() as DesignComp;
|
|
|
- root.value.useFor = c.state.useFor;
|
|
|
- root.value.pageMode = c.state.pageMode;
|
|
|
- root.value.pageSizeType = c.state.pageSizeType;
|
|
|
-
|
|
|
+ root.value.useFor = c.state.screen.useFor;
|
|
|
+ root.value.pageMode = c.state.screen.pageMode;
|
|
|
+ root.value.pageSizeType = c.state.screen.pageSizeType;
|
|
|
+
|
|
|
// 封面截屏
|
|
|
if (!this.store.designData.thumbnail) {
|
|
|
await this.actions.updateThumbnailByScreenshot();
|