Merge branch 'dev' into test

This commit is contained in:
2026-06-18 11:35:46 +08:00
3 changed files with 33 additions and 20 deletions
+30 -18
View File
@@ -12,6 +12,7 @@ LOG_FILE=""
CURRENT_BRANCH=""
START_PORT=""
BUILD_EXIT=0
STOP_WAIT_SECONDS=3
resolve_repo_context() {
GIT_DIR_ABS="$(git rev-parse --absolute-git-dir 2>/dev/null)"
@@ -104,31 +105,42 @@ run_build() {
}
# ============================================================
# 6. stop_existing_next —— 仅停止当前分支端口上的旧进程
# 1) 优雅关闭(SIGTERM)—— 旧进程自己 drain
# 2) 等 2s
# 3) 强杀(SIGKILL)—— 还在的话
# 4) 等 1s
# 6. stop_existing_next —— 强杀当前分支端口上的旧进程
# 1) 查找占用 START_PORT 的进程
# 2) 直接 SIGKILL,避免旧服务 drain 太久导致新服务无法绑定端口
# 3) 等待 STOP_WAIT_SECONDS,让系统释放端口
# 4) 复查端口占用并再次强杀残留
# ============================================================
find_port_pids() {
if command -v lsof >/dev/null 2>&1; then
lsof -ti tcp:"$START_PORT" 2>/dev/null || true
return
fi
if command -v fuser >/dev/null 2>&1; then
fuser "$START_PORT"/tcp 2>/dev/null || true
fi
}
stop_existing_next() {
echo "=== stop existing next on port $START_PORT @ $(date +%Y-%m-%dT%H:%M:%S%z) ===" >> "$LOG_FILE"
PIDS=""
if command -v lsof >/dev/null 2>&1; then
PIDS="$(lsof -ti tcp:"$START_PORT" 2>/dev/null || true)"
elif command -v fuser >/dev/null 2>&1; then
PIDS="$(fuser "$START_PORT"/tcp 2>/dev/null || true)"
else
pkill -f "next start.*$START_PORT" 2>/dev/null || true
fi
PIDS="$(find_port_pids)"
if [ -n "$PIDS" ]; then
kill $PIDS 2>/dev/null || true
fi
sleep 2
if [ -n "$PIDS" ]; then
echo "=== force kill PIDS: $PIDS ===" >> "$LOG_FILE"
kill -9 $PIDS 2>/dev/null || true
else
echo "=== no process found on port $START_PORT ===" >> "$LOG_FILE"
fi
sleep 1
sleep "$STOP_WAIT_SECONDS"
REMAINING_PIDS="$(find_port_pids)"
if [ -n "$REMAINING_PIDS" ]; then
echo "=== force kill remaining PIDS: $REMAINING_PIDS ===" >> "$LOG_FILE"
kill -9 $REMAINING_PIDS 2>/dev/null || true
sleep "$STOP_WAIT_SECONDS"
fi
echo "=== stop DONE @ $(date +%Y-%m-%dT%H:%M:%S%z) ===" >> "$LOG_FILE"
echo "" >> "$LOG_FILE"
}
+1 -1
View File
@@ -178,7 +178,7 @@ export function ChatScreen() {
return;
}
UrlLauncherUtil.openUrlWithExternalBrowser(ROUTES.chat);
UrlLauncherUtil.openUrlWithExternalBrowser(ROUTES.splash);
}
return (
@@ -15,6 +15,7 @@
import { useEffect } from "react";
import { BrowserDetector } from "@/utils/browser-detect";
import { AppEnvUtil } from "@/utils/app-env";
import { SpAsyncUtil } from "@/utils/storage";
import { pwaUtil } from "@/utils/pwa";
@@ -37,7 +38,7 @@ export function PwaInstallOverlay() {
// 提前挂 beforeinstallprompt 监听,避免用户点 OK 时事件已在更早时机丢失。
pwaUtil.prepareInstallPrompt();
const isDev = process.env.NODE_ENV === "development";
const isDev = AppEnvUtil.isDevelopment();
if (!isDev) {
// 生产环境:每日只弹一次(防骚扰)