优化pc版本首页

This commit is contained in:
yml2213
2026-05-29 08:59:05 +08:00
parent 56216c7523
commit 72f7d504d1
4 changed files with 805 additions and 412 deletions
-1
View File
@@ -20,7 +20,6 @@ const router = useRouter();
const navItems = [ const navItems = [
{ label: "首页", to: "/", icon: House }, { label: "首页", to: "/", icon: House },
{ label: "租号大厅", to: "/listings", icon: Shop },
{ label: "我的订单", to: "/orders", icon: Tickets }, { label: "我的订单", to: "/orders", icon: Tickets },
{ label: "消息", to: "/messages", icon: ChatDotRound }, { label: "消息", to: "/messages", icon: ChatDotRound },
{ label: "钱包", to: "/wallet", icon: Wallet }, { label: "钱包", to: "/wallet", icon: Wallet },
-5
View File
@@ -6,11 +6,6 @@ export const publicRoutes: RouteRecordRaw[] = [
name: 'home', name: 'home',
component: () => import('@/views/public/HomeView.vue'), component: () => import('@/views/public/HomeView.vue'),
}, },
{
path: '/listings',
name: 'listings',
component: () => import('@/views/public/ListingsView.vue'),
},
{ {
path: '/listings/:id', path: '/listings/:id',
name: 'listing-detail', name: 'listing-detail',
File diff suppressed because it is too large Load Diff
+76 -5
View File
@@ -5,6 +5,11 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
COMPOSE_FILE="${ROOT_DIR}/deploy/docker-compose.dev.yml" COMPOSE_FILE="${ROOT_DIR}/deploy/docker-compose.dev.yml"
BACKEND_ENV="${ROOT_DIR}/backend/.env" BACKEND_ENV="${ROOT_DIR}/backend/.env"
BACKEND_ENV_EXAMPLE="${ROOT_DIR}/backend/.env.example" BACKEND_ENV_EXAMPLE="${ROOT_DIR}/backend/.env.example"
BACKEND_PORT="${DEV_BACKEND_PORT:-8080}"
FRONTEND_PORT="${DEV_FRONTEND_PORT:-5173}"
BACKEND_HEALTH_URL="${DEV_BACKEND_HEALTH_URL:-http://127.0.0.1:${BACKEND_PORT}/health}"
FRONTEND_HEALTH_URL="${DEV_FRONTEND_HEALTH_URL:-http://127.0.0.1:${FRONTEND_PORT}/}"
HTTP_READY_TIMEOUT="${DEV_HTTP_READY_TIMEOUT:-120}"
BACKEND_PID="" BACKEND_PID=""
FRONTEND_PID="" FRONTEND_PID=""
@@ -53,6 +58,16 @@ show_help() {
环境变量: 环境变量:
DEV_RESET_DB=1 等同于 --reset-db DEV_RESET_DB=1 等同于 --reset-db
DEV_BACKEND_PORT=8080
后端端口占用检查端口
DEV_FRONTEND_PORT=5173
前端端口占用检查端口
DEV_BACKEND_HEALTH_URL=http://127.0.0.1:8080/health
后端健康检查地址
DEV_FRONTEND_HEALTH_URL=http://127.0.0.1:5173/
前端健康检查地址
DEV_HTTP_READY_TIMEOUT=120
HTTP 服务就绪等待秒数
示例: 示例:
./scripts/dev.sh # 正常启动 ./scripts/dev.sh # 正常启动
@@ -135,6 +150,55 @@ wait_container_healthy() {
exit 1 exit 1
} }
wait_http_ready() {
local url="$1"
local label="$2"
local pid="${3:-}"
local attempt
log "等待 ${label} HTTP 服务就绪..."
for ((attempt = 1; attempt <= HTTP_READY_TIMEOUT; attempt++)); do
if [[ -n "${pid}" ]] && ! kill -0 "${pid}" >/dev/null 2>&1; then
wait "${pid}" || true
log_error "${label} 进程已退出,请检查上方日志"
exit 1
fi
if curl -fsS --max-time 2 "${url}" >/dev/null 2>&1; then
log_success "${label} 已就绪:${url}"
return 0
fi
sleep 1
done
log_error "${label} HTTP 服务启动超时:${url}"
exit 1
}
ensure_port_free() {
local port="$1"
local label="$2"
if command -v lsof >/dev/null 2>&1; then
if lsof -nP -iTCP:"${port}" -sTCP:LISTEN >/dev/null 2>&1; then
log_error "${label}端口 ${port} 已被占用,请先停止旧进程或调整端口"
exit 1
fi
return 0
fi
if command -v nc >/dev/null 2>&1; then
if nc -z 127.0.0.1 "${port}" >/dev/null 2>&1; then
log_error "${label}端口 ${port} 已被占用,请先停止旧进程或调整端口"
exit 1
fi
return 0
fi
log_warn "未找到 lsof 或 nc,跳过 ${label}端口 ${port} 占用检查"
}
mysql_root() { mysql_root() {
docker exec -i -e MYSQL_PWD=rootsecret hfb-mysql mysql -uroot "$@" docker exec -i -e MYSQL_PWD=rootsecret hfb-mysql mysql -uroot "$@"
} }
@@ -240,6 +304,9 @@ main() {
if [[ "${SEED_ONLY}" != "1" && "${NO_FRONTEND}" == "0" ]]; then if [[ "${SEED_ONLY}" != "1" && "${NO_FRONTEND}" == "0" ]]; then
need_cmd npm need_cmd npm
fi fi
if [[ "${SEED_ONLY}" != "1" && ( "${NO_BACKEND}" == "0" || "${NO_FRONTEND}" == "0" ) ]]; then
need_cmd curl
fi
trap cleanup EXIT trap cleanup EXIT
trap 'cleanup; exit 130' INT TERM trap 'cleanup; exit 130' INT TERM
@@ -260,11 +327,20 @@ main() {
fi fi
if [[ "${NO_BACKEND}" == "0" ]]; then if [[ "${NO_BACKEND}" == "0" ]]; then
ensure_port_free "${BACKEND_PORT}" "后端"
start_backend start_backend
wait_http_ready "${BACKEND_HEALTH_URL}" "后端" "${BACKEND_PID}"
fi fi
if [[ "${NO_FRONTEND}" == "0" ]]; then if [[ "${NO_FRONTEND}" == "0" ]]; then
ensure_port_free "${FRONTEND_PORT}" "前端"
start_frontend start_frontend
wait_http_ready "${FRONTEND_HEALTH_URL}" "前端" "${FRONTEND_PID}"
fi
if [[ -z "${BACKEND_PID}" && -z "${FRONTEND_PID}" ]]; then
log "仅启动 Docker 开发依赖,前后端未启动"
return 0
fi fi
log_success "开发环境已启动" log_success "开发环境已启动"
@@ -273,11 +349,6 @@ main() {
log "后台:http://localhost:5173/admin/loginadmin / admin123456" log "后台:http://localhost:5173/admin/loginadmin / admin123456"
fi fi
if [[ -z "${BACKEND_PID}" && -z "${FRONTEND_PID}" ]]; then
log "仅启动 Docker 开发依赖,前后端未启动"
return 0
fi
log "按 Ctrl+C 停止前后端;Docker 依赖会保留运行" log "按 Ctrl+C 停止前后端;Docker 依赖会保留运行"
watch_processes watch_processes