|
@@ -37,6 +37,7 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
|
|
|
docWidth: window.innerWidth, //实际屏幕宽度
|
|
|
docHeight: window.innerHeight, //实际屏幕高度
|
|
|
safeFactor: 0.8,
|
|
|
+ currScreenId: ""
|
|
|
})
|
|
|
|
|
|
get isShortPage () {
|
|
@@ -50,6 +51,14 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
|
|
|
}
|
|
|
|
|
|
initEvent() {
|
|
|
+
|
|
|
+ window.addEventListener("resize", ()=>{
|
|
|
+ if ( !this.store.isDisplay ) return;
|
|
|
+
|
|
|
+ console.log("apply screen");
|
|
|
+ this.applyScreen();
|
|
|
+ })
|
|
|
+
|
|
|
if ( !this.store.isEditMode ) return;
|
|
|
this.state.onScreenChanged(()=>this.updateAdapterState());
|
|
|
|
|
@@ -91,6 +100,7 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
|
|
|
const option = this.getRightScreenId();
|
|
|
if ( this.isScreenExit(option.sreenId) ) {
|
|
|
this.restorScreenPage(option.sreenId);
|
|
|
+ this.state.currScreenId = option.sreenId;
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -99,6 +109,7 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
|
|
|
const screenId = option.device + option.pageMode + AllSize[n];
|
|
|
if ( this.isScreenExit(screenId) ) {
|
|
|
this.restorScreenPage(screenId);
|
|
|
+ this.state.currScreenId = screenId;
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -113,6 +124,7 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
|
|
|
const screenId = option.device + "short" + AllSize[n];
|
|
|
if ( this.isScreenExit(screenId) ) {
|
|
|
this.restorScreenPage(screenId);
|
|
|
+ this.state.currScreenId = screenId;
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -143,7 +155,9 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
|
|
|
|
|
|
updateAdapterState() {
|
|
|
if (!this.store.rootPage) return;
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
this.restorScreenPage();
|
|
|
|
|
|
this.store.streamCardIds.forEach(c=>{
|
|
@@ -158,7 +172,9 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
|
|
|
this.store.rootPage.layout.size[0] = this.getCurrScreenWidth();
|
|
|
this.store.rootPage.layout.size[1] = this.getCurrScreenHeight();
|
|
|
|
|
|
- this.state.safeFactor = this.state.screen.useFor == "pc" ? PCConst.factor : MobileConst.factor;
|
|
|
+ this.state.safeFactor = this.state.screen.useFor == "pc" ? PCConst.factor : MobileConst.factor;
|
|
|
+
|
|
|
+ this.state.currScreenId = this.currScreenId;
|
|
|
}
|
|
|
isScreenExit(screenId:string) {
|
|
|
return !!this.store.designData.compScreenMap[screenId] &&
|
|
@@ -168,8 +184,7 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
|
|
|
|
|
|
restorScreenPage(screenId = "") {
|
|
|
if (!this.store.rootPage) return;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
//获取当前screen的配置
|
|
|
screenId = screenId ? screenId : this.state.screen.useFor + this.state.screen.pageMode + this.state.screen.pageSizeType;
|
|
|
const screenCards = this.store.designData.compScreenMap[screenId] || [];
|
|
@@ -182,6 +197,11 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
|
|
|
const screenCard = screenCards.find(item=>item.id == c)
|
|
|
let newChilds:string[] = [];
|
|
|
let childrs = screenCard?.children || [];
|
|
|
+ if (screenCard && screenCard.size){
|
|
|
+ card.layout.size[0] = screenCard.size[0];
|
|
|
+ card.layout.size[1] = screenCard.size[1];
|
|
|
+ }
|
|
|
+
|
|
|
childrs.forEach(item=>{
|
|
|
newChilds.push(item.id);
|
|
|
const screenComp = this.helper.findComp(item.id) as DesignComp;
|
|
@@ -209,6 +229,7 @@ export class ScreenCtrl extends ModuleControl<EditorModule> {
|
|
|
const card = compMap[c] as DesignComp;
|
|
|
const screenCard :CardState = {
|
|
|
id: c,
|
|
|
+ size: [card.layout.size[0], card.layout.size[1]],
|
|
|
children: []
|
|
|
}
|
|
|
let childrs = card.children.default || [];
|