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
7cdb16c8
authored
Sep 25, 2025
by
Finley Ge
Committed by
GitHub
Sep 25, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: permission index & model table collaborator context lazy mount (#5703)
parent
d4c1e255
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
15 deletions
+45
-15
packages/service/support/permission/schema.ts
+5
-0
projects/app/src/components/core/ai/ModelTable/index.tsx
+7
-14
projects/app/src/components/support/permission/MemberManager/context.tsx
+33
-1
No files found.
packages/service/support/permission/schema.ts
View file @
7cdb16c8
...
@@ -78,6 +78,11 @@ ResourcePermissionSchema.virtual('org', {
...
@@ -78,6 +78,11 @@ ResourcePermissionSchema.virtual('org', {
});
});
try
{
try
{
ResourcePermissionSchema
.
index
({
resourceType
:
1
,
teamId
:
1
});
// Indexes for resourceId-based resources
// Indexes for resourceId-based resources
ResourcePermissionSchema
.
index
(
ResourcePermissionSchema
.
index
(
{
{
...
...
projects/app/src/components/core/ai/ModelTable/index.tsx
View file @
7cdb16c8
...
@@ -26,10 +26,10 @@ import dynamic from 'next/dynamic';
...
@@ -26,10 +26,10 @@ import dynamic from 'next/dynamic';
import
CopyBox
from
'@fastgpt/web/components/common/String/CopyBox'
;
import
CopyBox
from
'@fastgpt/web/components/common/String/CopyBox'
;
import
MyIconButton
from
'@fastgpt/web/components/common/Icon/button'
;
import
MyIconButton
from
'@fastgpt/web/components/common/Icon/button'
;
import
{
useTableMultipleSelect
}
from
'@fastgpt/web/hooks/useTableMultipleSelect'
;
import
{
useTableMultipleSelect
}
from
'@fastgpt/web/hooks/useTableMultipleSelect'
;
import
CollaboratorContextProvider
from
'@/components/support/permission/MemberManager/context'
;
import
{
ReadRoleVal
}
from
'@fastgpt/global/support/permission/constant'
;
import
{
ReadRoleVal
}
from
'@fastgpt/global/support/permission/constant'
;
import
{
getModelCollaborators
,
updateModelCollaborators
}
from
'@/web/common/system/api'
;
import
{
getModelCollaborators
,
updateModelCollaborators
}
from
'@/web/common/system/api'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
LazyCollaboratorProvider
}
from
'@/components/support/permission/MemberManager/context'
;
const
MyModal
=
dynamic
(()
=>
import
(
'@fastgpt/web/components/common/MyModal'
));
const
MyModal
=
dynamic
(()
=>
import
(
'@fastgpt/web/components/common/MyModal'
));
...
@@ -317,7 +317,7 @@ const ModelTable = () => {
...
@@ -317,7 +317,7 @@ const ModelTable = () => {
<
Td
fontSize=
{
'sm'
}
>
{
item
.
priceLabel
}
</
Td
>
<
Td
fontSize=
{
'sm'
}
>
{
item
.
priceLabel
}
</
Td
>
{
userInfo
?.
team
.
permission
.
hasManagePer
&&
(
{
userInfo
?.
team
.
permission
.
hasManagePer
&&
(
<
Td
fontSize=
{
'sm'
}
>
<
Td
fontSize=
{
'sm'
}
>
<
CollaboratorContext
Provider
<
LazyCollaborator
Provider
selectedHint=
{
t
(
'account_model:model_permission_config_hint'
)
}
selectedHint=
{
t
(
'account_model:model_permission_config_hint'
)
}
defaultRole=
{
ReadRoleVal
}
defaultRole=
{
ReadRoleVal
}
onGetCollaboratorList=
{
()
=>
getModelCollaborators
(
item
.
model
)
}
onGetCollaboratorList=
{
()
=>
getModelCollaborators
(
item
.
model
)
}
...
@@ -335,12 +335,10 @@ const ModelTable = () => {
...
@@ -335,12 +335,10 @@ const ModelTable = () => {
size=
"1rem"
size=
"1rem"
hoverColor=
{
'blue.500'
}
hoverColor=
{
'blue.500'
}
w=
"min-content"
w=
"min-content"
onClick=
{
()
=>
{
onClick=
{
onOpenManageModal
}
onOpenManageModal
();
}
}
/>
/>
)
}
)
}
</
CollaboratorContext
Provider
>
</
LazyCollaborator
Provider
>
</
Td
>
</
Td
>
)
}
)
}
</
Tr
>
</
Tr
>
...
@@ -351,7 +349,7 @@ const ModelTable = () => {
...
@@ -351,7 +349,7 @@ const ModelTable = () => {
<
FloatingActionBar
<
FloatingActionBar
Controler=
{
Controler=
{
<
CollaboratorContext
Provider
<
LazyCollaborator
Provider
selectedHint=
{
t
(
'account_model:model_permission_config_hint'
)
}
selectedHint=
{
t
(
'account_model:model_permission_config_hint'
)
}
defaultRole=
{
ReadRoleVal
}
defaultRole=
{
ReadRoleVal
}
onGetCollaboratorList=
{
()
=>
onGetCollaboratorList=
{
()
=>
...
@@ -368,16 +366,11 @@ const ModelTable = () => {
...
@@ -368,16 +366,11 @@ const ModelTable = () => {
permission=
{
userInfo
?.
team
.
permission
!
}
permission=
{
userInfo
?.
team
.
permission
!
}
>
>
{
({
onOpenManageModal
})
=>
(
{
({
onOpenManageModal
})
=>
(
<
Button
<
Button
variant=
{
'whiteBase'
}
onClick=
{
onOpenManageModal
}
>
variant=
{
'whiteBase'
}
onClick=
{
()
=>
{
onOpenManageModal
();
}
}
>
{
t
(
'common:permission.Permission config'
)
}
{
t
(
'common:permission.Permission config'
)
}
</
Button
>
</
Button
>
)
}
)
}
</
CollaboratorContext
Provider
>
</
LazyCollaborator
Provider
>
}
}
></
FloatingActionBar
>
></
FloatingActionBar
>
</
Flex
>
</
Flex
>
...
...
projects/app/src/components/support/permission/MemberManager/context.tsx
View file @
7cdb16c8
...
@@ -10,7 +10,7 @@ import type {
...
@@ -10,7 +10,7 @@ import type {
RoleListType
,
RoleListType
,
RoleValueType
RoleValueType
}
from
'@fastgpt/global/support/permission/type'
;
}
from
'@fastgpt/global/support/permission/type'
;
import
{
type
ReactNode
,
useCallback
,
use
Memo
}
from
'react'
;
import
{
type
ReactNode
,
useCallback
,
use
Effect
,
useMemo
,
useState
}
from
'react'
;
import
{
createContext
}
from
'use-context-selector'
;
import
{
createContext
}
from
'use-context-selector'
;
import
dynamic
from
'next/dynamic'
;
import
dynamic
from
'next/dynamic'
;
...
@@ -230,3 +230,35 @@ const CollaboratorContextProvider = ({
...
@@ -230,3 +230,35 @@ const CollaboratorContextProvider = ({
};
};
export
default
CollaboratorContextProvider
;
export
default
CollaboratorContextProvider
;
export
const
LazyCollaboratorProvider
=
({
children
,
...
props
}:
{
children
:
(
params
:
{
onOpenManageModal
:
()
=>
void
})
=>
React
.
ReactNode
;
}
&
React
.
ComponentProps
<
typeof
CollaboratorContextProvider
>
)
=>
{
const
[
isProviderMounted
,
setIsProviderMounted
]
=
useState
(
false
);
const
handleOpen
=
useCallback
(()
=>
{
setIsProviderMounted
(
true
);
},
[]);
// 如果还未挂载 Provider,只渲染触发按钮
if
(
!
isProviderMounted
)
{
return
<>
{
children
({
onOpenManageModal
:
handleOpen
})
}
</>;
}
// Provider 已挂载,渲染完整的协作者管理功能
return
(
<
CollaboratorContextProvider
{
...
props
}
>
{
({
onOpenManageModal
})
=>
{
// 组件挂载后自动打开模态框
useEffect
(()
=>
{
onOpenManageModal
();
},
[
onOpenManageModal
]);
return
<>
{
children
({
onOpenManageModal
})
}
</>;
}
}
</
CollaboratorContextProvider
>
);
};
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