2019-07-05 03:19:24 +08:00
|
|
|
export class AbstractScreen {
|
2016-09-10 06:38:16 +08:00
|
|
|
oCross = null;
|
|
|
|
sScreenName;
|
|
|
|
aViewModels;
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
constructor(screenName, viewModels = []) {
|
2016-07-07 07:11:13 +08:00
|
|
|
this.sScreenName = screenName;
|
2020-07-30 03:49:41 +08:00
|
|
|
this.aViewModels = Array.isArray(viewModels) ? viewModels : [];
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {Array}
|
|
|
|
*/
|
|
|
|
viewModels() {
|
|
|
|
return this.aViewModels;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
screenName() {
|
|
|
|
return this.sScreenName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {?Array)}
|
|
|
|
*/
|
|
|
|
routes() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {?Object}
|
|
|
|
*/
|
|
|
|
__cross() {
|
|
|
|
return this.oCross;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
__start() {
|
|
|
|
const routes = this.routes();
|
2020-09-04 23:07:35 +08:00
|
|
|
if (Array.isNotEmpty(routes)) {
|
2020-09-23 20:44:46 +08:00
|
|
|
let route = new Crossroads(),
|
|
|
|
fMatcher = (this.onRoute || (()=>{})).bind(this);
|
|
|
|
|
|
|
|
routes.forEach(item => item && route && (route.addRoute(item[0], fMatcher).rules = item[1]));
|
2016-07-07 07:11:13 +08:00
|
|
|
|
|
|
|
this.oCross = route;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|