#!/bin/bash

# Soul派对小程序 - 生产环境部署脚本
# 域名: http://kr-soul.lytiao.com

echo "======================================="
echo "  Soul派对小程序 - 生产环境部署        "
echo "======================================="
echo ""

# 检查配置
echo "📋 当前配置:"
echo "   AppID: wx0976665c3a3d5a7c"
echo "   域名: http://kr-soul.lytiao.com"
echo "   环境: 生产环境"
echo ""

# 检查依赖
if [ ! -d "node_modules" ]; then
    echo "📦 安装依赖..."
    pnpm install || npm install
fi

# 构建生产版本
echo ""
echo "🔨 构建生产版本..."
pnpm build || npm run build

if [ $? -ne 0 ]; then
    echo "❌ 构建失败"
    exit 1
fi

echo ""
echo "✅ 构建完成！"
echo ""
echo "📱 小程序配置:"
echo "   1. 已配置AppID: wx0976665c3a3d5a7c"
echo "   2. 已配置API地址: http://kr-soul.lytiao.com/api"
echo ""
echo "🚀 启动生产服务器..."
echo "   访问地址: http://kr-soul.lytiao.com"
echo ""
echo "⚙️  后续配置步骤:"
echo "   1. 在小程序后台配置服务器域名白名单"
echo "   2. 配置微信支付商户号（如需支付功能）"
echo "   3. 上传代码到微信后台审核"
echo ""
echo "======================================="

# 启动生产服务器
pnpm start || npm start
