mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-20 18:54:09 +00:00
fix the problem that no permission to exported knowledge when the cookie cannot be get (#1182)
This commit is contained in:
@@ -34,6 +34,7 @@ import ParentPaths from '@/components/common/ParentPaths';
|
|||||||
import DatasetTypeTag from '@/components/core/dataset/DatasetTypeTag';
|
import DatasetTypeTag from '@/components/core/dataset/DatasetTypeTag';
|
||||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||||
|
import { getToken } from '@/web/support/user/auth';
|
||||||
|
|
||||||
const CreateModal = dynamic(() => import('./component/CreateModal'), { ssr: false });
|
const CreateModal = dynamic(() => import('./component/CreateModal'), { ssr: false });
|
||||||
const MoveModal = dynamic(() => import('./component/MoveModal'), { ssr: false });
|
const MoveModal = dynamic(() => import('./component/MoveModal'), { ssr: false });
|
||||||
@@ -90,12 +91,9 @@ const Kb = () => {
|
|||||||
mutationFn: async (dataset: DatasetItemType) => {
|
mutationFn: async (dataset: DatasetItemType) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
await checkTeamExportDatasetLimit(dataset._id);
|
await checkTeamExportDatasetLimit(dataset._id);
|
||||||
const a = document.createElement('a');
|
const url = `/api/core/dataset/exportAll?datasetId=${dataset._id}`;
|
||||||
a.href = `/api/core/dataset/exportAll?datasetId=${dataset._id}`;
|
const name = `${dataset.name}.csv`;
|
||||||
a.download = `${dataset.name}.csv`;
|
localDownLoadWithToken(url, name, getToken());
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
document.body.removeChild(a);
|
|
||||||
},
|
},
|
||||||
onSettled() {
|
onSettled() {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -103,6 +101,26 @@ const Kb = () => {
|
|||||||
errorToast: t('dataset.Export Dataset Limit Error')
|
errorToast: t('dataset.Export Dataset Limit Error')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const localDownLoadWithToken = (url: string | URL, filename: string, token: string) => {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', url, true);
|
||||||
|
xhr.setRequestHeader("token", token);
|
||||||
|
xhr.responseType = 'blob';
|
||||||
|
xhr.onload = function (e) {
|
||||||
|
if (this.status == 200) {
|
||||||
|
var blob = this.response;
|
||||||
|
var a = document.createElement('a');
|
||||||
|
var url = URL.createObjectURL(blob);
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename;
|
||||||
|
a.click();
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const { data, refetch, isFetching } = useQuery(
|
const { data, refetch, isFetching } = useQuery(
|
||||||
['loadDataset', parentId],
|
['loadDataset', parentId],
|
||||||
() => {
|
() => {
|
||||||
@@ -238,7 +256,7 @@ const Kb = () => {
|
|||||||
parentId: dragTargetId
|
parentId: dragTargetId
|
||||||
});
|
});
|
||||||
refetch();
|
refetch();
|
||||||
} catch (error) {}
|
} catch (error) { }
|
||||||
setDragTargetId(undefined);
|
setDragTargetId(undefined);
|
||||||
}}
|
}}
|
||||||
_hover={{
|
_hover={{
|
||||||
@@ -301,41 +319,41 @@ const Kb = () => {
|
|||||||
menuList={[
|
menuList={[
|
||||||
...(dataset.permission === PermissionTypeEnum.private
|
...(dataset.permission === PermissionTypeEnum.private
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
<Flex alignItems={'center'}>
|
<Flex alignItems={'center'}>
|
||||||
<MyIcon name={'support/permission/publicLight'} w={'14px'} mr={2} />
|
<MyIcon name={'support/permission/publicLight'} w={'14px'} mr={2} />
|
||||||
{t('permission.Set Public')}
|
{t('permission.Set Public')}
|
||||||
</Flex>
|
</Flex>
|
||||||
),
|
),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
updateDataset({
|
updateDataset({
|
||||||
id: dataset._id,
|
id: dataset._id,
|
||||||
permission: PermissionTypeEnum.public
|
permission: PermissionTypeEnum.public
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
|
]
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
<Flex alignItems={'center'}>
|
<Flex alignItems={'center'}>
|
||||||
<MyIcon
|
<MyIcon
|
||||||
name={'support/permission/privateLight'}
|
name={'support/permission/privateLight'}
|
||||||
w={'14px'}
|
w={'14px'}
|
||||||
mr={2}
|
mr={2}
|
||||||
/>
|
/>
|
||||||
{t('permission.Set Private')}
|
{t('permission.Set Private')}
|
||||||
</Flex>
|
</Flex>
|
||||||
),
|
),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
updateDataset({
|
updateDataset({
|
||||||
id: dataset._id,
|
id: dataset._id,
|
||||||
permission: PermissionTypeEnum.private
|
permission: PermissionTypeEnum.private
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]),
|
}
|
||||||
|
]),
|
||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
<Flex alignItems={'center'}>
|
<Flex alignItems={'center'}>
|
||||||
|
Reference in New Issue
Block a user