修改后
This commit is contained in:
@ -1,29 +1,37 @@
|
|||||||
import { handlePic } from '@/api/home/notice';
|
import { handlePic } from '@/api/home/notice';
|
||||||
export function formatRichText(url, id) {
|
export function formatRichText(url, id) {
|
||||||
// let src = document.querySelectorAll('#text .ql-editor img');
|
// let src = document.querySelectorAll('#text .ql-editor img');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不需要判断域名存不存在
|
||||||
|
*/
|
||||||
|
|
||||||
|
let status = true;
|
||||||
let src = document.querySelectorAll('#text img');
|
let src = document.querySelectorAll('#text img');
|
||||||
let endUrl = [];
|
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);
|
endUrl.push(string);
|
||||||
// 包括
|
|
||||||
const flag = string.includes('http://');
|
const flag = string.includes('http://');
|
||||||
// 不包括
|
// 域名存在
|
||||||
if (!flag) src[i].setAttribute('src', url + string);
|
if (status) {
|
||||||
}
|
if (i == src.length - 1) {
|
||||||
if (url == 'http://drc.hefei.gov.cn') {
|
const data = {
|
||||||
const data = {
|
startUrl: url,
|
||||||
startUrl: url,
|
policyId: id,
|
||||||
policyId: id,
|
endUrl
|
||||||
endUrl
|
};
|
||||||
};
|
handlePic(data).then(({ data: res }) => {
|
||||||
handlePic(data).then(({ data: res }) => {
|
console.log(res);
|
||||||
res.map(item => {
|
for (let i = 0; i < src.length; i++) {
|
||||||
for (let i = 0; i < src.length; i++) {
|
src[i].setAttribute('src', res[i].name);
|
||||||
src[i].setAttribute('src', item.name);
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
});
|
} else {
|
||||||
|
// 域名不存在并且不包含http
|
||||||
|
if (!flag) src[i].setAttribute('src', url + string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 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');
|
||||||
|
Reference in New Issue
Block a user