Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
db2dd91f
authored
Apr 11, 2024
by
Howie Lau
Committed by
GitHub
Apr 11, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the problem that no permission to exported knowledge when the cookie cannot be get (#1182)
parent
2991c074
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
39 deletions
+57
-39
projects/app/src/pages/dataset/list/index.tsx
+57
-39
No files found.
projects/app/src/pages/dataset/list/index.tsx
View file @
db2dd91f
...
@@ -34,6 +34,7 @@ import ParentPaths from '@/components/common/ParentPaths';
...
@@ -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 = () => {
...
@@ -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 = () => {
...
@@ -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 = () => {
...
@@ -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 = () => {
...
@@ -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'
}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment