1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 00:20:07 +00:00

Fix download file bug in grid mode right click (#7418)

* fix download file use different API

* change error message
This commit is contained in:
Michael An
2025-01-23 12:49:54 +08:00
committed by GitHub
parent 689b5cba83
commit f590e7741d
3 changed files with 35 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { siteRoot, username, enableSeadoc, thumbnailDefaultSize, thumbnailSizeForOriginal, gettext, fileServerRoot, enableWhiteboard } from '../../utils/constants';
import { siteRoot, username, enableSeadoc, thumbnailDefaultSize, thumbnailSizeForOriginal, gettext, fileServerRoot, enableWhiteboard, useGoFileserver } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import { seafileAPI } from '../../utils/seafile-api';
import URLDecorator from '../../utils/url-decorator';
@@ -486,10 +486,20 @@ class DirentGridView extends React.Component {
return dirent.name;
});
this.setState({
isZipDialogOpen: true,
downloadItems: selectedDirentNames
});
if (useGoFileserver) {
seafileAPI.zipDownload(repoID, path, selectedDirentNames).then((res) => {
const zipToken = res.data['zip_token'];
location.href = `${fileServerRoot}zip/${zipToken}`;
}).catch((error) => {
let errorMsg = Utils.getErrorMsg(error);
toaster.danger(errorMsg);
});
} else {
this.setState({
isZipDialogOpen: true,
downloadItems: selectedDirentNames
});
}
};
onCreateFolderToggle = () => {

View File

@@ -1,7 +1,7 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { siteRoot, gettext, username, enableSeadoc, thumbnailSizeForOriginal, thumbnailDefaultSize, fileServerRoot, enableWhiteboard } from '../../utils/constants';
import { siteRoot, gettext, username, enableSeadoc, thumbnailSizeForOriginal, thumbnailDefaultSize, fileServerRoot, enableWhiteboard, useGoFileserver } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import TextTranslation from '../../utils/text-translation';
import URLDecorator from '../../utils/url-decorator';
@@ -340,10 +340,20 @@ class DirentListView extends React.Component {
return dirent.name;
});
this.setState({
isProgressDialogShow: true,
downloadItems: selectedDirentNames
});
if (useGoFileserver) {
seafileAPI.zipDownload(repoID, path, selectedDirentNames).then((res) => {
const zipToken = res.data['zip_token'];
location.href = `${fileServerRoot}zip/${zipToken}`;
}).catch((error) => {
let errorMsg = Utils.getErrorMsg(error);
toaster.danger(errorMsg);
});
} else {
this.setState({
isProgressDialogShow: true,
downloadItems: selectedDirentNames
});
}
}
};

View File

@@ -83,11 +83,7 @@ class SelectedDirentsToolbar extends React.Component {
location.href = url;
return;
}
if (!useGoFileserver) {
this.setState({
isZipDialogOpen: true
});
} else {
if (useGoFileserver) {
const target = this.props.selectedDirentList.map(dirent => dirent.name);
seafileAPI.zipDownload(repoID, path, target).then((res) => {
const zipToken = res.data['zip_token'];
@@ -99,6 +95,10 @@ class SelectedDirentsToolbar extends React.Component {
errorMsg: errorMsg
});
});
} else {
this.setState({
isZipDialogOpen: true
});
}
}
};