UNPKG

@sinosun/lib

Version:

sinosun jsbridge and net toolkit

105 lines (77 loc) 2.88 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); var _defineProperty = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property")); var __importDefault = void 0 && (void 0).__importDefault || function (mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; (0, _defineProperty["default"])(exports, "__esModule", { value: true }); /* * @Description: * @FilePath: \weboah5d:\gitCode\sinosunlib\src\AppApi\bridgeAdapter.ts */ var SinoJSBridgeImpl_1 = __importDefault(require("./Bridge/impl/SinoJSBridgeImpl")); var JSBridgeAdapter = /** @class */ function () { // 默认是 sinosun jsbridge的实现 function JSBridgeAdapter() { this.jsBridgeImpl = new SinoJSBridgeImpl_1["default"](); } /** * 设置jsbridge的实现,默认是sinosun jsbridge的实现,可以设置IJsBridge的mPaaS、tmf实现 * @param {*} impl */ JSBridgeAdapter.prototype.setJsBridgeImpl = function (impl) { if (impl) { this.jsBridgeImpl = impl; } }; JSBridgeAdapter.prototype.callHandler = function (method, data) { return this.jsBridgeImpl.callHandler(method, data); }; // 注册阿里的jsbridge js注册方法等待App调用 JSBridgeAdapter.prototype.registerHandler = function (method, callback) { return this.jsBridgeImpl.registerHandler(method, function (data) { callback(data); }); }; JSBridgeAdapter.prototype.openPage = function (url, target) { this.jsBridgeImpl.openPage(url, target); }; /** * 监听app菜单监听事件 */ JSBridgeAdapter.prototype.registerMenu = function (menuList) { this.jsBridgeImpl.registerMenu(menuList); }; /** * 回退页面 * @param {Object} url //目标页面url */ JSBridgeAdapter.prototype.goBack = function (url, backSteps, loadData) { this.jsBridgeImpl.goBack(url, backSteps, loadData); }; JSBridgeAdapter.prototype.getUrlParam = function (key, urlParams) { return this.jsBridgeImpl.getUrlParam(key, urlParams); }; // 获取真实地址 JSBridgeAdapter.prototype.getRealHost = function (key) { return this.jsBridgeImpl.getRealHost(key); }; //打开小应用,如果小应用入口地址不能配置全,需要做处理 JSBridgeAdapter.prototype.openAppRoute = function () { return this.jsBridgeImpl.openAppRoute(); }; JSBridgeAdapter.prototype.fileUploadFunction = function (data) { return this.jsBridgeImpl.fileUploadFunction(data); }; //选择联系人 JSBridgeAdapter.prototype.selectContact = function (data) { return this.jsBridgeImpl.selectContact(data); }; //扫描二维码 JSBridgeAdapter.prototype.scanQrcode = function (data) { return this.jsBridgeImpl.scanQrcode(data); }; return JSBridgeAdapter; }(); exports["default"] = new JSBridgeAdapter();