[add] webview改透明度
This commit is contained in:
parent
3bdf5bf905
commit
ef23390d9a
@ -5,10 +5,10 @@ export default class Manager extends cc.Component {
|
|||||||
//#region 外調參數
|
//#region 外調參數
|
||||||
|
|
||||||
@property({ type: cc.WebView })
|
@property({ type: cc.WebView })
|
||||||
public webview: cc.WebView = null
|
public webview: cc.WebView = null;
|
||||||
|
|
||||||
@property({ type: cc.Node })
|
@property({ type: cc.Node })
|
||||||
public BG: cc.Node = null
|
public BG: cc.Node = null;
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
@ -18,8 +18,8 @@ export default class Manager extends cc.Component {
|
|||||||
let self: this = this;
|
let self: this = this;
|
||||||
window.addEventListener("message", function (e: MessageEvent<any>): void {
|
window.addEventListener("message", function (e: MessageEvent<any>): void {
|
||||||
let data: any = e.data;
|
let data: any = e.data;
|
||||||
let method = data.method;
|
let method: string = data.method;
|
||||||
let value = data.value;
|
let value: any = data.value;
|
||||||
if (method && self[method]) {
|
if (method && self[method]) {
|
||||||
if (value) {
|
if (value) {
|
||||||
self[method](...value);
|
self[method](...value);
|
||||||
@ -33,16 +33,25 @@ export default class Manager extends cc.Component {
|
|||||||
}, false);
|
}, false);
|
||||||
let href: string = window.location.href;
|
let href: string = window.location.href;
|
||||||
|
|
||||||
this.webview.url = `https://karolchang.github.io/jm-expense-vue-ts/?ignore=${Date.now()}`;
|
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/?ignore=${Date.now()}&host=${href}`;
|
// this.webview.url = `http://localhost:8080/jm-expense-vue-ts/?host=${href}&ignore=${Date.now()}`;
|
||||||
this.webview.node.active = true;
|
this.webview.node.active = true;
|
||||||
|
|
||||||
cc.view.setResizeCallback(this._resize.bind(this));
|
cc.view.setResizeCallback(this._resize.bind(this));
|
||||||
this._resize();
|
this._resize();
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.webview.node.opacity === 0) {
|
||||||
|
self._closeBG();
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _closeBG(): void {
|
private _closeBG(): void {
|
||||||
this.BG.destroy();
|
this.BG.destroy();
|
||||||
|
this.webview.node.opacity = 255;
|
||||||
|
this.webview.node.active = false;
|
||||||
|
this.webview.node.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _log(msg: string): void {
|
private _log(msg: string): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user