41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
#!/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()
|