[add] 防呆

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

View File

@ -62,15 +62,20 @@ 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]);
try {
let data: JSON = JSON.parse(content);
let method: any = data["method"]; let method: any = data["method"];
let value: any = data["value"]; let value: any = data["value"];
if (method) { if (method) {
self.Birdge(method, ...value); self.Birdge(method, ...value);
} }
} catch (error) {
console.error(error);
}
}); });
} }