From ef23390d9afa1e8ce5d28593007838786552e047 Mon Sep 17 00:00:00 2001 From: JianMiau Date: Wed, 5 Jan 2022 09:01:27 +0800 Subject: [PATCH] =?UTF-8?q?[add]=20webview=E6=94=B9=E9=80=8F=E6=98=8E?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Script/Manager.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/assets/Script/Manager.ts b/assets/Script/Manager.ts index 2fec9c0..3bf592e 100644 --- a/assets/Script/Manager.ts +++ b/assets/Script/Manager.ts @@ -5,10 +5,10 @@ export default class Manager extends cc.Component { //#region 外調參數 @property({ type: cc.WebView }) - public webview: cc.WebView = null + public webview: cc.WebView = null; @property({ type: cc.Node }) - public BG: cc.Node = null + public BG: cc.Node = null; //#endregion @@ -18,8 +18,8 @@ export default class Manager extends cc.Component { let self: this = this; window.addEventListener("message", function (e: MessageEvent): void { let data: any = e.data; - let method = data.method; - let value = data.value; + let method: string = data.method; + let value: any = data.value; if (method && self[method]) { if (value) { self[method](...value); @@ -33,16 +33,25 @@ export default class Manager extends cc.Component { }, false); let href: string = window.location.href; - this.webview.url = `https://karolchang.github.io/jm-expense-vue-ts/?ignore=${Date.now()}`; - // this.webview.url = `http://localhost:8080/jm-expense-vue-ts/?ignore=${Date.now()}&host=${href}`; + this.webview.url = `https://karolchang.github.io/jm-expense-vue-ts/?host=${href}&ignore=${Date.now()}`; + // this.webview.url = `http://localhost:8080/jm-expense-vue-ts/?host=${href}&ignore=${Date.now()}`; this.webview.node.active = true; cc.view.setResizeCallback(this._resize.bind(this)); this._resize(); + + setTimeout(() => { + if (this.webview.node.opacity === 0) { + self._closeBG(); + } + }, 2000); } private _closeBG(): void { this.BG.destroy(); + this.webview.node.opacity = 255; + this.webview.node.active = false; + this.webview.node.active = true; } private _log(msg: string): void {