$express ue-test -ejs $cd ue-test && npm install
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" charset="utf-8" src="../ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../ueditor/ueditor.all.min.js"> </script>
<!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="../ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
<script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
</body>
<script type="text/javascript">
//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');
</script>
</html>
//找到这一行代码 修改成这样,这里的url为请求的路径
// 服务器统一请求接口路径
,serverUrl: URL + "ue"
$npm install ueditor --save
//加载ueditor 模块
var ueditor = require("ueditor");
//使用模块
app.use("/ueditor/ue", 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 = '/images/ueditor/';
res.ue_up(img_url); //你只要输入要保存的地址 。保存操作交给ueditor来做
res.setHeader('Content-Type', 'text/html');//IE8下载需要设置返回头尾text/html 不然json返回文件会被直接下载打开
}
// 客户端发起图片列表请求
else if (req.query.action === 'listimage') {
var dir_url = '/images/ueditor/';
res.ue_list(dir_url); // 客户端会列出 dir_url 目录下的所有图片
}
// 客户端发起其它请求
else {
// console.log('config.json')
res.setHeader('Content-Type', 'application/json');
res.redirect('/ueditor/jsp/config.json');
}
}));
//启用自动保存 ,enableAutoSave: true //自动保存间隔时间, 单位ms ,saveInterval: 500
//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');
//注意一定要延时。要等这玩意载入成功。
setTimeout(function () {
ue.execCommand('drafts');
}, 500);
//启用自动保存 ,enableAutoSave: true //自动保存间隔时间, 单位ms ,saveInterval: 500 * 60 *60
//实例化编辑器
var ue = UE.getEditor('editor');
$(function() {
//初始化数据,读localstroage
var allData = {};
if (localStorage.getItem('ueditor_content')!=null && localStorage.getItem('ueditor_content')!="") {
allData = JSON.parse(localStorage.getItem('ueditor_content'));
}
//延时加载数据 要等编辑器加载成功,反正我不延时的时候没有成功。
setTimeout(function () {
ue.setContent (allData)
}, 500);
//离开页面或者刷新页面触发方法
window.onbeforeunload = function() {
localStorage.setItem("ueditor_content", JSON.stringify(ue.getContent()));
}
})
img {
max-width: 100%; /*图片自适应宽度*/
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2026 源码网商城 (www.ymwmall.com) 版权所有