修复创建pagetype前后端模板文件路径错误

This commit is contained in:
jingrow 2025-10-25 11:58:42 +08:00
parent 7cfc1693d6
commit c8aefd3953
12 changed files with 63 additions and 6 deletions

View File

@ -59,12 +59,12 @@ const slug = computed(() => toSnake(form.value.pagetype || ''))
function dotToSlash(s: string): string { return s ? s.split('.').join('/').toLowerCase() : '' }
const frontendPath = computed(() =>
appName.value && slug.value !== ''
? `frontend/src/apps/${appName.value}/${appName.value}/${dotToSlash(moduleName.value)}/pagetype/${slug.value}/${slug.value}_toolbar.vue`
? `apps/${appName.value}/frontend/src/views/pagetype/${slug.value}/${slug.value}_toolbar.vue`
: ''
)
const backendPath = computed(() =>
appName.value && slug.value !== ''
? `${appName.value}/apps/${appName.value}/${appName.value}/${dotToSlash(moduleName.value)}/pagetype/${slug.value}/${slug.value}.py`
? `apps/${appName.value}/${appName.value}/${dotToSlash(moduleName.value)}/pagetype/${slug.value}/${slug.value}.py`
: ''
)

View File

@ -21,8 +21,7 @@ async def create_pagetypes(payload: Dict[str, Any]):
slug = to_snake(name)
current = Path(__file__).resolve()
# project root (apps/jingrow/jingrow/api/dev.py) -> go up 5 to reach /home/dev/
root = current.parents[5]
root = current.parents[4]
frontend_path = None
backend_path = None
@ -30,7 +29,7 @@ async def create_pagetypes(payload: Dict[str, Any]):
backend_exists = False
if create_frontend:
fp = root / "apps" / app / "frontend" / module / "pagetype" / slug / f"{slug}_toolbar.vue"
fp = root / "apps" / app / "frontend" / "src" / "views" / "pagetype" / slug / f"{slug}_toolbar.vue"
fp.parent.mkdir(parents=True, exist_ok=True)
if fp.exists():
frontend_exists = True
@ -39,7 +38,7 @@ async def create_pagetypes(payload: Dict[str, Any]):
frontend_path = str(fp)
if create_backend:
bp = root / "apps" / app / app / app / module / "pagetype" / slug / f"{slug}.py"
bp = root / "apps" / app / app / module / "pagetype" / slug / f"{slug}.py"
bp.parent.mkdir(parents=True, exist_ok=True)
if bp.exists():
backend_exists = True

19
apps/myapp/README.md Normal file
View File

@ -0,0 +1,19 @@
# Myapp
Myapp
## 安装
```bash
pip install -e .
```
## 开发
```bash
pip install -e ".[dev]"
```
## 许可证
MIT License

View File

@ -0,0 +1,5 @@
<template>
<div></div>
</template>
<script setup lang="ts">
</script>

View File

@ -0,0 +1 @@
__version__ = "0.0.1"

View File

View File

@ -0,0 +1,6 @@
app_name = "myapp"
app_title = "Myapp"
app_publisher = "Your Company"
app_description = "Myapp"
app_email = "support@yourcompany.com"
app_license = "mit"

View File

@ -0,0 +1 @@
Myapp

View File

View File

@ -0,0 +1,3 @@
# coding: utf-8
# Blank template for PageType backend hooks

View File

23
apps/myapp/pyproject.toml Normal file
View File

@ -0,0 +1,23 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "myapp"
version = "0.0.1"
description = "Myapp"
authors = [
{name = "Your Company", email = "support@yourcompany.com"}
]
license = {text = "MIT"}
requires-python = ">=3.8"
dependencies = [
# Add your app-specific dependencies here
]
[project.optional-dependencies]
dev = [
"pytest>=7.0.0",
"black>=23.0.0",
]