diff --git a/src/utils/editor.js b/src/utils/editor.js index 387fc23..851eb72 100644 --- a/src/utils/editor.js +++ b/src/utils/editor.js @@ -1,5 +1,30 @@ import { handlePic } from '@/api/policy/library'; -export function formatRichText(url, id) { +export let urlList =[ + 'http://ahchjkq.hefei.gov.cn/', + 'http://bhkxc.hefei.gov.cn/', + 'http://cxjsj.hefei.gov.cn/index.html', + 'http://drc.hefei.gov.cn/', + 'http://gxq.hefei.gov.cn/', + 'http://hetda.hefei.gov.cn/', + 'http://hfxz.hefei.gov.cn/index.html', + 'http://jxj.hefei.gov.cn/index.html', + 'http://kjj.hefei.gov.cn/', + 'http://rsj.hefei.gov.cn/', + 'http://swj.hefei.gov.cn/', + 'http://sjzyj.hefei.gov.cn/', + 'http://www.ahfeixi.gov.cn/', + 'http://www.ahhfly.gov.cn/index.html', + 'http://www.baohe.gov.cn/index.html', + 'http://www.changfeng.gov.cn/', + 'http://www.chaohu.gov.cn/', + 'http://www.feidong.gov.cn/index.html', + 'http://www.hefei.gov.cn/', + 'http://wlj.hefei.gov.cn/index.html', + 'http://www.hfyaohai.gov.cn/', + 'http://www.hfss.gov.cn/index.html', + 'http://www.lj.gov.cn/', +] +export function formatRichText(dowUrl, id, url) { // let src = document.querySelectorAll('#text .ql-editor img'); /** @@ -15,23 +40,33 @@ export function formatRichText(url, id) { } if (endUrl.length) { const data = { - startUrl: url, + startUrl: dowUrl, policyId: id, endUrl }; - handlePic(data).then(({ data: res }) => { - console.log(res); - for (let i = 0; i < src.length; i++) { - src[i].setAttribute('src', res[i].name); + let flag = true; + urlList.map(item=>{ + if(url.includes(item)){ + flag = false; + handlePic(data).then(({ data: res }) => { + for (let i = 0; i < src.length; i++) { + src[i].setAttribute('src', res[i].name); + } + }); } - }); + }) + if(flag){ + for (let i = 0; i < src.length; i++) { + src[i].setAttribute('src', dowUrl+endUrl[i]); + } + } } // let src2 = document.querySelectorAll('#text .ql-editor a'); let src2 = document.querySelectorAll('#text a'); for (let i = 0; i < src2.length; i++) { const string = src2[i].getAttribute('href'); const flag = string.includes('http://'); - if (!flag) src2[i].setAttribute('href', url + string); + if (!flag) src2[i].setAttribute('href', dowUrl + string); } // var imgReg = /|\/>)/gi; // var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i; @@ -45,14 +80,14 @@ export function formatRichText(url, id) { // if (src[1]) { // var newContent = html.replace( // /\|\/>)/gi; // var hrefReg = /href=[\'\"]?([^\'\"]*)[\'\"]?/i; @@ -61,7 +96,7 @@ export function formatRichText(url, id) { // let src = arr2[i].match(hrefReg); // //获取图片地址 // if (src[1]) { -// var newContent = html.replace(/\ { - this.formatRichText(this.ruleForm.downloadUrl, this.ruleForm.id); + this.formatRichText(this.ruleForm.downloadUrl, this.ruleForm.id,this.ruleForm.url); }); }, }, diff --git a/src/views/policy/library/index.vue b/src/views/policy/library/index.vue index 3292c9a..d463fe6 100644 --- a/src/views/policy/library/index.vue +++ b/src/views/policy/library/index.vue @@ -198,14 +198,14 @@