From a0985488361eeace67087ed2a58a1084e01d7a61 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:33:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=94=BF=E7=AD=96=E5=85=B1?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E6=B3=95=E7=9A=84=E5=9B=BE=E7=89=87=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/editor.js | 49 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/src/utils/editor.js b/src/utils/editor.js index 88cd525..1d2d893 100644 --- a/src/utils/editor.js +++ b/src/utils/editor.js @@ -1,5 +1,30 @@ import { handlePic } from '@/api/home/notice'; -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;