mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
allow user to config custom menu
This commit is contained in:
@@ -113,6 +113,16 @@ module.exports = {
|
||||
});
|
||||
|
||||
cb();
|
||||
},
|
||||
|
||||
_getCustomMenu : function(){
|
||||
return [
|
||||
// {
|
||||
// name:"test",
|
||||
// icon:"uk-icon-lemon-o",
|
||||
// url :"http://anyproxy.io"
|
||||
// }
|
||||
];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user