perf: 优化拖拽文件夹上传提示

This commit is contained in:
kuaifan 2023-07-29 15:26:23 +08:00
parent bbdf4932e3
commit 829ed0a575
5 changed files with 37 additions and 0 deletions

View File

@ -1277,3 +1277,8 @@ AI机器人
支持 http 或 socks 代理
例如http://proxy.com 或 socks5://proxy.com
查看 Cookie 中的 sessionKey 便是
暂不支持拖拽文件夹。
暂不支持粘贴文件夹。
暂不支持拖拽文件夹,请手动上传文件夹。
暂不支持粘贴文件夹,请手动上传文件夹。

View File

@ -869,6 +869,23 @@
url = $A.rightDelete(url, '_thumb.jpg')
url = $A.rightDelete(url, '_thumb.png')
return url
},
/**
* 拖拽或粘贴的数据是否包含文件夹
* @param data
* @returns {boolean}
*/
dataHasFolder(data) {
const {items} = data;
if (items) {
for (const item of items) {
if (!(item.kind === "file" && item.webkitGetAsEntry().isFile)) {
return true;
}
}
}
return false;
}
});

View File

@ -1582,6 +1582,11 @@ export default {
chatPasteDrag(e, type) {
this.dialogDrag = false;
if ($A.dataHasFolder(type === 'drag' ? e.dataTransfer : e.clipboardData)) {
e.preventDefault();
$A.modalWarning(`暂不支持${type === 'drag' ? '拖拽' : '粘贴'}文件夹。`)
return;
}
const files = type === 'drag' ? e.dataTransfer.files : e.clipboardData.files;
const postFiles = Array.prototype.slice.call(files);
if (postFiles.length > 0) {

View File

@ -1421,6 +1421,11 @@ export default {
taskPasteDrag(e, type) {
this.dialogDrag = false;
if ($A.dataHasFolder(type === 'drag' ? e.dataTransfer : e.clipboardData)) {
e.preventDefault();
$A.modalWarning(`暂不支持${type === 'drag' ? '拖拽' : '粘贴'}文件夹。`)
return;
}
const files = type === 'drag' ? e.dataTransfer.files : e.clipboardData.files;
this.msgFile = Array.prototype.slice.call(files);
if (this.msgFile.length > 0) {

View File

@ -1686,6 +1686,11 @@ export default {
filePasteDrag(e, type) {
this.dialogDrag = false;
if ($A.dataHasFolder(type === 'drag' ? e.dataTransfer : e.clipboardData)) {
e.preventDefault();
$A.modalWarning(`暂不支持${type === 'drag' ? '拖拽' : '粘贴'}文件夹,请手动上传文件夹。`)
return;
}
this.pasteDragNext(e, type);
},