Comparing version 1.3.7 to 1.3.8
@@ -157,2 +157,3 @@ /** | ||
App.prototype.loadPage = function (page) { | ||
var _this = this; | ||
@@ -175,6 +176,31 @@ if (typeof page === 'function') { | ||
return env.isServer ? this.resolveServerModule(page) : this.resolveClientModule(page); | ||
var loadMethodName = env.isServer ? 'resolveServerModule' : 'resolveClientModule'; | ||
return this[loadMethodName](page).then(function (Page) { | ||
return _this.resolvePage(Page); | ||
}); | ||
}; | ||
/** | ||
* 解析 Page 类 | ||
* | ||
* @protected | ||
* | ||
* @param {Object|Function} Page 页面模块 | ||
* | ||
* @return {Promise} | ||
*/ | ||
App.prototype.resolvePage = function (Page) { | ||
// @hack | ||
// 这种是 commonjs/amd 直接返回的 Page | ||
if (typeof Page === 'function') { | ||
return Page; | ||
} | ||
// 这种是 export default 输出的 | ||
return Page['default']; | ||
}; | ||
/** | ||
* 服务器端加载Page模块 | ||
@@ -181,0 +207,0 @@ * |
{ | ||
"name": "ei", | ||
"version": "1.3.7", | ||
"version": "1.3.8", | ||
"main": "lib/main.js", | ||
@@ -13,3 +13,4 @@ "scripts": { | ||
"build": "npm test && npm run build:amd && npm run build:commonjs", | ||
"precommit": "npm run lint && npm test" | ||
"precommit": "npm run lint && npm test", | ||
"prepublish": "npm run build" | ||
}, | ||
@@ -16,0 +17,0 @@ "author": { |
130288
2481