From 4d6278a8d609d85afadb8ddfce1ea5397e81a356 Mon Sep 17 00:00:00 2001 From: jingrow Date: Sun, 2 Nov 2025 23:27:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96local=5Fapp.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jcloud/api/local_app.py | 167 +++++++++++------- .../jcloud/pagetype/local_app/local_app.json | 6 +- jcloud/jcloud/pagetype/local_app/local_app.py | 2 +- .../pagetype/local_node/local_node.json | 6 +- .../jcloud/pagetype/local_node/local_node.py | 2 +- 5 files changed, 112 insertions(+), 71 deletions(-) diff --git a/jcloud/api/local_app.py b/jcloud/api/local_app.py index fbe963e..e6dabbc 100644 --- a/jcloud/api/local_app.py +++ b/jcloud/api/local_app.py @@ -140,6 +140,68 @@ def get_local_app(name): return app_data +@dashboard_whitelist() +def get_my_local_app_list(filters=None, order_by=None, limit_start=None, limit_page_length=None): + """获取当前团队的应用列表""" + + team = get_current_team() + if not team: + return {"success": False, "message": "未找到当前团队信息"} + + # 构建查询条件 + query_filters = {"team": team} + + if filters: + if isinstance(filters, str): + import json + filters = json.loads(filters) + query_filters.update(filters) + + # 默认排序 + if not order_by: + order_by = "app_name asc" + + # 获取应用列表 + apps = jingrow.get_all( + "Local App", + filters=query_filters, + fields=[ + "name", "app_name", "title", "subtitle", "category", + "enabled", "public", "team", "status", "repository_url", + "file_url", "app_image", "creation", "modified" + ], + order_by=order_by, + limit_start=limit_start, + limit_page_length=limit_page_length + ) + + # 批量获取团队用户名称 + team_user_names = _get_team_user_names(apps) + + # 格式化返回数据 + result = [] + for app in apps: + app_data = { + "name": app.name, + "app_name": app.app_name, + "title": app.title, + "subtitle": app.subtitle, + "category": app.category, + "enabled": app.enabled, + "public": app.public, + "team": team_user_names.get(app.team), + "status": app.status, + "repository_url": app.repository_url, + "file_url": app.file_url, + "app_image": app.app_image, + "creation": app.creation, + "modified": app.modified + } + result.append(app_data) + + return result + + @dashboard_whitelist() def create_local_app(app_data): """创建本地应用""" @@ -217,87 +279,62 @@ def delete_local_app(name): return {"success": True, "message": "应用删除成功"} -@jingrow.whitelist(allow_guest=True) -def get_local_app_meta(): - """获取 Local App 元数据信息""" +@dashboard_whitelist() +def get_my_local_node_list(filters=None, order_by=None, limit_start=None, limit_page_length=None): + """获取当前团队的节点列表""" - meta = jingrow.get_meta("Local App") - return meta.as_dict() - - -@jingrow.whitelist(allow_guest=True) -def get_local_app_categories(): - """获取本地应用分类列表""" + team = get_current_team() + if not team: + return {"success": False, "message": "未找到当前团队信息"} - categories = jingrow.get_all( - "Marketplace App Category", - fields=["name", "description", "slug"], - order_by="name asc" - ) - - result = [] - for category in categories: - category_data = { - "name": category.name, - "description": category.description, - "slug": category.slug - } - result.append(category_data) - - return result - - -@jingrow.whitelist(allow_guest=True) -def search_local_apps(query, filters=None, limit=20): - """搜索本地应用""" - - # 构建搜索条件 - search_filters = { - "enabled": 1, - "app_name": ["like", f"%{query}%"] - } + # 构建查询条件 + query_filters = {"team": team} if filters: if isinstance(filters, str): import json filters = json.loads(filters) - search_filters.update(filters) + query_filters.update(filters) - # 搜索应用 - apps = jingrow.get_all( - "Local App", - filters=search_filters, + # 默认排序 + if not order_by: + order_by = "node_type asc" + + # 获取节点列表 + nodes = jingrow.get_all( + "Local Node", + filters=query_filters, fields=[ - "name", "app_name", "title", "subtitle", "category", + "name", "node_type", "title", "subtitle", "enabled", "public", "team", "status", "repository_url", - "file_url", "app_image", "creation", "modified" + "file_url", "node_image", "creation", "modified" ], - order_by="app_name asc", - limit=limit + order_by=order_by, + limit_start=limit_start, + limit_page_length=limit_page_length ) # 批量获取团队用户名称 - team_user_names = _get_team_user_names(apps) + team_user_names = _get_team_user_names(nodes) # 格式化返回数据 result = [] - for app in apps: - app_data = { - "name": app.name, - "app_name": app.app_name, - "title": app.title, - "subtitle": app.subtitle, - "category": app.category, - "enabled": app.enabled, - "public": app.public, - "team": team_user_names.get(app.team), - "status": app.status, - "repository_url": app.repository_url, - "file_url": app.file_url, - "app_image": app.app_image, - "creation": app.creation, - "modified": app.modified + for node in nodes: + node_data = { + "name": node.name, + "node_type": node.node_type, + "title": node.title, + "subtitle": node.subtitle, + "enabled": node.enabled, + "public": node.public, + "team": team_user_names.get(node.team), + "status": node.status, + "repository_url": node.repository_url, + "file_url": node.file_url, + "node_image": node.node_image, + "creation": node.creation, + "modified": node.modified } - result.append(app_data) + result.append(node_data) - return result \ No newline at end of file + return result diff --git a/jcloud/jcloud/pagetype/local_app/local_app.json b/jcloud/jcloud/pagetype/local_app/local_app.json index af4642d..39f1064 100644 --- a/jcloud/jcloud/pagetype/local_app/local_app.json +++ b/jcloud/jcloud/pagetype/local_app/local_app.json @@ -24,6 +24,8 @@ { "fieldname": "team", "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, "label": "Team", "options": "Team", "read_only": 1 @@ -96,7 +98,7 @@ "fieldname": "status", "fieldtype": "Select", "label": "Status", - "options": "Published\nUnpublished\nDraft" + "options": "Pending Review\nPublished\nUnpublished\nDraft" }, { "fieldname": "subtitle", @@ -105,7 +107,7 @@ } ], "links": [], - "modified": "2025-10-22 22:35:00.480783", + "modified": "2025-11-02 22:55:33.457151", "modified_by": "Administrator", "module": "Jcloud", "name": "Local App", diff --git a/jcloud/jcloud/pagetype/local_app/local_app.py b/jcloud/jcloud/pagetype/local_app/local_app.py index 3ad1408..b612879 100644 --- a/jcloud/jcloud/pagetype/local_app/local_app.py +++ b/jcloud/jcloud/pagetype/local_app/local_app.py @@ -21,7 +21,7 @@ class LocalApp(Page): file_url: DF.Data | None public: DF.Check repository_url: DF.Data | None - status: DF.Literal["Published", "Unpublished", "Draft"] + status: DF.Literal["Pending Review", "Published", "Unpublished", "Draft"] subtitle: DF.SmallText | None team: DF.Link | None title: DF.Data diff --git a/jcloud/jcloud/pagetype/local_node/local_node.json b/jcloud/jcloud/pagetype/local_node/local_node.json index 3e10663..943a697 100644 --- a/jcloud/jcloud/pagetype/local_node/local_node.json +++ b/jcloud/jcloud/pagetype/local_node/local_node.json @@ -23,6 +23,8 @@ { "fieldname": "team", "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, "label": "Team", "options": "Team", "read_only": 1 @@ -73,7 +75,7 @@ "fieldname": "status", "fieldtype": "Select", "label": "Status", - "options": "Published\nUnpublished\nDraft" + "options": "Pending Review\nPublished\nUnpublished\nDraft" }, { "fieldname": "subtitle", @@ -96,7 +98,7 @@ } ], "links": [], - "modified": "2025-11-02 04:50:27.312179", + "modified": "2025-11-02 23:06:55.789746", "modified_by": "Administrator", "module": "Jcloud", "name": "Local Node", diff --git a/jcloud/jcloud/pagetype/local_node/local_node.py b/jcloud/jcloud/pagetype/local_node/local_node.py index 1e0425c..9ec53de 100644 --- a/jcloud/jcloud/pagetype/local_node/local_node.py +++ b/jcloud/jcloud/pagetype/local_node/local_node.py @@ -20,7 +20,7 @@ class LocalNode(Page): node_type: DF.Data public: DF.Check repository_url: DF.Data | None - status: DF.Literal["Published", "Unpublished", "Draft"] + status: DF.Literal["Pending Review", "Published", "Unpublished", "Draft"] subtitle: DF.SmallText | None team: DF.Link | None title: DF.Data