From 73f669d170426a87ded55bb647fdbef662082ec4 Mon Sep 17 00:00:00 2001 From: jingrow Date: Wed, 5 Nov 2025 03:12:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84getSinglePageData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jingrow/frontend/src/shared/utils/pagetype.ts | 11 ++++------- apps/jingrow/jingrow/__init__.py | 5 ++++- apps/jingrow/jingrow/api/page.py | 11 ----------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/apps/jingrow/frontend/src/shared/utils/pagetype.ts b/apps/jingrow/frontend/src/shared/utils/pagetype.ts index b910bab..012dc95 100644 --- a/apps/jingrow/frontend/src/shared/utils/pagetype.ts +++ b/apps/jingrow/frontend/src/shared/utils/pagetype.ts @@ -40,19 +40,16 @@ export async function getPageTypeRouteName(entity: string): Promise { */ export async function getSinglePageData(pagetype: string): Promise<{ success: boolean; data?: any; message?: string }> { try { - const url = `/api/action/jingrow.client.get_single` + const url = `/api/data/${encodeURIComponent(pagetype)}/${encodeURIComponent(pagetype)}` const res = await axios.get(url, { - params: { - pagetype: pagetype - }, headers: get_session_api_headers(), withCredentials: true }) - if (res.data?.message) { + if (res.data?.data) { return { success: true, - data: res.data.message + data: res.data.data } } else { return { @@ -64,7 +61,7 @@ export async function getSinglePageData(pagetype: string): Promise<{ success: bo console.error('Failed to get single page data:', error) return { success: false, - message: error.response?.data?.message || error.message || '获取单页数据失败' + message: error.response?.data?.detail || error.message || '获取单页数据失败' } } } diff --git a/apps/jingrow/jingrow/__init__.py b/apps/jingrow/jingrow/__init__.py index 99ddb33..ca6583a 100644 --- a/apps/jingrow/jingrow/__init__.py +++ b/apps/jingrow/jingrow/__init__.py @@ -122,7 +122,10 @@ def get_all(pagetype: str, filters: List[List[Any]] = None, fields: List[str] = def get_single(pagetype: str): """获取 single 类型 pagetype 配置,返回 {success, config|error} 结构。""" - return Page(pagetype).get_single() + data = get_pg(pagetype, pagetype) + if data is None: + return {'success': False, 'error': f'{pagetype}配置不存在'} + return {'success': True, 'config': data} def get_module_app(pagetype: str): diff --git a/apps/jingrow/jingrow/api/page.py b/apps/jingrow/jingrow/api/page.py index ae4f414..6bf97dc 100644 --- a/apps/jingrow/jingrow/api/page.py +++ b/apps/jingrow/jingrow/api/page.py @@ -198,16 +198,5 @@ async def get_record_count(request: Request, pagetype: str): raise HTTPException(status_code=500, detail=str(e)) -@router.get("/api/single/{pagetype}") -async def get_single(request: Request, pagetype: str): - """获取single类型pagetype记录""" - try: - result = jingrow.get_single(pagetype) - if isinstance(result, dict) and result.get('success'): - return JSONResponse(content={"data": result.get('config', {})}) - raise HTTPException(status_code=404, detail=(result or {}).get('error', '配置不存在') if isinstance(result, dict) else '配置不存在') - - except Exception as e: - raise HTTPException(status_code=500, detail=str(e))