更新 app.py:修正前端路徑指向 React

變更:
- 前端路徑從 frontend/static/ 更新為 frontend-react/dist/
- 添加更詳細的錯誤提示(npm run build)
- 添加註解說明推薦使用 start_dev.bat 進行開發
- 配合清理後的專案結構(已刪除舊 frontend 目錄)

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
beabigegg
2025-11-06 11:44:00 +08:00
parent c120fc43b6
commit ad9ba59fdf

20
app.py
View File

@@ -43,19 +43,27 @@ class TimelineDesignerApp:
Returns:
前端 index.html 的絕對路徑
"""
# 開發模式:從專案目錄載入
dev_path = Path(__file__).parent / "frontend" / "static" / "index.html"
if dev_path.exists():
return str(dev_path.absolute())
# 開發模式:使用 React 開發伺服器
# 注意:需要先執行 `npm run dev` 啟動 React 前端
# PyWebview 模式已不推薦使用,建議使用 start_dev.bat 啟動前後端分離模式
# React 打包後的前端檔案
react_dist_path = Path(__file__).parent / "frontend-react" / "dist" / "index.html"
if react_dist_path.exists():
logger.info("使用 React 打包後的前端")
return str(react_dist_path.absolute())
# 打包模式:從執行檔旁邊載入
bundle_path = Path(sys.executable).parent / "frontend" / "static" / "index.html"
bundle_path = Path(sys.executable).parent / "frontend-react" / "dist" / "index.html"
if bundle_path.exists():
return str(bundle_path.absolute())
# 找不到前端檔案
logger.error("找不到前端 HTML 檔案")
raise FileNotFoundError("Frontend index.html not found")
logger.error("請執行以下命令建置前端:")
logger.error(" cd frontend-react")
logger.error(" npm run build")
raise FileNotFoundError("Frontend index.html not found. Please run 'npm run build' in frontend-react/")
def start_api_server(self):
"""