存储图片路径为相对路径时显示的bugfix

This commit is contained in:
xiaoqi.cxq 2022-10-29 16:37:26 +08:00
parent 401c2787af
commit dd78ec7b3a

View File

@ -255,7 +255,7 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
return; return;
} }
if (imgElt.src.indexOf(constants.origin) >= 0) { if (imgElt.src.indexOf(constants.origin) >= 0) {
getImgUrl(imgElt.src.replace(constants.origin, '')).then((newUrl) => { getImgUrl(imgElt.attributes.src.nodeValue).then((newUrl) => {
imgElt.src = newUrl; imgElt.src = newUrl;
resolve(); resolve();
}, () => reject(new Error('加载本地空间图片出错'))); }, () => reject(new Error('加载本地空间图片出错')));
@ -555,11 +555,10 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
if (loadImgs.length) { if (loadImgs.length) {
// Wait for images to load // Wait for images to load
const loadWorkspaceImg = loadImgs.map(imgElt => new Promise((resolve, reject) => { const loadWorkspaceImg = loadImgs.map(imgElt => new Promise((resolve, reject) => {
const uri = imgElt.src.replace(origin, ''); getImgUrl(imgElt.attributes.src.nodeValue).then((newUrl) => {
getImgUrl(uri).then((newUrl) => {
imgElt.src = newUrl; imgElt.src = newUrl;
resolve(); resolve();
}, () => reject(new Error(`加载本地空间图片出错,uri:${uri}`))); }, () => reject(new Error(`加载本地空间图片出错,uri:${imgElt.attributes.src.nodeValue}`)));
})); }));
Promise.all(loadWorkspaceImg).then(); Promise.all(loadWorkspaceImg).then();
} }