@vue-async/module-loader
Version:
Module Loader Core.
64 lines • 2.22 kB
JavaScript
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
import warning from 'warning';
import { hasOwn } from '@ace-util/core';
import { version } from './version';
import install from './install';
var ModuleLoader = /** @class */ (function () {
function ModuleLoader(options) {
var _this = this;
this._framework = {};
options &&
Object.entries(options).map(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
if (!hasOwn(_this._framework, key)) {
_this._framework[key] = value;
}
else {
warning(process.env.NODE_ENV === 'production', "".concat(key, " has been defined"));
}
});
}
Object.defineProperty(ModuleLoader.prototype, "framework", {
get: function () {
return this._framework;
},
enumerable: false,
configurable: true
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ModuleLoader.prototype.init = function (root, ssrContext) {
// 默认方法
!hasOwn(this._framework, 'addRoutes') && (this._framework.addRoutes = this._createAddRoutes(root));
};
ModuleLoader.prototype._createAddRoutes = function (root) {
return function (routes) {
if (root.$router) {
root.$router.addRoutes(routes);
}
else {
warning(process.env.NODE_ENV === 'production', 'vm.$router is not exists!');
}
};
};
ModuleLoader.install = install;
ModuleLoader.version = version;
ModuleLoader.installed = false;
return ModuleLoader;
}());
export default ModuleLoader;
//# sourceMappingURL=framework.js.map