Files
QZMusic-Web/start.sh
2026-06-04 15:15:17 +00:00

60 lines
1.4 KiB
Bash
Executable File
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.
#!/bin/bash
# QZMusic-Web 启动脚本
# 端口10096
echo "=========================================="
echo " 启动 QZMusic-Web"
echo "=========================================="
echo ""
# 检查是否已安装依赖
if [ ! -d "node_modules" ]; then
echo "📦 依赖未安装,正在安装..."
npm install
if [ $? -ne 0 ]; then
echo "❌ 依赖安装失败!"
exit 1
fi
fi
# 选择启动模式
echo "请选择启动模式:"
echo " 1) 开发模式(带热更新)"
echo " 2) 生产模式(静态文件服务)"
read -p "请输入选项 (1/2默认 2): " choice
case ${choice:-2} in
1)
echo ""
echo "🚀 正在启动开发服务器..."
echo "🌐 访问地址: http://localhost:10096"
echo ""
echo "按 Ctrl+C 停止服务器"
echo ""
npm run dev
;;
2)
# 检查是否已构建
if [ ! -d "dist" ]; then
echo "📦 未找到构建文件,正在构建..."
npm run build
if [ $? -ne 0 ]; then
echo "❌ 构建失败!"
exit 1
fi
fi
echo ""
echo "🚀 正在启动生产服务器..."
echo "🌐 访问地址: http://[你的IP]:10096"
echo ""
echo "按 Ctrl+C 停止服务器"
echo ""
npm run serve
;;
*)
echo "❌ 无效选项!"
exit 1
;;
esac