修复上传本地文件,在对话框输入会两次显示的 bug

This commit is contained in:
RockYang 2025-03-31 09:57:05 +08:00
parent 2a71d5d557
commit 14fa4fdaa0

View File

@ -149,10 +149,12 @@ const processFiles = () => {
return; return;
} }
//
const linkRegex = /(https?:\/\/\S+)/g; const linkRegex = /(https?:\/\/\S+)/g;
const links = props.data.content.match(linkRegex); const links = props.data.content.match(linkRegex);
const urlPrefix = `${window.location.protocol}//${window.location.host}`; const urlPrefix = `${window.location.protocol}//${window.location.host}`;
if (links) { if (links) {
//
const _links = links.map((link) => { const _links = links.map((link) => {
if (link.startsWith(urlPrefix)) { if (link.startsWith(urlPrefix)) {
return link.replace(urlPrefix, ""); return link.replace(urlPrefix, "");
@ -165,14 +167,15 @@ const processFiles = () => {
.then((res) => { .then((res) => {
files.value = res.data.items; files.value = res.data.items;
for (let link of links) { // for (let link of links) {
if (isExternalImg(link, files.value)) { // if (isExternalImg(link, files.value)) {
files.value.push({ url: link, ext: ".png" }); // files.value.push({ url: link, ext: ".png" });
} // }
} // }
}) })
.catch(() => {}); .catch(() => {});
//
for (let link of links) { for (let link of links) {
content.value = content.value.replace(link, ""); content.value = content.value.replace(link, "");
} }