feat: 前后端全量开发 v0.2
后端: - 客户模块 CRUD+搜索 (api/services/repositories 分层) - 合同模块: FG单号规则/意向单转正式单/订单创建自动快照客户信息 - 优化下料: FFD首递减装箱算法(利用率统计/余料/未排入清单) 前端 (Vue3+TS+Element Plus): - 7页面: 登录/工作台/订单中心/合同/客户/样板库/优化下料 - 自研二维窗型画布渲染器: 解析drawing_data渲染玻璃区域/外框/ 扇开向标记/尺寸标注, 支持缩放平移复位 - 样板库与订单联动(用此样板下单自动带图纸) - axios统一envelope拦截/登录守卫/付费墙提示 工程: - SPA history 回退路由, 构建产物挂载后端 - 全接口回归 6/6 通过
This commit is contained in:
@@ -53,15 +53,28 @@ async def health():
|
||||
|
||||
app.include_router(api_router)
|
||||
|
||||
from fastapi.responses import FileResponse # noqa: E402
|
||||
|
||||
# 静态资源:样板平面图(data/windoor-images)
|
||||
_imgdir = Path(__file__).resolve().parents[2] / "data" / "windoor-images"
|
||||
if _imgdir.exists():
|
||||
app.mount("/static/windoor-images", StaticFiles(directory=str(_imgdir)), name="windoor-images")
|
||||
|
||||
# 前端构建产物挂载(前后端规范:构建到后端目录)
|
||||
# 前端构建产物挂载(前后端规范:构建到后端目录)+ history 路由回退
|
||||
_dist = Path(__file__).resolve().parents[2] / "frontend" / "dist"
|
||||
if _dist.exists():
|
||||
app.mount("/", StaticFiles(directory=str(_dist), html=True), name="frontend")
|
||||
app.mount("/assets", StaticFiles(directory=str(_dist / "assets")), name="assets")
|
||||
|
||||
@app.get("/{full_path:path}", include_in_schema=False)
|
||||
async def spa_fallback(full_path: str):
|
||||
"""非 API/静态路径一律返回 index.html(前端 history 模式)。"""
|
||||
if full_path.startswith(("api/", "static/")):
|
||||
return JSONResponse(
|
||||
{"code": 0, "message": "接口不存在", "data": "", "other_data": "", "other_data2": ""})
|
||||
target = _dist / full_path
|
||||
if full_path and target.is_file():
|
||||
return FileResponse(target)
|
||||
return FileResponse(_dist / "index.html")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
Reference in New Issue
Block a user