[add] 防呆

This commit is contained in:
建喵 2022-08-29 12:25:51 +08:00
parent c0ea0d936b
commit b4571e07aa

View File

@ -62,14 +62,19 @@ export default class Manager extends cc.Component {
self.Birdge(method, value); self.Birdge(method, value);
}; };
} }
let scheme: string = "jmka"; let scheme: string = "http";
this.webview.setJavascriptInterfaceScheme(scheme); this.webview.setJavascriptInterfaceScheme(scheme);
this.webview.setOnJSCallback((sender: any, url: any) => { this.webview.setOnJSCallback((sender: any, url: any) => {
let data: JSON = JSON.parse(decodeURI(url.split(`${scheme}://`)[1])); let content: string = decodeURI(url.split(`${scheme}://`)[1]);
let method: any = data["method"]; try {
let value: any = data["value"]; let data: JSON = JSON.parse(content);
if (method) { let method: any = data["method"];
self.Birdge(method, ...value); let value: any = data["value"];
if (method) {
self.Birdge(method, ...value);
}
} catch (error) {
console.error(error);
} }
}); });
} }