Import the supplied management frontend, including request encryption, withdrawal updates, and vendored dependencies. Use incoming versions for overlapping source files and retain existing environment configuration absent from the supplied directory.
57 lines
1.5 KiB
Bash
Executable File
57 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
||
# 双击或在「终端.app」中运行:完成依赖安装并启动前端
|
||
# 请勿在 Cursor Agent 内置终端执行(会因目录拦截导致 vite 缺失)
|
||
|
||
set -e
|
||
cd "$(dirname "$0")"
|
||
|
||
export NVM_DIR="$HOME/.nvm"
|
||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||
nvm use 20 2>/dev/null || true
|
||
|
||
echo "=========================================="
|
||
echo " Node: $(node -v 2>/dev/null || echo 未找到)"
|
||
echo " 目录: $(pwd)"
|
||
echo "=========================================="
|
||
|
||
if ! command -v node >/dev/null; then
|
||
echo "请先安装 Node.js 20+"
|
||
read -r _
|
||
exit 1
|
||
fi
|
||
|
||
if ! command -v pnpm >/dev/null; then
|
||
echo "正在安装 pnpm..."
|
||
npm install -g pnpm@9 --registry=https://registry.npmjs.org/
|
||
fi
|
||
|
||
cat > .npmrc <<'EOF'
|
||
registry=https://registry.npmjs.org/
|
||
node-linker=hoisted
|
||
shamefully-hoist=true
|
||
EOF
|
||
|
||
echo "清理并重新安装依赖..."
|
||
rm -rf node_modules
|
||
pnpm install --registry=https://registry.npmjs.org/
|
||
|
||
# 补齐 rollup 可选原生包(避免 optional deps 丢失)
|
||
case "$(uname -m)" in
|
||
x86_64) pnpm add -D @rollup/rollup-darwin-x64 --registry=https://registry.npmjs.org/ || true ;;
|
||
arm64) pnpm add -D @rollup/rollup-darwin-arm64 --registry=https://registry.npmjs.org/ || true ;;
|
||
esac
|
||
|
||
if [ ! -f node_modules/vite/package.json ]; then
|
||
echo "安装失败:未找到 vite,请把上方完整日志发给开发者"
|
||
read -r _
|
||
exit 1
|
||
fi
|
||
|
||
echo ""
|
||
echo "启动成功后请打开: http://localhost:5173"
|
||
echo "(使用远程后端 .env.dev)"
|
||
echo ""
|
||
|
||
export VITE_PORT=5173
|
||
exec pnpm exec vite --mode dev --port 5173 --host 0.0.0.0
|