Files
2025-11-24 14:33:02 +08:00

43 lines
1.3 KiB
Bash
Raw Permalink 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
echo "========================================"
echo "[INFO] 校园新闻系统 - 前端Web服务启动"
echo "========================================"
# 创建日志目录
mkdir -p /app/logs
# 处理配置文件
CONFIG_TARGET="/app/dist/app-config.js"
if [ -f /app/config/app-config.js ]; then
echo "[INFO] 检测到外部配置文件,替换默认配置"
cp /app/config/app-config.js $CONFIG_TARGET
echo "[INFO] ✅ 使用自定义配置: /app/config/app-config.js"
# 显示配置摘要
echo "[INFO] 配置摘要:"
grep -E "(env|baseUrl|api)" /app/config/app-config.js | head -5 || true
else
echo "[INFO] 未检测到外部配置文件"
if [ ! -f $CONFIG_TARGET ]; then
echo "[WARN] 默认配置不存在,复制模板"
cp /app/config/app-config.js.template $CONFIG_TARGET
fi
echo "[INFO] ✅ 使用默认配置"
fi
echo "========================================"
echo "[INFO] Node版本: $(node --version)"
echo "[INFO] Vite版本: $(vite --version)"
echo "[INFO] 前端路径: /app/dist"
echo "[INFO] 配置文件: $CONFIG_TARGET"
echo "[INFO] 日志路径: /app/logs"
echo "[INFO] 监听端口: 4173"
echo "========================================"
echo "[INFO] 启动Vite Preview服务器..."
# 启动Vite Preview前台运行
cd /app
vite preview --host 0.0.0.0 --port 4173