mirror of
https://github.com/thinkjs/thinkjs.git
synced 2026-01-25 14:42:47 +00:00
update
This commit is contained in:
parent
6aafca5d70
commit
4100d83b3f
@ -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;
|
||||
},
|
||||
/**
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user