diff --git a/apps/user/.env.example b/apps/user/.env.example index 250f86e..40d7adc 100644 --- a/apps/user/.env.example +++ b/apps/user/.env.example @@ -9,6 +9,10 @@ VITE_CDN_URL=https://cdn.jsdmirror.com # Enable tutorial document feature (true/false) VITE_TUTORIAL_DOCUMENT=true +# Show landing page on home route (true/false, default: true) +# When set to false, users will be redirected to login page directly +VITE_SHOW_LANDING_PAGE=true + # Default login credentials (for development only) VITE_USER_EMAIL= VITE_USER_PASSWORD= diff --git a/apps/user/src/sections/main/index.tsx b/apps/user/src/sections/main/index.tsx index d90c619..49be4bd 100644 --- a/apps/user/src/sections/main/index.tsx +++ b/apps/user/src/sections/main/index.tsx @@ -10,11 +10,20 @@ export default function Main() { const { user } = useGlobalStore(); const navigate = useNavigate(); + const showLanding = import.meta.env.VITE_SHOW_LANDING_PAGE !== "false"; + useEffect(() => { if (user) { navigate({ to: "/dashboard" }); + return; } - }, [user, navigate]); + + if (!showLanding) { + navigate({ to: "/auth" }); + } + }, [user, navigate, showLanding]); + + if (!showLanding) return null; return (
diff --git a/docs/guide/separation/frontend.md b/docs/guide/separation/frontend.md index 8259af9..ca64fe6 100644 --- a/docs/guide/separation/frontend.md +++ b/docs/guide/separation/frontend.md @@ -99,6 +99,9 @@ VITE_CDN_URL=https://cdn.jsdmirror.com # Enable tutorial documentation (optional) VITE_TUTORIAL_DOCUMENT=true +# Show landing page (optional, set to false to redirect to login directly) +VITE_SHOW_LANDING_PAGE=true + # Development default credentials (leave empty in production) VITE_USER_EMAIL= VITE_USER_PASSWORD= @@ -461,6 +464,7 @@ sudo systemctl enable caddy | `VITE_API_BASE_URL` | Backend API address | ✅ | - | `https://api.your-domain.com` | | `VITE_CDN_URL` | CDN address | ❌ | `https://cdn.jsdmirror.com` | `https://cdn.your-domain.com` | | `VITE_TUTORIAL_DOCUMENT` | Enable tutorial docs | ❌ | `true` | `true` / `false` | +| `VITE_SHOW_LANDING_PAGE` | Show landing page | ❌ | `true` | `true` / `false` | | `VITE_USER_EMAIL` | Default login email (dev only) | ❌ | - | - | | `VITE_USER_PASSWORD` | Default login password (dev only) | ❌ | - | - | diff --git a/docs/zh/guide/separation/frontend.md b/docs/zh/guide/separation/frontend.md index 24a3ff0..ad2e3a7 100644 --- a/docs/zh/guide/separation/frontend.md +++ b/docs/zh/guide/separation/frontend.md @@ -116,6 +116,9 @@ VITE_CDN_URL=https://cdn.jsdmirror.com # 启用教程文档(可选) VITE_TUTORIAL_DOCUMENT=true +# 显示落地页(可选,设为 false 则直接跳转登录页) +VITE_SHOW_LANDING_PAGE=true + # 开发环境默认登录凭证(生产环境请留空) VITE_USER_EMAIL= VITE_USER_PASSWORD= @@ -461,6 +464,7 @@ sudo systemctl enable caddy | `VITE_API_BASE_URL` | 后端 API 地址 | ✅ | - | `https://api.your-domain.com` | | `VITE_CDN_URL` | CDN 地址 | ❌ | `https://cdn.jsdmirror.com` | `https://cdn.your-domain.com` | | `VITE_TUTORIAL_DOCUMENT` | 启用教程文档 | ❌ | `true` | `true` / `false` | +| `VITE_SHOW_LANDING_PAGE` | 显示落地页 | ❌ | `true` | `true` / `false` | | `VITE_USER_EMAIL` | 默认登录邮箱(仅开发) | ❌ | - | - | | `VITE_USER_PASSWORD` | 默认登录密码(仅开发) | ❌ | - | - |