test
This commit is contained in:
@@ -125,6 +125,7 @@ _start_fe() {
|
||||
|
||||
info "启动 ${BOLD}$name${NC} ..."
|
||||
if [[ "$name" == "pc" ]]; then
|
||||
pc_ensure_wasm_assets
|
||||
pc_export_vite_backend_env
|
||||
pc_print_vite_backend_env
|
||||
pc_check_nginx_gateway
|
||||
|
||||
30
common.sh
30
common.sh
@@ -311,11 +311,37 @@ pc_check_wasm_assets() {
|
||||
local asset url ct
|
||||
for asset in openIM.wasm sql-wasm.wasm wasm_exec.js; do
|
||||
url="${origin}/${asset}"
|
||||
if curl -fsS --max-time 5 "$url" >/dev/null 2>&1; then
|
||||
ct=$(curl -fsSI --max-time 5 "$url" 2>/dev/null | awk 'BEGIN{IGNORECASE=1} /^content-type:/ {sub(/\r$/, ""); print $0; exit}' || true)
|
||||
ct=$(curl -fsSI --max-time 5 "$url" 2>/dev/null | awk 'BEGIN{IGNORECASE=1} /^content-type:/ {sub(/\r$/, ""); print $0; exit}' || true)
|
||||
if [[ -n "$ct" ]] || curl -fsS --max-time 5 -r 0-0 "$url" >/dev/null 2>&1; then
|
||||
success " PC SDK 资源可达: ${url}${ct:+ (${ct#*: })}"
|
||||
else
|
||||
warn " PC SDK 资源不可达: ${url}(SDK login 可能卡住且不会发起 /msg_gateway WebSocket)"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
pc_ensure_wasm_assets() {
|
||||
local public_dir="$ROOT_DIR/pc/public"
|
||||
local assets_dir="$ROOT_DIR/pc/node_modules/@openim/wasm-client-sdk/assets"
|
||||
local asset src dst size
|
||||
|
||||
for asset in openIM.wasm sql-wasm.wasm wasm_exec.js; do
|
||||
src="$assets_dir/$asset"
|
||||
dst="$public_dir/$asset"
|
||||
|
||||
if [[ -s "$dst" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ ! -s "$src" ]]; then
|
||||
warn " PC SDK 资源缺失且无法自动补齐: $dst(未找到 $src)"
|
||||
continue
|
||||
fi
|
||||
|
||||
mkdir -p "$public_dir"
|
||||
cp "$src" "$dst"
|
||||
chmod 0644 "$dst" 2>/dev/null || true
|
||||
size=$(wc -c < "$dst" 2>/dev/null | tr -d ' ' || true)
|
||||
success " 已补齐 PC SDK 资源: $dst${size:+ (${size} bytes)}"
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user