[mod] 監聽時機調整

This commit is contained in:
建喵 2022-08-29 09:54:55 +08:00
parent f4b2afb9f5
commit e5b166415f

View File

@ -31,6 +31,22 @@ export default class Manager extends cc.Component {
let self: this = this; let self: this = this;
// this._text_to_Speech = new Text_to_Speech(); // this._text_to_Speech = new Text_to_Speech();
let href: string = window.location.href;
// let url: string = `http://220.134.195.1/public/bonus_casino/html5/jianmiau/Test/?host=${href}&v=${Date.now()}`;
// let url: string = `https://karolchang.github.io/jm-expense-vue-ts/?host=${href}&ignore=${Date.now()}`;
// let url: string = `http://karol.jianmiau.cf/jm-expense-vue-ts/?v=${Date.now()}`;
let url: string = `https://jm-expense-2022.firebaseapp.com/login?host=${href}&v=${Date.now()}`;
this.webview.url = url;
this.webview.node.active = true;
cc.view.setResizeCallback(this._resize.bind(this));
this._resize();
const FCMToken: string = NativeClass.Instance.GetFCMToken();
console.log(`FCMToken ${FCMToken}`);
// Set EventListener
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: string = data.method; let method: string = data.method;
@ -47,7 +63,7 @@ export default class Manager extends cc.Component {
} }
let scheme: string = "jmka"; let scheme: string = "jmka";
this.webview.setJavascriptInterfaceScheme(scheme); this.webview.setJavascriptInterfaceScheme(scheme);
this.webview.setOnJSCallback((sender, url) => { this.webview.setOnJSCallback((sender: any, url: any) => {
let data: JSON = JSON.parse(decodeURI(url.split(`${scheme}://`)[1])); let data: JSON = JSON.parse(decodeURI(url.split(`${scheme}://`)[1]));
let method: any = data["method"]; let method: any = data["method"];
let value: any = data["value"]; let value: any = data["value"];
@ -55,20 +71,6 @@ export default class Manager extends cc.Component {
self.Birdge(method, ...value); self.Birdge(method, ...value);
} }
}); });
let href: string = window.location.href;
// let url: string = `http://220.134.195.1/public/bonus_casino/html5/jianmiau/Test/?host=${href}&v=${Date.now()}`;
// let url: string = `https://karolchang.github.io/jm-expense-vue-ts/?host=${href}&ignore=${Date.now()}`;
// let url: string = `http://karol.jianmiau.cf/jm-expense-vue-ts/?v=${Date.now()}`;
let url: string = `https://jm-expense-2022.firebaseapp.com/login?host=${href}&v=${Date.now()}`;
this.webview.url = url;
this.webview.node.active = true;
cc.view.setResizeCallback(this._resize.bind(this));
this._resize();
const FCMToken: string = NativeClass.Instance.GetFCMToken();
console.log(`FCMToken ${FCMToken}`);
} }
/** /**