jingrowlocal/start_frontend.py

41 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Jflow前端开发服务器启动脚本
"""
import subprocess
import sys
import os
from pathlib import Path
def main():
frontend_dir = Path(__file__).parent / "frontend"
print("🎨 启动Jflow前端开发服务器...")
print(f"📁 前端目录: {frontend_dir}")
print("=" * 50)
try:
# 切换到前端目录
os.chdir(frontend_dir)
# 检查是否已安装依赖
if not (frontend_dir / "node_modules").exists():
print("📦 安装前端依赖...")
subprocess.run(["npm", "install"], check=True)
# 启动Vite开发服务器
print("🚀 启动开发服务器...")
subprocess.run(["npm", "run", "dev"], check=True)
except KeyboardInterrupt:
print("\n👋 前端服务已停止")
except subprocess.CalledProcessError as e:
print(f"❌ 前端启动失败: {e}")
except FileNotFoundError:
print("❌ 未找到npm请确保已安装Node.js")
print("💡 安装指南: https://nodejs.org/")
if __name__ == "__main__":
main()