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}
|
|
|
|
*/
|
2021-01-22 19:23:20 +08:00
|
|
|
get viewModels() {
|
2016-07-07 07:11:13 +08:00
|
|
|
return this.aViewModels;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
screenName() {
|
|
|
|
return this.sScreenName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {?Array)}
|
|
|
|
*/
|
|
|
|
routes() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {?Object}
|
|
|
|
*/
|
2020-10-02 18:40:33 +08:00
|
|
|
get __cross() {
|
2016-07-07 07:11:13 +08:00
|
|
|
return this.oCross;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-01-27 07:26:31 +08:00
|
|
|
onStart() {
|
|
|
|
if (!this.__started) {
|
|
|
|
this.__started = true;
|
|
|
|
const routes = this.routes();
|
|
|
|
if (Array.isNotEmpty(routes)) {
|
|
|
|
let route = new Crossroads(),
|
|
|
|
fMatcher = (this.onRoute || (()=>{})).bind(this);
|
|
|
|
|
|
|
|
routes.forEach(item => item && route && (route.addRoute(item[0], fMatcher).rules = item[1]));
|
|
|
|
|
|
|
|
this.oCross = route;
|
|
|
|
}
|
2016-07-07 07:11:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|