From 81d0cce53d8626bd10deed5eb25b519d595cc6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E4=B8=BD=E5=90=9B?= <664953382@qq.com> Date: Fri, 5 Nov 2021 11:50:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BF=E7=AD=96=E8=AF=A6=E6=83=85=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E7=9A=84=E5=A4=84=E7=90=86=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E4=B8=BA?= =?UTF-8?q?int?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/editor.js | 61 +++++++++++++++++++++++------- src/views/policy/library/add.vue | 2 +- src/views/policy/library/index.vue | 9 +++-- 3 files changed, 55 insertions(+), 17 deletions(-) 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 @@