mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
optimze map icon
This commit is contained in:
@@ -15,7 +15,6 @@ function Recorder(option){
|
||||
|
||||
option = option || {};
|
||||
if(option.filename && typeof option.filename == "string"){
|
||||
|
||||
try{
|
||||
if(fs.existsSync(option.filename)){
|
||||
fs.writeFileSync(option.filename,""); //empty original file
|
||||
@@ -39,9 +38,20 @@ function Recorder(option){
|
||||
db = new Datastore();
|
||||
}
|
||||
|
||||
|
||||
self.recordBodyMap = []; // id - body
|
||||
|
||||
self.emitUpdate = function(id,info){
|
||||
if(info){
|
||||
self.emit("update",info);
|
||||
}else{
|
||||
self.getSingleRecord(id,function(err,doc){
|
||||
if(!err && !!doc && !!doc[0]){
|
||||
self.emit("update",doc[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
self.updateRecord = function(id,info){
|
||||
if(id < 0 ) return;
|
||||
|
||||
@@ -50,10 +60,18 @@ function Recorder(option){
|
||||
db.update({_id:id},finalInfo);
|
||||
self.updateRecordBody(id,info);
|
||||
|
||||
self.emit("update",finalInfo);
|
||||
self.emitUpdate(id,finalInfo);
|
||||
};
|
||||
|
||||
|
||||
self.updateExtInfo = function(id,extInfo){
|
||||
db.update({_id:id},{ $set: { ext: extInfo } },{},function(err,nums){
|
||||
if(!err){
|
||||
self.emitUpdate(id);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
self.appendRecord = function(info){
|
||||
if(info.req.headers.anyproxy_web_req){ //request from web interface
|
||||
return -1;
|
||||
@@ -64,10 +82,9 @@ function Recorder(option){
|
||||
db.insert(finalInfo);
|
||||
self.updateRecordBody(id,info);
|
||||
|
||||
self.emit("update",finalInfo);
|
||||
self.emitUpdate(id,finalInfo);
|
||||
return thisId;
|
||||
};
|
||||
|
||||
|
||||
//update recordBody if exits
|
||||
self.updateRecordBody =function(id,info){
|
||||
@@ -91,9 +108,7 @@ function Recorder(option){
|
||||
return self.recordBodyMap[id] || "";
|
||||
};
|
||||
|
||||
|
||||
self.getBodyUTF8 = function(id,cb){
|
||||
|
||||
var bodyContent = self.getBody(id),
|
||||
result = "";
|
||||
|
||||
@@ -123,17 +138,16 @@ function Recorder(option){
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
self.getSingleRecord = function(id,cb){
|
||||
db.find({_id:parseInt(id)},cb);
|
||||
}
|
||||
};
|
||||
|
||||
self.getSummaryList = function(cb){
|
||||
db.find({},cb);
|
||||
};
|
||||
|
||||
|
||||
self.db = db;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user