mirror of
https://gitee.com/blackfox/geekai.git
synced 2025-12-07 01:08:24 +08:00
修复上传本地文件,在对话框输入会两次显示的 bug
This commit is contained in:
parent
2a71d5d557
commit
14fa4fdaa0
@ -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, "");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user