wnjk
Version:
两只蜗牛通用微服务脚本
61 lines (60 loc) • 2.66 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const pcNative_1 = __importDefault(require("./implements/pc/pcNative"));
const mobileNative_1 = __importDefault(require("./implements/app/mobileNative"));
const originalInfo_1 = __importStar(require("./model/originalInfo"));
const wrapStorage_1 = __importDefault(require("./utils/wrapStorage"));
const jsBridge_1 = __importDefault(require("./utils/jsBridge"));
const webNative_1 = __importDefault(require("./implements/web/webNative"));
class WNJK {
constructor() {
this.appCode = "";
this.platInfo = new originalInfo_1.default();
this.storage = wrapStorage_1.default;
this.jsBridge = jsBridge_1.default;
}
init() {
if (this.platInfo.nativeType == originalInfo_1.NativeType.PC) {
this.native = new pcNative_1.default(this.appCode);
}
else if (this.platInfo.nativeType == originalInfo_1.NativeType.Android || this.platInfo.nativeType == originalInfo_1.NativeType.Ios) {
this.native = new mobileNative_1.default(this.appCode);
}
else if (this.platInfo.nativeType == originalInfo_1.NativeType.Web) {
this.native = new webNative_1.default(this.appCode);
}
else {
throw new Error(`暂无此类平台交互实现:${this.platInfo.nativeType}`);
}
}
static createInstance(init) {
let wnjkObj = new WNJK();
wnjkObj.appCode = init.appCode;
wnjkObj.platInfo = init;
wnjkObj.init();
return wnjkObj;
}
}
exports.default = WNJK;