From 3ccc5907214398d2a06e45de5e884932ad43fae3 Mon Sep 17 00:00:00 2001 From: JianMiau Date: Sun, 2 Jan 2022 10:58:09 +0800 Subject: [PATCH] =?UTF-8?q?[add]=20=E8=9E=A2=E5=B9=95=E6=97=8B=E8=BD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Scene/Main.fire | 38 +++++++++++++++++++++++++++++++++++--- assets/Script/Manager.ts | 17 ++++++++++++++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/assets/Scene/Main.fire b/assets/Scene/Main.fire index 4f44f10..532b6c8 100644 --- a/assets/Scene/Main.fire +++ b/assets/Scene/Main.fire @@ -77,14 +77,14 @@ ], "_active": true, "_components": [ - { - "__id__": 7 - }, { "__id__": 8 }, { "__id__": 9 + }, + { + "__id__": 10 } ], "_prefab": null, @@ -245,6 +245,9 @@ "_components": [ { "__id__": 6 + }, + { + "__id__": 7 } ], "_prefab": null, @@ -307,6 +310,35 @@ "webviewEvents": [], "_id": "0dhyrwc5lM/oEUOjnLH8Wx" }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 5 + }, + "_enabled": true, + "alignMode": 1, + "_target": { + "__id__": 2 + }, + "_alignFlags": 45, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 1080, + "_originalHeight": 1920, + "_id": "86PkA+qQ9MHrsu5Inmk20K" + }, { "__type__": "cc.Canvas", "_name": "", diff --git a/assets/Script/Manager.ts b/assets/Script/Manager.ts index 39ecbc6..f7b28a1 100644 --- a/assets/Script/Manager.ts +++ b/assets/Script/Manager.ts @@ -13,7 +13,22 @@ export default class Manager extends cc.Component { protected onLoad(): void { this.webview.url = `https://karolchang.github.io/jm-expense-vue-ts/?ignore=${Date.now()}`; - this.webview.node.active = true + this.webview.node.active = true; + + cc.view.setResizeCallback(this._resize.bind(this)); + this._resize(); + } + + private _resize(): void { + let Canvas: cc.Canvas = cc.Canvas.instance; + Canvas.designResolution = cc.size(Canvas.designResolution.height, Canvas.designResolution.width); + // let rect: DOMRect = cc.game.canvas.getBoundingClientRect(); + // /** 判断是否是横屏 */ + // let landscape: boolean = false; + // if (rect.width > rect.height) { + // landscape = true; + // } + // // 根据横竖屏调整节点的位置适配等 } //#endregion