allow user to config custom menu

This commit is contained in:
OttoMao
2015-07-12 21:19:49 +08:00
parent 95531a3558
commit 1558813144
9 changed files with 325 additions and 290 deletions

View File

@@ -113,6 +113,16 @@ module.exports = {
});
cb();
},
_getCustomMenu : function(){
return [
// {
// name:"test",
// icon:"uk-icon-lemon-o",
// url :"http://anyproxy.io"
// }
];
}
};

View File

@@ -8,6 +8,7 @@ var express = require("express"),
util = require("./util"),
certMgr = require("./certMgr"),
logUtil = require("./log"),
juicer = require("juicer"),
compress = require('compression');
@@ -16,10 +17,12 @@ function webInterface(config){
wsPort = config.wsPort,
ipAddress = config.ip,
userRule = config.userRule,
ruleSummary = "";
ruleSummary = "",
customMenu = [];
try{
ruleSummary = userRule.summary();
customMenu = userRule._getCustomMenu();
}catch(e){}
var self = this,
@@ -88,15 +91,16 @@ function webInterface(config){
app.use(function(req,res,next){
var indexTpl = fs.readFileSync(path.join(staticDir,"/index.html"),{encoding:"utf8"}),
indexHTML = util.simpleRender(indexTpl, {
rule : ruleSummary || "",
wsPort : wsPort,
ipAddress : ipAddress || "127.0.0.1"
});
opt = {
rule : ruleSummary || "",
customMenu : customMenu || [],
wsPort : wsPort,
ipAddress : ipAddress || "127.0.0.1"
};
if(req.url == "/"){
res.setHeader("Content-Type", "text/html");
res.end(indexHTML);
res.end(juicer(indexTpl, opt));
}else{
next();
}