From 3153dd883895890fef82b30508772bf2e294bf0c Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 3 May 2026 15:40:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E6=A0=A1=E9=AA=8C=E5=92=8C=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=AE=88=E5=8D=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 注册/install路由,安装向导页面可访问 - env.ts: VITE_SERVER_API_URL默认空字符串(相对路径) - 路由守卫: API失败时默认跳转安装页面 --- frontend/src/router/guard/index.ts | 6 +++--- frontend/src/router/routes.ts | 9 +++++++++ frontend/src/utils/env.ts | 6 ++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/frontend/src/router/guard/index.ts b/frontend/src/router/guard/index.ts index efd9f11..d53eb65 100644 --- a/frontend/src/router/guard/index.ts +++ b/frontend/src/router/guard/index.ts @@ -8,14 +8,14 @@ async function checkInstallStatus(): Promise { try { const res = await fetch('/api/install/status') const data = await res.json() - isInstalled = data?.data?.installed || false + isInstalled = data?.data?.installed ?? false installChecked = true return isInstalled } catch { installChecked = true - isInstalled = true - return true + isInstalled = false + return false } } diff --git a/frontend/src/router/routes.ts b/frontend/src/router/routes.ts index e44bed6..72e0557 100644 --- a/frontend/src/router/routes.ts +++ b/frontend/src/router/routes.ts @@ -1,6 +1,15 @@ import type { RouteRecordRaw } from 'vue-router' const routes: RouteRecordRaw[] = [ + { + path: '/install', + name: 'Install', + component: () => import('@/pages/install/index.vue'), + meta: { + title: '安装 - 管理平台', + layout: false, + }, + }, { path: '/', redirect: '/login', diff --git a/frontend/src/utils/env.ts b/frontend/src/utils/env.ts index bc8ef1e..d7fa747 100644 --- a/frontend/src/utils/env.ts +++ b/frontend/src/utils/env.ts @@ -9,10 +9,8 @@ import { z } from 'zod' */ const EnvSchema = z.object({ - // Add your environment variables here, for example: - // VITE_API_BASE_URL: z.string().url(), - VITE_SERVER_API_URL: z.url(), - VITE_SERVER_API_PREFIX: z.string(), + VITE_SERVER_API_URL: z.string().default(''), + VITE_SERVER_API_PREFIX: z.string().default('/api'), VITE_SERVER_API_TIMEOUT: z.coerce.number().default(5000), })