UNPKG

olympus-r-17plugins

Version:

A plugin of Olympus for 17zuoye.

112 lines (111 loc) 4.46 kB
import { core } from "olympus-r/core/Core"; import { engine } from "olympus-r/engine/Engine"; import Shell from "olympus-r/engine/env/Shell"; import { moduleManager } from "olympus-r/engine/module/ModuleManager"; import { environment17 } from "./env/Environment17"; import Shell17 from "./env/Shell17"; import Shell17Android from "./env/Shell17Android"; import Shell17AndroidParent from "./env/Shell17AndroidParent"; import Shell17AndroidStudent from "./env/Shell17AndroidStudent"; import Shell17AndroidTeacher from "./env/Shell17AndroidTeacher"; import Shell17AndroidYunketang from './env/Shell17AndroidYunketang'; import Shell17IOS from "./env/Shell17IOS"; import Shell17IOSParent from "./env/Shell17IOSParent"; import Shell17IOSStudent from "./env/Shell17IOSStudent"; import Shell17IOSTeacher from "./env/Shell17IOSTeacher"; import Shell17IOSYunketang from './env/Shell17IOSYunketang'; import Shell17WXApp from "./env/Shell17WXApp"; import { LogLevel, logManager } from "./log/LogManager"; /** * @author Raykid * @email initial_r@qq.com * @create date 2017-10-25 * @modify date 2017-10-25 * * 为一起作业定制的Olympus插件 */ var Olympus17Plugin = /** @class */ (function () { function Olympus17Plugin(app, testInitParams) { this._app = app; this._testInitParams = testInitParams; } Olympus17Plugin.prototype.initPlugin = function () { // 初始化一起作业环境变量 this.initEnvironment(); // 监控全局报错,并发送错误日志 this.initErrorMonitor(); }; Olympus17Plugin.prototype.initEnvironment = function () { environment17.initialize(this._app, this._testInitParams); }; Olympus17Plugin.prototype.initErrorMonitor = function () { engine.listenError(function (evt) { // 利用通用提示框提示 // panelManager.alert(evt.message); // 记录错误日志 logManager.remoteLog({ _lv: LogLevel.ERR, module: environment17.app, op: "window.onerror", err_code: "", msg: evt.message }, { errorMessage: evt.message, scriptURI: evt.filename, lineNumber: evt.lineno, columnNumber: evt.colno, errorObj: evt.error, currentModule: (moduleManager.currentModuleInstance && moduleManager.currentModuleInstance.moduleName) }); }); }; return Olympus17Plugin; }()); export default Olympus17Plugin; // 初始化外壳 initShell(); function initShell() { /** 判断环境以确定要注入的实际对象 */ if (window["__wxjs_environment"] === "miniprogram") { core.mapInject(Shell17WXApp, Shell); core.mapInject(Shell17WXApp, Shell17); core.mapInject(Shell17WXApp, Shell17WXApp); } else if (/iPhone|iPad|iPod|iOS/i.test(navigator.userAgent)) { var cls = Shell17; if (/17student/i.test(navigator.userAgent)) cls = Shell17IOSStudent; else if (/17teacher/i.test(navigator.userAgent)) cls = Shell17IOSTeacher; else if (/17parent/i.test(navigator.userAgent)) cls = Shell17IOSParent; else if (/17Yunketang/i.test(navigator.userAgent)) cls = Shell17IOSYunketang; core.mapInject(cls, Shell); core.mapInject(cls, Shell17); core.mapInject(cls, Shell17IOS); core.mapInject(cls, cls); } else if (/Android/i.test(navigator.userAgent)) { var cls = Shell17; if (/17student/i.test(navigator.userAgent)) cls = Shell17AndroidStudent; else if (/17teacher/i.test(navigator.userAgent)) cls = Shell17AndroidTeacher; else if (/17parent/i.test(navigator.userAgent)) cls = Shell17AndroidParent; else if (/17Yunketang/i.test(navigator.userAgent)) cls = Shell17AndroidYunketang; core.mapInject(cls, Shell); core.mapInject(cls, Shell17); core.mapInject(cls, Shell17Android); core.mapInject(cls, cls); } else { core.mapInject(Shell17, Shell); core.mapInject(Shell17, Shell17); } // 统一进行一次初始化 var shell17 = core.getInject(Shell17); shell17.initShell17(); }