chore: 官网拆分 homepage + 关于页瘦身 + 端口 5175(当前可用状态基线)

This commit is contained in:
Logan.Li committed 2026-10-14 20:31:51 +08:00
1 parent 5eb11826db
commit be151cb68f
85 files changed
+4420 -1530

No files matched your search

+61 -38
View File
@@ -1,22 +1,23 @@
#!/usr/bin/env bash
# OpsXShell launcher — scene profiles(对齐 opsxdb / opsxapi)
# OpsxShell launcher — scene profiles(对齐 opsxdb / opsxapi)
#
# ./run.sh # = web:仅 Gin 官网 + docs(:8789)
# ./run.sh web # 同上(浏览器不当操作客户端)
# ./run.sh gui # 桌面唯一操作入口:Tauri;默认也起 Gin
# ./run.sh gui # 桌面唯一操作入口:临时 .app(Dock 图标)+ 默认 Gin
# ./run.sh all # 同 gui(兼容旧命令)
# ./run.sh server|desktop
# ./run.sh clean-apps # 全量开发机卫生(~/devops/scripts/clean-opsx-apps.sh)
# ./run.sh stop|restart|status|help
#
# 产品形态:浏览器 = 官网/docs;操作 = 桌面 Tauri(src/ + src-tauri/)。
# Vite :1420 仅作桌面 WebView 源,不要用浏览器当工作台。
# Vite :5175 仅作桌面 WebView 源,不要用浏览器当工作台。
set -euo pipefail
PROJECT_NAME="OpsXShell"
PROJECT_NAME="OpsxShell"
SERVER_PORT="${OPSXSHELL_SERVER_PORT:-8789}"
WEB_PORT="${OPSXSHELL_WEB_PORT:-1420}"
SERVER_DIR="apps/server"
WEB_PORT="${OPSXSHELL_WEB_PORT:-5175}"
SERVER_DIR="server"
SERVER_BIN="opsxshell-server"
SERVER_LABEL="com.opsx.shell.server"
WEB_LABEL="com.opsx.shell.web"
@@ -39,6 +40,36 @@ SERVER_LOG="$LOG_DIR/server.log"
WEB_LOG="$LOG_DIR/web.log"
DESKTOP_LOG="$LOG_DIR/desktop.log"
# shellcheck source=gui-dev-app.sh
source "$SCRIPT_DIR/scripts/gui-dev-app.sh"
OPSX_CLEAN_SCRIPT="${OPSX_CLEAN_SCRIPT:-$HOME/devops/scripts/clean-opsx-apps.sh}"
# gui 启动前轻量清:推残留 DMG + 注销非 /Applications、非 keep-path 的幽灵。
# 不删 target、不 ResetLaunchPad / kill Dock。逻辑在 clean-opsx-apps.sh --light。
opsx_light_clean_before_gui() {
local keep="$1"
if [ "$(uname -s)" != "Darwin" ]; then
return 0
fi
if [ ! -x "$OPSX_CLEAN_SCRIPT" ]; then
warning "找不到清理脚本: $OPSX_CLEAN_SCRIPT(跳过轻量清)"
return 0
fi
info "gui light-clean (keep-path=${keep})..."
"$OPSX_CLEAN_SCRIPT" --light --keep-path="$keep" --no-verify \
|| warning "轻量清未完全成功(继续启动)"
}
run_clean_apps() {
if [ ! -x "$OPSX_CLEAN_SCRIPT" ]; then
error "找不到: $OPSX_CLEAN_SCRIPT"
return 1
fi
# 转发剩余参数(如 --delete-target-apps);默认 full
"$OPSX_CLEAN_SCRIPT" "$@"
}
# Same path as src-tauri infrastructure/file_log.rs (dirs::data_local_dir).
if [ "$(uname -s)" = "Darwin" ]; then
APP_LOG="$HOME/Library/Application Support/opsxshell/logs/opsxshell.log"
@@ -174,14 +205,14 @@ start_vite_for_desktop() {
success "桌面 UI(Vite) 已在运行 :$WEB_PORT"
return 0
fi
info "启动桌面 UI 源 :$WEB_PORT(仅本机给 Tauri,勿当浏览器客户端)..."
info "启动桌面 UI 源 :${WEB_PORT}(仅本机给 Tauri,勿当浏览器客户端)..."
: >"$WEB_LOG"
ensure_npm
kill_port "$WEB_PORT"
start_detached "$WEB_LABEL" "$WEB_LOG" \
"export PATH=\"$NODE_BIN_DIR:/opt/homebrew/bin:/usr/local/bin:\$PATH\"; cd \"$SCRIPT_DIR\" && exec npm run dev:ui"
wait_http "http://127.0.0.1:$WEB_PORT/" "Vite" 80
success "桌面 UI(Vite) UP http://127.0.0.1:$WEB_PORT(请用 ./run.sh gui)"
success "桌面 UI(Vite) UP http://127.0.0.1:${WEB_PORT}(请用 ./run.sh gui)"
}
stop_web() {
@@ -191,32 +222,26 @@ stop_web() {
}
start_desktop() {
info "启动桌面 OpsXShell ..."
opsx_light_clean_before_gui "$GUI_APP"
info "启动桌面 OpsxShell(临时 .app + 当前图标)..."
: >"$DESKTOP_LOG"
ensure_npm
# 清理旧进程
pkill -f 'target/debug/opsxshell' 2>/dev/null || true
pkill -f 'target/debug/OpsXShell' 2>/dev/null || true
stop_detached "$DESKTOP_LABEL"
# tauri dev 会自己起 Vite;detached 跑 npm run dev
start_detached "$DESKTOP_LABEL" "$DESKTOP_LOG" \
"export PATH=\"$NODE_BIN_DIR:/opt/homebrew/bin:/usr/local/bin:\$HOME/.cargo/bin:\$PATH\"; cd \"$SCRIPT_DIR\" && exec npm run dev"
kill_opsxshell_gui
ensure_gui_dev_app || return 1
if [ "${GUI_DEV_NEEDS_VITE:-0}" = "1" ]; then
start_vite_for_desktop
fi
open "$GUI_APP" 2>>"$DESKTOP_LOG" || { error "open 失败,见 $DESKTOP_LOG"; return 1; }
local i=0
while true; do
if pgrep -f 'target/debug/opsxshell' >/dev/null 2>&1 \
|| pgrep -f 'target/debug/OpsXShell' >/dev/null 2>&1; then
success "桌面 OpsXShell 已启动"
info "应用日志: tail -f \"$APP_LOG\""
if gui_is_running; then
success "桌面 OpsxShell 已启动(临时 .app,Dock 用 icon.icns / 名称 OpsxShell)"
info "路径: $GUI_APP"
return 0
fi
if grep -Eiq 'error:|panicked|could not compile' "$DESKTOP_LOG" 2>/dev/null; then
error "桌面启动失败,见 $DESKTOP_LOG"
tail -n 40 "$DESKTOP_LOG" || true
return 1
fi
i=$((i + 1))
if [ "$i" -ge 180 ]; then
if [ "$i" -ge 30 ]; then
error "桌面启动超时,见 $DESKTOP_LOG"
tail -n 40 "$DESKTOP_LOG" || true
return 1
@@ -226,10 +251,7 @@ start_desktop() {
}
stop_desktop() {
stop_detached "$DESKTOP_LABEL"
pkill -f 'target/debug/opsxshell' 2>/dev/null || true
pkill -f 'target/debug/OpsXShell' 2>/dev/null || true
pkill -f 'node_modules/.bin/tauri' 2>/dev/null || true
kill_opsxshell_gui
success "桌面已停止"
}
@@ -241,7 +263,7 @@ status() {
warning "server :$SERVER_PORT DOWN"
fi
if curl -fsS "http://127.0.0.1:$WEB_PORT/" >/dev/null 2>&1; then
success "vite :$WEB_PORT UP(桌面源,非浏览器产品)"
success "vite :${WEB_PORT} UP(桌面源,非浏览器产品)"
else
warning "vite :$WEB_PORT DOWN"
fi
@@ -249,11 +271,10 @@ status() {
|| curl -fsS "http://127.0.0.1:$SERVER_PORT/docs" >/dev/null 2>&1; then
success "site :$SERVER_PORT 官网/docs 可达"
fi
if pgrep -f 'target/debug/opsxshell' >/dev/null 2>&1 \
|| pgrep -f 'target/debug/OpsXShell' >/dev/null 2>&1; then
success "gui OpsXShell UP"
if gui_is_running; then
success "gui OpsxShell UP"
else
warning "gui OpsXShell DOWN"
warning "gui OpsxShell DOWN"
fi
}
@@ -263,14 +284,15 @@ $PROJECT_NAME 启动脚本(产品形态:浏览器=官网/docs · 操作=桌
./run.sh # 同 web
./run.sh web # 仅 Gin:官网 + docs → http://127.0.0.1:$SERVER_PORT/
./run.sh gui # 桌面唯一操作入口(Tauri;默认也起 Gin)
./run.sh gui # 桌面:临时 .app(Dock=OpsxShell / icon.icns;默认也起 Gin)
./run.sh all # 同 gui(兼容旧名)
./run.sh server # 只 Gin(官网/docs)
./run.sh desktop # 只 Desktop
./run.sh stop | restart | status | help
./run.sh clean-apps # 全量开发机卫生(默认只注销不删 target)
端口: Gin/官网 $SERVER_PORT · 桌面 Vite 源 $WEB_PORT(不对外当客户端)
端口: Gin/官网 $SERVER_PORT · 桌面 Vite 源 ${WEB_PORT}(不对外当客户端)
日志: logs/{server,web,desktop}.log · 应用日志见 $APP_LOG
USAGE
}
@@ -291,7 +313,7 @@ start_gui_scene() {
fi
start_desktop
echo
success "GUI 场景就绪 → 桌面窗口 OpsXShell"
success "GUI 场景就绪 → 桌面窗口 OpsxShell"
}
start_all_scene() {
@@ -321,6 +343,7 @@ case "$cmd" in
start_web_scene
;;
status) status ;;
clean-apps) run_clean_apps "${@:2}" ;;
help|-h|--help) usage ;;
*) error "未知命令: $cmd"; usage; exit 1 ;;
esac