diff --git a/lib/Lib/Core/Dispatcher.class.js b/lib/Lib/Core/Dispatcher.class.js index f04b0004..7f8eef16 100644 --- a/lib/Lib/Core/Dispatcher.class.js +++ b/lib/Lib/Core/Dispatcher.class.js @@ -32,35 +32,38 @@ var Dispatcher = module.exports = Class(function(){ pathname = pathname.substr(C('pathname_prefix').length); }; this.http.pathname = pathname; - //是否使用自定义路由 - if (!this.routerCheck()) { - var paths = pathname.split("/"); - //将group list变为小写 - var groupList = (C('app_group_list') || []).map(function(item){ - return item.toLowerCase(); - }); - if (groupList.length) { - if (groupList.indexOf((paths[0] + "").toLowerCase()) > -1) { - group = paths.shift(); - }; - }; - var deny = C('app_group_deny') || []; - if (group && deny.length) { - if (deny.indexOf(group) > -1) { - throw_error(group + " is not allowed", this.http); - }; - }; - controller = paths.shift(); - action = paths.shift(); - if (paths.length) { - for(var i = 0,length = Math.ceil(paths.length)/2; i < length; i++){ - this.http.get[paths[i * 2]] = paths[i * 2 + 1] || ""; - } - }; - this.http.group = Dispatcher.getGroup(group); - this.http.controller = Dispatcher.getController(controller); - this.http.action = Dispatcher.getAction(action); + + //使用自定义路由 + if (this.routerCheck()) { + return true; }; + //使用默认路由 + var paths = pathname.split("/"); + //将group list变为小写 + var groupList = (C('app_group_list') || []).map(function(item){ + return item.toLowerCase(); + }); + if (groupList.length) { + if (groupList.indexOf((paths[0] + "").toLowerCase()) > -1) { + group = paths.shift(); + }; + }; + var deny = C('app_group_deny') || []; + if (group && deny.length) { + if (deny.indexOf(group) > -1) { + throw_error(group + " is not allowed", this.http); + }; + }; + controller = paths.shift(); + action = paths.shift(); + if (paths.length) { + for(var i = 0,length = Math.ceil(paths.length)/2; i < length; i++){ + this.http.get[paths[i * 2]] = paths[i * 2 + 1] || ""; + } + }; + this.http.group = Dispatcher.getGroup(group); + this.http.controller = Dispatcher.getController(controller); + this.http.action = Dispatcher.getAction(action); return true; }, /** diff --git a/lib/Tpl/IndexController.class.js b/lib/Tpl/IndexController.class.js index 7b395689..6843c395 100644 --- a/lib/Tpl/IndexController.class.js +++ b/lib/Tpl/IndexController.class.js @@ -4,12 +4,9 @@ */ module.exports = Controller(function(){ return { - /*init: function(http){ - this.super("init", http); - }*/ indexAction: function(){ - this.end("hello, thinkjs!"); - //this.display(); //render Home/index_index.html file + //render Tpl/Home/index_index.html file + this.display(); } } }); \ No newline at end of file