修改政策共用方法的图片处理文件

This commit is contained in:
熊丽君
2021-11-05 11:33:01 +08:00
parent 2cd114d334
commit a098548836

View File

@ -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 = /<img.*?(?:>|\/>)/gi;
// var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;