| | |
| | | fileList: [], |
| | | // 工具栏配置 |
| | | toolbarConfig: { |
| | | excludeKeys: [ |
| | | "group-video", |
| | | "insertVideo", |
| | | "uploadVideo", |
| | | "emotion", |
| | | "codeBlock", |
| | | ], |
| | | excludeKeys: ["emotion", "codeBlock"], |
| | | }, |
| | | |
| | | // 编辑器配置 |
| | | editorConfig: { |
| | | placeholder: "请输入宣教内容...", |
| | | placeholder: "请输入内容...", |
| | | MENU_CONF: { |
| | | // 图片上传配置 |
| | | uploadImage: { |
| | | server: process.env.VUE_APP_BASE_API + "/common/uploadSort", |
| | | fieldName: "file", |
| | | maxFileSize: 2 * 1024 * 1024, |
| | | maxNumberOfFiles: 1, |
| | | allowedFileTypes: ["image/*"], |
| | | headers: { |
| | | Authorization: "Bearer " + getToken(), |
| | | }, |
| | | customUpload: async (file, insertFn) => { |
| | | try { |
| | | const formData = new FormData(); |
| | | formData.append("file", file); |
| | | |
| | | const response = await axios.post( |
| | | process.env.VUE_APP_BASE_API + "/common/uploadSort", |
| | | formData, |
| | | { |
| | | headers: { |
| | | // "Content-Type": "multipart/form-data", |
| | | Authorization: "Bearer " + getToken(), |
| | | // 自定义插入图片 |
| | | customInsert: (res, insertFn) => { |
| | | const url = res.url || res.data || res.filePath; |
| | | if (url) { |
| | | // 处理内网地址转换 |
| | | const processedUrl = url.replace( |
| | | "http://192.168.191.181:8095/profile/upload", |
| | | "http://m.zjtongde.com:13871/prod-api/profile/upload" |
| | | ); |
| | | insertFn(processedUrl); |
| | | } |
| | | }, |
| | | } |
| | | ); |
| | | |
| | | if (response.data && response.data.url) { |
| | | let imgUrl = response.data.url; |
| | | // imgUrl = imgUrl.replace( |
| | | // "http://218.108.11.22:8093/profile-api/upload", |
| | | // "http://192.88.117.236:8090/prod-api/profile/upload" |
| | | // ); |
| | | imgUrl = imgUrl.replace( |
| | | "http://m.zjtongde.com:13871/prod-api/profile/upload", |
| | | "http://192.88.117.236:8090/prod-api/profile/upload" |
| | | ); |
| | | insertFn(imgUrl); |
| | | } |
| | | } catch (error) { |
| | | console.error("图片上传失败", error); |
| | | // 上传成功回调 |
| | | onSuccess: (file, res) => { |
| | | console.log("图片上传成功", res); |
| | | return res.url || res.data || res.filePath; |
| | | }, |
| | | onFailed: (file, res) => { |
| | | this.$message.error("图片上传失败"); |
| | | console.error("图片上传失败", res); |
| | | }, |
| | | }, |
| | | |
| | | // 视频上传配置 |
| | | uploadVideo: { |
| | | server: process.env.VUE_APP_BASE_API + "/common/uploadSort", |
| | | fieldName: "file", |
| | | maxFileSize: 50 * 1024 * 1024, // 50MB |
| | | allowedFileTypes: ["video/*"], |
| | | headers: { |
| | | Authorization: "Bearer " + getToken(), |
| | | }, |
| | | // 自定义插入视频 |
| | | customInsert: (res, insertFn) => { |
| | | const url = res.url || res.data || res.filePath; |
| | | if (url) { |
| | | // 处理内网地址转换 |
| | | const processedUrl = url.replace( |
| | | "http://192.168.191.181:8095/profile/upload", |
| | | "http://m.zjtongde.com:13871/prod-api/profile/upload" |
| | | ); |
| | | insertFn(processedUrl, "视频"); |
| | | } |
| | | }, |
| | | onSuccess: (file, res) => { |
| | | console.log("视频上传成功", res); |
| | | return res.url || res.data || res.filePath; |
| | | }, |
| | | onFailed: (file, res) => { |
| | | this.$message.error("视频上传失败"); |
| | | console.error("视频上传失败", res); |
| | | }, |
| | | onError: (file, err, res) => { |
| | | this.$message.error("视频上传出错"); |
| | | console.error("视频上传出错", err); |
| | | }, |
| | | }, |
| | | }, |
| | |
| | | // 获取所有的video元素 |
| | | var videos = doc.querySelectorAll("video"); |
| | | var images = doc.querySelectorAll("img"); |
| | | console.log(videos, "videos"); |
| | | console.log(images, "images"); |
| | | |
| | | // 遍历所有的video元素并替换src属性 |
| | | videos.forEach(function (video) { |
| | | // 先检查video元素自身的src属性 |
| | | var src = video.getAttribute("src"); |
| | | if (src.startsWith(oldUrlBase)) { |
| | | if (src && src.startsWith(oldUrlBase)) { |
| | | video.setAttribute("src", src.replace(oldUrlBase, newUrlBase)); |
| | | } |
| | | |
| | | // 然后检查video元素内部的source子元素 |
| | | var sources = video.querySelectorAll("source"); |
| | | sources.forEach(function (source) { |
| | | var sourceSrc = source.getAttribute("src"); |
| | | if (sourceSrc && sourceSrc.startsWith(oldUrlBase)) { |
| | | source.setAttribute( |
| | | "src", |
| | | sourceSrc.replace(oldUrlBase, newUrlBase) |
| | | ); |
| | | } |
| | | }); |
| | | console.log(images,'images'); |
| | | }); |
| | | console.log(images, "images"); |
| | | |
| | | images.forEach(function (img) { |
| | | var src = img.getAttribute("src"); |
| | |
| | | content: this.parserdom(this.content), |
| | | fileName: this.generateRandomHtmlFilename(), |
| | | }).then((res) => { |
| | | console.log(55); |
| | | |
| | | this.ruleForm.richText = res.msg; |
| | | this.ruleForm.richText = res.msg.replace( |
| | | this.oldPattern, |