修复创建app模板出现路径错误的问题
This commit is contained in:
parent
3636194a17
commit
ebe92eb140
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user