修改前

This commit is contained in:
熊丽君
2021-08-16 08:46:36 +08:00
parent cdd37b70a6
commit 6adc027fe1

View File

@ -1,12 +1,30 @@
export function formatRichText(url) { import { handlePic } from '@/api/home/notice';
export function formatRichText(url, id) {
// let src = document.querySelectorAll('#text .ql-editor img'); // let src = document.querySelectorAll('#text .ql-editor img');
let src = document.querySelectorAll('#text img'); let src = document.querySelectorAll('#text img');
console.log(src); let endUrl = [];
for (let i = 0; i < src.length; i++) { for (let i = 0; i < src.length; i++) {
const string = src[i].getAttribute('src'); const string = src[i].getAttribute('src');
endUrl.push(string);
// 包括
const flag = string.includes('http://'); const flag = string.includes('http://');
// 不包括
if (!flag) src[i].setAttribute('src', url + string); if (!flag) src[i].setAttribute('src', url + string);
} }
if (url == 'http://drc.hefei.gov.cn') {
const data = {
startUrl: url,
policyId: id,
endUrl
};
handlePic(data).then(({ data: res }) => {
res.map(item => {
for (let i = 0; i < src.length; i++) {
src[i].setAttribute('src', item.name);
}
});
});
}
// let src2 = document.querySelectorAll('#text .ql-editor a'); // let src2 = document.querySelectorAll('#text .ql-editor a');
let src2 = document.querySelectorAll('#text a'); let src2 = document.querySelectorAll('#text a');
for (let i = 0; i < src2.length; i++) { for (let i = 0; i < src2.length; i++) {