yoqw/web/cms/app/routes/application.js
2020-07-01 15:22:07 +08:00

47 lines
1.5 KiB
JavaScript

import { inject as service } from '@ember/service';
import { getOwner } from '@ember/application';
import Route from '@ember/routing/route';
import { assign } from '@ember/polyfills';
import $ from 'jquery';
export default Route.extend({
authService: service('auth-service'),
routerService: service('router'),
getLoginRoute() {
return getOwner(this).lookup('route:login');
},
transitionIntercept(transition) {
let me = this;
me.get('authService').auth(transition);
},
beforeModel: function(transition) {
console.log('Before Application Model.', transition);
this.transitionIntercept(transition);
},
activate() {
console.log('Application Activate.');
$('body').addClass('no-skin');
try{ace.settings.check('navbar', 'fixed');}catch(e){console.log(e)}
try{ace.settings.check('main-container', 'fixed');}catch(e){console.log(e)}
},
actions: {
willTransition(transition) {
console.log('Application Will Transition.', transition);
this.transitionIntercept(transition);
},
goback() {
history.back();
},
reload() {
this.refresh();
}
},
allParams(transition) {
let params = {};
Object.keys(transition.params).forEach((k) => {
assign(params, transition.params[k]);
});
return Object.keys(params).length ? params : undefined;
}
});