import?Vue?from?'vue';
import?VueRouter?from?'vue-router';
import?filters?from?'./filters';
import?routerMap?from?'./routers';
import?FastClick?from?'fastclick';
Vue.use(VueRouter);
$.ajaxSettings.crossDomain?=?true;
//實例化Vue的filter
Object.keys(filters).forEach(k?=>?Vue.filter(k,?filters[k]));
//實例化VueRouterlet?router?=?new?VueRouter({
????hashbang:?true,
????history:?false,
????saveScrollPosition:?true,
????transitionOnLoad:?true});
//登錄中間驗證,頁面需要登錄而沒有登錄的情況直接跳轉登錄router.beforeEach((transition)?=>?{
????//處理左側滾動不影響右邊
????$("html,?body,?#page").removeClass("scroll-hide");
????FastClick.attach(document.body);
????if?(transition.to.auth)?{
????????if?(localStorage.userId)?{
????????????transition.next();
????????}?else?{
????????????var?redirect?=?encodeURIComponent(transition.to.path);
????????????transition.redirect('/login?redirect='?+?redirect);
????????}
????}?else?{
????????transition.next();
????}});
let?app?=?Vue.extend({});routerMap(router);router.start(app,?"#app");