| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- (function () {
- 'use strict';
- function isBridgeReady() {
- return window.flutter_inappwebview && typeof window.flutter_inappwebview.callHandler === 'function';
- }
- function callHandler(name, args) {
- if (!isBridgeReady()) return undefined;
- try {
- if (args !== undefined) {
- return window.flutter_inappwebview.callHandler(name, args);
- }
- return window.flutter_inappwebview.callHandler(name);
- } catch (e) {
- return undefined;
- }
- }
- function callHandlerSafe(name, args) {
- if (!isBridgeReady()) return;
- try {
- if (args !== undefined) {
- window.flutter_inappwebview.callHandler(name, args);
- } else {
- window.flutter_inappwebview.callHandler(name);
- }
- } catch (e) { }
- }
- async function getToken() {
- if (!isBridgeReady()) throw new Error('Bridge not ready');
- try {
- const token = await window.flutter_inappwebview.callHandler('getToken');
- if (token) return token;
- throw new Error('Bridge not ready');
- } catch (e) {
- throw new Error('Bridge not ready');
- }
- }
- async function getActivityId() {
- if (!isBridgeReady()) throw new Error('Bridge not ready');
- try {
- const result = await window.flutter_inappwebview.callHandler('getActivityId');
- return result || '';
- } catch (e) {
- return '';
- }
- }
- async function getLocalTime(timestamp) {
- // if (!isBridgeReady()) throw new Error('Bridge not ready');
- try {
- return await window.flutter_inappwebview.callHandler('getLocalTime', timestamp);
- } catch (e) {
- return timestamp || '';
- }
- }
- function closeWebview() {
- callHandlerSafe('closeWebview');
- }
- function jumpToLogin() {
- callHandlerSafe('jumpToLogin');
- }
- function jumpToDeposit() {
- callHandlerSafe('jumpToDeposit');
- }
- function showToast(message) {
- callHandlerSafe('showToast', message);
- }
- function showInviteView(params) {
- callHandlerSafe('showInviteView', params);
- }
- function goRouterName(path) {
- callHandlerSafe('goRouterName', { path: path });
- }
- window.BEXBridge = {
- isBridgeReady: isBridgeReady,
- callHandler: callHandler,
- callHandlerSafe: callHandlerSafe,
- getToken: getToken,
- getActivityId: getActivityId,
- getLocalTime: getLocalTime,
- closeWebview: closeWebview,
- jumpToLogin: jumpToLogin,
- jumpToDeposit: jumpToDeposit,
- showToast: showToast,
- showInviteView: showInviteView,
- goRouterName: goRouterName
- };
- })();
|