mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-17 16:35:53 +08:00
优化部分样式问题,新增部分功能,解决发现的bug,暂未完全测试通过。
This commit is contained in:
@@ -15,20 +15,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Modal
|
||||
title="编辑html代码"
|
||||
v-model="showHTMLModal"
|
||||
:mask-closable="false"
|
||||
:width="900"
|
||||
:fullscreen="full"
|
||||
>
|
||||
<Input
|
||||
v-if="!full"
|
||||
v-model="dataEdit"
|
||||
:rows="15"
|
||||
type="textarea"
|
||||
style="max-height:60vh;overflow:auto;"
|
||||
/>
|
||||
<Modal title="编辑html代码" v-model="showHTMLModal" :mask-closable="false" :width="900" :fullscreen="full">
|
||||
<Input v-if="!full" v-model="dataEdit" :rows="15" type="textarea" style="max-height:60vh;overflow:auto;" />
|
||||
<Input v-if="full" v-model="dataEdit" :rows="32" type="textarea" />
|
||||
<div slot="footer">
|
||||
<Button @click="full=!full" icon="md-expand">全屏开/关</Button>
|
||||
@@ -56,21 +44,21 @@ export default {
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
default: "editor"
|
||||
default: "editor",
|
||||
},
|
||||
value: String,
|
||||
base64: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
showExpand: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
default: true,
|
||||
},
|
||||
openXss: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -79,16 +67,17 @@ export default {
|
||||
dataEdit: "", // 编辑数据
|
||||
showHTMLModal: false, // 显示html
|
||||
full: false, // html全屏开关
|
||||
fullscreenModal: false // 显示全屏预览
|
||||
fullscreenModal: false, // 显示全屏预览
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
||||
initEditor() {
|
||||
let that = this;
|
||||
// 详见wangeditor3官网文档 https://www.kancloud.cn/wangfupeng/wangeditor3/332599
|
||||
editor = new E(`#${this.id}`);
|
||||
// 编辑内容绑定数据
|
||||
editor.config.onchange = html => {
|
||||
editor.config.onchange = (html) => {
|
||||
if (this.openXss) {
|
||||
this.data = xss(html);
|
||||
} else {
|
||||
@@ -108,30 +97,30 @@ export default {
|
||||
editor.config.uploadImgServer = uploadFile;
|
||||
// lili如要header中传入token鉴权
|
||||
editor.config.uploadImgHeaders = {
|
||||
accessToken: that.getStore("accessToken")
|
||||
accessToken: that.getStore("accessToken"),
|
||||
};
|
||||
editor.config.uploadFileName = "file";
|
||||
editor.config.uploadImgHooks = {
|
||||
before: function(xhr, editor, files) {
|
||||
before: function (xhr, editor, files) {
|
||||
// 图片上传之前触发
|
||||
},
|
||||
success: function(xhr, editor, result) {
|
||||
success: function (xhr, editor, result) {
|
||||
// 图片上传并返回结果,图片插入成功之后触发
|
||||
},
|
||||
fail: function(xhr, editor, result) {
|
||||
fail: function (xhr, editor, result) {
|
||||
// 图片上传并返回结果,但图片插入错误时触发
|
||||
that.$Message.error("上传图片失败");
|
||||
},
|
||||
error: function(xhr, editor) {
|
||||
error: function (xhr, editor) {
|
||||
// 图片上传出错时触发
|
||||
that.$Message.error("上传图片出错");
|
||||
},
|
||||
timeout: function(xhr, editor) {
|
||||
timeout: function (xhr, editor) {
|
||||
// 图片上传超时时触发
|
||||
that.$Message.error("上传图片超时");
|
||||
},
|
||||
// 如果服务器端返回的不是 {errno:0, data: [...]} 这种格式,可使用该配置
|
||||
customInsert: function(insertImg, result, editor) {
|
||||
customInsert: function (insertImg, result, editor) {
|
||||
if (result.success == true) {
|
||||
let url = result.result;
|
||||
insertImg(url);
|
||||
@@ -139,10 +128,11 @@ export default {
|
||||
} else {
|
||||
that.$Message.error(result.message);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
editor.config.customAlert = function(info) {
|
||||
|
||||
editor.config.customAlert = function (info) {
|
||||
// info 是需要提示的内容
|
||||
// that.$Message.info(info);
|
||||
};
|
||||
@@ -156,8 +146,8 @@ export default {
|
||||
// type -> 'emoji' / 'image'
|
||||
type: "image",
|
||||
// content -> 数组
|
||||
content: sina
|
||||
}
|
||||
content: sina,
|
||||
},
|
||||
];
|
||||
editor.create();
|
||||
if (this.value) {
|
||||
@@ -187,7 +177,7 @@ export default {
|
||||
editor.txt.html(this.data);
|
||||
this.$emit("input", this.data);
|
||||
this.$emit("on-change", this.data);
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
setData(value) {
|
||||
@@ -200,22 +190,21 @@ export default {
|
||||
this.$emit("input", this.data);
|
||||
this.$emit("on-change", this.data);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
this.setData(val);
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.initEditor();
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.e-menu {
|
||||
|
||||
z-index: 101;
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
|
||||
Reference in New Issue
Block a user