fix: 修复Luna页面用户授权树默认展开所有节点的问题(同步加载方式)

pull/10131/head
Bai 2023-04-04 11:28:51 +08:00 committed by Jiangjie.Bai
parent 98a2d9ffdb
commit 00ec9b6d5a
1 changed files with 20 additions and 1 deletions

View File

@ -8,6 +8,15 @@ from common.utils import lazyproperty, timeit
class SerializeToTreeNodeMixin:
request: Request
@lazyproperty
def is_sync(self):
sync_paths = ['/api/v1/perms/users/self/nodes/all-with-assets/tree/']
for p in sync_paths:
if p == self.request.path:
return True
return False
@timeit
def serialize_nodes(self, nodes: List[Node], with_asset_amount=False):
@ -17,6 +26,16 @@ class SerializeToTreeNodeMixin:
else:
def _name(node: Node):
return node.value
def _open(node):
if not self.is_sync:
# 异步加载资产树时,默认展开节点
return True
if not node.parent_key:
return True
else:
return False
data = [
{
'id': node.key,
@ -24,7 +43,7 @@ class SerializeToTreeNodeMixin:
'title': _name(node),
'pId': node.parent_key,
'isParent': True,
'open': True,
'open': _open(node),
'meta': {
'data': {
"id": node.id,