1.req.session时一直是undefined

解决方法:

// sesssion应用的配置

app.use(session({

secret:'blog',

cookie: ('name', 'value', { path: '/', httpOnly: true,secure: false, maxAge: 60000 }),

resave:true,

saveUninitialized:true

}));

 

应该要放在路由配置之前

2.博客中的内容去除html标签

<%= html%> 不转译

<%- html%> 转译

<%= html.replace(/<[^>]+>/g,"")%> 不转译但是出去html标签

3.百度富文本编辑器上传图片

在没有配置的时候

 

大致就是在ueditor.config.js里面注意一个

 

其次就是在app.js里面重点

 

//ueditor

app.use("/libs/ueditor/getImg", ueditor(path.join(__dirname, 'public'), function (req, res, next) {

 

// ueditor 客户发起上传图片请求

if (req.query.action === 'uploadimage') {

var foo = req.ueditor;

 

var imgname = req.ueditor.filename;

 

var img_url = '/upload';

res.ue_up(img_url); //你只要输入要保存的地址 。保存操作交给ueditor来做

}

 

// 客户端发起图片列表请求

else if (req.query.action === 'listimage') {

var dir_url = '/upload';

res.ue_list(dir_url); // 客户端会列出 dir_url 目录下的所有图片

}

 

// 客户端发起其它请求

else {

 

res.setHeader('Content-Type', 'application/json');

res.redirect('/libs/ueditor/nodejs/config.json')

}

 

}));

 

ok!完成!

 posted on 2018-02-23 14:37  董董董啊  阅读(111)  评论(0编辑  收藏  举报