2021-08-16 08:46:36 +08:00
|
|
|
import { handlePic } from '@/api/home/notice';
|
2021-11-05 11:33:01 +08:00
|
|
|
export let urlList = [
|
|
|
|
'http://ahchjkq.hefei.gov.cn/',
|
|
|
|
'http://bhkxc.hefei.gov.cn/',
|
2022-04-14 11:40:12 +08:00
|
|
|
'http://cxjsj.hefei.gov.cn/',
|
2021-11-05 11:33:01 +08:00
|
|
|
'http://drc.hefei.gov.cn/',
|
|
|
|
'http://gxq.hefei.gov.cn/',
|
|
|
|
'http://hetda.hefei.gov.cn/',
|
2022-04-14 11:40:12 +08:00
|
|
|
'http://hfxz.hefei.gov.cn/',
|
|
|
|
'http://jxj.hefei.gov.cn/',
|
2021-11-05 11:33:01 +08:00
|
|
|
'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/',
|
2022-04-14 11:40:12 +08:00
|
|
|
'http://www.ahhfly.gov.cn/',
|
|
|
|
'http://www.baohe.gov.cn/',
|
2021-11-05 11:33:01 +08:00
|
|
|
'http://www.changfeng.gov.cn/',
|
|
|
|
'http://www.chaohu.gov.cn/',
|
2022-04-14 11:40:12 +08:00
|
|
|
'http://www.feidong.gov.cn/',
|
2021-11-05 11:33:01 +08:00
|
|
|
'http://www.hefei.gov.cn/',
|
2022-04-14 11:40:12 +08:00
|
|
|
'http://wlj.hefei.gov.cn/',
|
2021-11-05 11:33:01 +08:00
|
|
|
'http://www.hfyaohai.gov.cn/',
|
2022-04-14 11:40:12 +08:00
|
|
|
'http://www.hfss.gov.cn/',
|
2021-11-05 11:33:01 +08:00
|
|
|
'http://www.lj.gov.cn/'
|
|
|
|
];
|
|
|
|
export function formatRichText(dowUrl, id, url) {
|
2021-08-10 17:15:42 +08:00
|
|
|
// let src = document.querySelectorAll('#text .ql-editor img');
|
2021-08-16 08:46:44 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 不需要判断域名存不存在
|
|
|
|
*/
|
|
|
|
|
|
|
|
let status = true;
|
2021-08-10 17:15:42 +08:00
|
|
|
let src = document.querySelectorAll('#text img');
|
2021-08-16 08:46:36 +08:00
|
|
|
let endUrl = [];
|
2021-08-06 16:05:39 +08:00
|
|
|
for (let i = 0; i < src.length; i++) {
|
|
|
|
const string = src[i].getAttribute('src');
|
2021-08-16 08:46:36 +08:00
|
|
|
endUrl.push(string);
|
2021-08-17 08:41:17 +08:00
|
|
|
}
|
|
|
|
if (endUrl.length) {
|
|
|
|
const data = {
|
2021-11-05 11:33:01 +08:00
|
|
|
startUrl: dowUrl,
|
2021-08-17 08:41:17 +08:00
|
|
|
policyId: id,
|
|
|
|
endUrl
|
|
|
|
};
|
2021-11-05 11:33:01 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
2021-08-16 08:46:44 +08:00
|
|
|
}
|
2021-08-17 08:41:17 +08:00
|
|
|
});
|
2021-11-05 11:33:01 +08:00
|
|
|
if (flag) {
|
|
|
|
for (let i = 0; i < src.length; i++) {
|
|
|
|
src[i].setAttribute('src', dowUrl + endUrl[i]);
|
|
|
|
}
|
|
|
|
}
|
2021-08-16 08:46:36 +08:00
|
|
|
}
|
2021-08-10 17:15:42 +08:00
|
|
|
// let src2 = document.querySelectorAll('#text .ql-editor a');
|
|
|
|
let src2 = document.querySelectorAll('#text a');
|
2021-08-06 16:05:39 +08:00
|
|
|
for (let i = 0; i < src2.length; i++) {
|
|
|
|
const string = src2[i].getAttribute('href');
|
|
|
|
const flag = string.includes('http://');
|
2021-11-05 11:33:01 +08:00
|
|
|
if (!flag) src2[i].setAttribute('href', dowUrl + string);
|
2021-08-06 16:05:39 +08:00
|
|
|
}
|
|
|
|
// var imgReg = /<img.*?(?:>|\/>)/gi;
|
|
|
|
// var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
|
|
|
|
// var arr = html.match(imgReg);
|
|
|
|
// // console.log(arr);
|
|
|
|
// for (let i = 0; i < arr.length; i++) {
|
|
|
|
// let src = arr[i].match(srcReg);
|
|
|
|
// //获取图片地址
|
|
|
|
// console.log(html);
|
|
|
|
// console.log(src[1]);
|
|
|
|
// if (src[1]) {
|
|
|
|
// var newContent = html.replace(
|
|
|
|
// /\<img/gi,
|
|
|
|
// `<img src="${url}${src[1]}"`
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return this.aaa(url, newContent);
|
|
|
|
}
|
|
|
|
// function aaa(url, html) {
|
|
|
|
// console.log(url);
|
|
|
|
// console.log(html);
|
|
|
|
// var aReg = /<a.*?(?:>|\/>)/gi;
|
|
|
|
// var hrefReg = /href=[\'\"]?([^\'\"]*)[\'\"]?/i;
|
|
|
|
// var arr2 = html.match(aReg);
|
|
|
|
// for (let i = 0; i < arr2.length; i++) {
|
|
|
|
// let src = arr2[i].match(hrefReg);
|
|
|
|
// //获取图片地址
|
|
|
|
// if (src[1]) {
|
|
|
|
// var newContent = html.replace(/\<a/gi, `<a href="${url}${src[1]}"`);
|
|
|
|
// }
|
|
|
|
// // 替换src
|
|
|
|
// // if (src[0]) {
|
|
|
|
// // var t = src[0].replace(/src/i, 'href');
|
|
|
|
// // console.log(t);
|
|
|
|
// // }
|
|
|
|
// }
|
|
|
|
// return newContent;
|
|
|
|
// }
|