Browse Source

Pull request #1994: 无JIRA任务 集成VueRouter

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

* commit 'f5f9ae06822dbdb122c4a6ccd59bdae2761f785b':
  update
  update
  add
  add
es6
guy 3 years ago
parent
commit
9ba5e82edf
  1. 49
      demo/app.js
  2. 18
      demo/js/center.js
  3. 6
      demo/js/main.js
  4. 13
      demo/js/main.store.js
  5. 2
      demo/js/north.js
  6. 3169
      src/router/router2.js

49
demo/app.js

@ -9,34 +9,47 @@ BI.$(function () {
}); });
var tree = BI.Tree.transformToTreeFormat(Demo.CONFIG); var tree = BI.Tree.transformToTreeFormat(Demo.CONFIG);
var obj = { var routes = [{
routes: { path: '/',
"": "index" component: function(){
}, return Promise.resolve({
index: function () { type: "demo.face"
Demo.showIndex = "demo.face"; })
} }
}; }];
BI.Tree.traversal(tree, function (index, node) { BI.Tree.traversal(tree, function (index, node) {
if (!node.children || BI.isEmptyArray(node.children)) { if (!node.children || BI.isEmptyArray(node.children)) {
obj.routes[node.text] = node.text; routes.push({
obj[node.text] = function () { path: '/' + node.text,
Demo.showIndex = node.value; component: function(){
}; return Promise.resolve({
type: node.value
})
}
});
} }
}); });
var AppRouter = BI.inherit(BI.Router, obj); // var AppRouter = BI.inherit(BI.Router, obj);
new AppRouter; // new AppRouter;
BI.history.start(); // BI.history.start();
BI.createWidget({ BI.createWidget({
type: "demo.main", type: "bi.router",
ref: function (_ref) { ref: function (_ref) {
console.log(_ref); BI.router = _ref._router;
ref = _ref;
}, },
element: "#wrapper" element: "#wrapper",
routes: routes,
render: function () {
return {
type: "demo.main",
ref: function (_ref) {
console.log(_ref);
ref = _ref;
}
}
}
}); });
}); });

18
demo/js/center.js

@ -5,22 +5,8 @@ Demo.Center = BI.inherit(BI.Widget, {
render: function () { render: function () {
var self = this; var self = this;
return { return {
type: "bi.tab", type: "bi.router_view"
ref: function () { }
self.tab = this;
},
single: true,
showIndex: Demo.showIndex,
cardCreator: function (v) {
return BI.createWidget({
type: v
});
}
};
},
setValue: function (v) {
this.tab.setSelect(v);
} }
}); });
BI.shortcut("demo.center", Demo.Center); BI.shortcut("demo.center", Demo.Center);

6
demo/js/main.js

@ -7,12 +7,6 @@ Demo.Main = BI.inherit(BI.Widget, {
return BI.Stores.getStore("demo.store.main"); return BI.Stores.getStore("demo.store.main");
}, },
watch: {
activeCard: function (v) {
this.center.setValue(v);
}
},
beforeInit: function (cb) { beforeInit: function (cb) {
this.store.init(cb); this.store.init(cb);
}, },

13
demo/js/main.store.js

@ -4,12 +4,6 @@
}, },
state: function () {
return {
activeCard: Demo.showIndex
};
},
computed: {}, computed: {},
watch: {}, watch: {},
@ -48,15 +42,16 @@
}, },
handleTreeSelectChange: function (v) { handleTreeSelectChange: function (v) {
this.model.activeCard = v;
var matched = BI.some(Demo.CONFIG, function (index, item) { var matched = BI.some(Demo.CONFIG, function (index, item) {
if (item.value === v) { if (item.value === v) {
BI.history.navigate(item.text, {trigger: true}); BI.router.push(item.text);
// BI.history.navigate(item.text, {trigger: true});
return true; return true;
} }
}); });
if (!matched) { if (!matched) {
BI.history.navigate("", {trigger: true}); BI.router.push("/");
// BI.history.navigate("", {trigger: true});
} }
} }
} }

2
demo/js/north.js

@ -13,7 +13,7 @@ Demo.North = BI.inherit(BI.Widget, {
listeners: [{ listeners: [{
eventName: BI.Button.EVENT_CHANGE, eventName: BI.Button.EVENT_CHANGE,
action: function () { action: function () {
self.fireEvent(Demo.North.EVENT_VALUE_CHANGE, "demo.face"); self.fireEvent(Demo.North.EVENT_VALUE_CHANGE, "");
} }
}], }],
cls: "logo", cls: "logo",

3169
src/router/router2.js

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save