From ebe92eb1405113882748396f2a3ae877914dc484 Mon Sep 17 00:00:00 2001 From: jingrow Date: Sat, 25 Oct 2025 01:50:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BAapp?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=87=BA=E7=8E=B0=E8=B7=AF=E5=BE=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jingrow/jingrow/api/dev.py | 5 +++-- apps/jingrow/jingrow/api/local_app_installer.py | 14 ++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/jingrow/jingrow/api/dev.py b/apps/jingrow/jingrow/api/dev.py index 4e0e50b..8d7dfc1 100644 --- a/apps/jingrow/jingrow/api/dev.py +++ b/apps/jingrow/jingrow/api/dev.py @@ -21,7 +21,7 @@ async def create_pagetypes(payload: Dict[str, Any]): slug = to_snake(name) current = Path(__file__).resolve() - # project root (apps/jingrow/jingrow/core/api/dev.py) -> go up 5 + # project root (apps/jingrow/jingrow/api/dev.py) -> go up 5 to reach /home/dev/ root = current.parents[5] frontend_path = None @@ -90,7 +90,8 @@ async def create_app_template(payload: Dict[str, Any]): raise ValueError("App name must start with lowercase letter and contain only lowercase letters, numbers, and underscores") current = Path(__file__).resolve() - root = current.parents[5] # 调整路径层级 + # project root (apps/jingrow/jingrow/api/dev.py) -> go up 4 to reach /home/dev/jingrow-framework/ + root = current.parents[4] # 创建app目录结构 - 保存到apps/app_name app_dir = root / "apps" / app_name diff --git a/apps/jingrow/jingrow/api/local_app_installer.py b/apps/jingrow/jingrow/api/local_app_installer.py index 66ecef4..f8c3cd3 100644 --- a/apps/jingrow/jingrow/api/local_app_installer.py +++ b/apps/jingrow/jingrow/api/local_app_installer.py @@ -71,10 +71,9 @@ async def install_app_from_upload( async def get_local_apps(request: Request): """扫描本地未安装的App""" try: - # 获取应用目录路径 - 修正路径 current = Path(__file__).resolve() - root = current.parents[7] # 调整路径层级 - apps_dir = root / "apps" # 新的apps目录 + root = current.parents[4] + apps_dir = root / "apps" # 获取已安装的App列表 - 从Local Installed Apps PageType读取 from jingrow import get_pg @@ -104,11 +103,10 @@ async def get_local_apps(request: Request): app_dir.name not in installed_names and app_dir.name not in system_apps): - # 检查是否有backend目录和hooks.py文件 - backend_dir = app_dir / "backend" - hooks_file = backend_dir / app_dir.name / 'hooks.py' + # 检查是否有hooks.py文件 + hooks_file = app_dir / app_dir.name / 'hooks.py' - if backend_dir.exists() and hooks_file.exists(): + if hooks_file.exists(): try: # 读取hooks.py获取App信息 with open(hooks_file, 'r', encoding='utf-8') as f: @@ -170,7 +168,7 @@ async def install_local_app(request: Request, app_name: str): try: # 获取应用目录路径 - 修正路径 current = Path(__file__).resolve() - root = current.parents[7] # 调整路径层级 + root = current.parents[4] # 调整路径层级 apps_dir = root / "apps" # 新的apps目录 app_dir = backend_dir / app_name