loki před 3 roky
rodič
revize
c3c57cfd9e

+ 1 - 0
README.md

@@ -108,6 +108,7 @@ Copyright (c) 2017-present PanJiaChen
 - 省市区组件 [x]
 - 积分配置 [x]
 - img 裁切显示[x]
+- 富文本增加图片宽度限制[x]
 
 -------- todo -----------
 

+ 5 - 0
src/main.js

@@ -82,6 +82,11 @@ window.UEDITOR_SERVER_URL = `${process.env.VUE_APP_BASE_API}/yxl-back-end/framew
 // window.UEDITOR_CONFIG = `https://ex.by-health.com/baby-institute-back-end/oss/ueditor/ueditor-action`;
 // window.UEDITOR_SERVER_URL = `https://ex.by-health.com/baby-institute-back-end/oss/ueditor/ueditor-action`;
 
+Vue.prototype.$filterRichTxt = str => {
+  if (!str) return '';
+  return str.replace(/<img/g, '<img style="width: 100%;"');
+};
+
 new Vue({
   el: '#app',
   router,

+ 1 - 0
src/views/baseManagement/infoManagement/modal/ItemModal.vue

@@ -137,6 +137,7 @@ export default {
         if (valid) {
           let params = Object.assign({}, this.form);
           params.cover = this.form.cover[0].url;
+          params.content = this.$filterRichTxt(params.content);
           if (this.id) params.id = this.id;
           const { success, msg } = await saveItem(params);
           if (success) {

+ 1 - 0
src/views/helpInfo/information/modal/ItemModal.vue

@@ -116,6 +116,7 @@ export default {
         if (valid) {
           const params = Object.assign({}, this.form);
           if (this.id) params.id = this.id;
+          params.content = this.$filterRichTxt(params.content);
           const { success, msg } = await saveItem(params);
           if (success) {
             this.$success('保存成功!');