Browse Source

Pull request #2112: KERNEL-8279 refactor:vue-router加上默认跳转 & 把dist下的router.js暴露出来

Merge in VISUAL/fineui from ~GUYI/fineui:master to master

* commit 'c04c937ea8b4b79e10b467afac09ed30e5355ce0':
  KERNEL-8279 refactor:RouterWidget改成BI.RouterWidget
  Revert "无jira任务,fineuiWithoutJqueryAndPolyfillJs中加上h.js"
  KERNEL-8279 refactor:vue-router加上默认跳转 & 把dist下的router.js暴露出来
  无jira任务,fineuiWithoutJqueryAndPolyfillJs中加上h.js
es6
Guyi 3 years ago
parent
commit
c88026141a
  1. 1
      .npmignore
  2. 17
      dist/router.js

1
.npmignore

@ -36,6 +36,7 @@
!dist/font/**/* !dist/font/**/*
!dist/images/* !dist/images/*
!dist/images/**/* !dist/images/**/*
!dist/router.js
!babel.config.js !babel.config.js
!babel.config.ie8.js !babel.config.ie8.js
!.eslintrc !.eslintrc

17
dist/router.js vendored

@ -3123,20 +3123,29 @@
var $router, cbs = []; var $router, cbs = [];
var RouterWidget = BI.inherit(BI.Widget, { BI.RouterWidget = BI.inherit(BI.Widget, {
init: function () { init: function () {
this.$router = this._router = BI.Router.$router = $router = new VueRouter({ this.$router = this._router = BI.Router.$router = $router = new VueRouter({
routes: this.options.routes routes: this.options.routes
}); });
this.$router.beforeEach(function (to, from, next) {
if (to.matched.length === 0) {
//如果上级也未匹配到路由则跳转主页面,如果上级能匹配到则转上级路由
from.path ? next({ path: from.path }) : next('/');
} else {
//如果匹配到正确跳转
next();
}
});
this.$router.afterEach(function () { this.$router.afterEach(function () {
cbs.forEach(function (cb) {cb();}); cbs.forEach(function (cb) {cb();});
}); });
this.$router.init(this); this.$router.init(this);
} }
}); });
BI.shortcut("bi.router", RouterWidget); BI.shortcut("bi.router", BI.RouterWidget);
var RouterView = BI.inherit(BI.Widget, { BI.RouterView = BI.inherit(BI.Widget, {
props: { props: {
deps: 0 deps: 0
}, },
@ -3167,7 +3176,7 @@
BI.remove(cbs, this._callbackListener); BI.remove(cbs, this._callbackListener);
} }
}); });
BI.shortcut("bi.router_view", RouterView); BI.shortcut("bi.router_view", BI.RouterView);
BI.Router = BI.Router || VueRouter; BI.Router = BI.Router || VueRouter;
BI.Router.isSameRoute = isSameRoute; BI.Router.isSameRoute = isSameRoute;

Loading…
Cancel
Save