fix: 添加安装路由,修复环境变量校验和路由守卫

- 注册/install路由,安装向导页面可访问
- env.ts: VITE_SERVER_API_URL默认空字符串(相对路径)
- 路由守卫: API失败时默认跳转安装页面
This commit is contained in:
2026-05-03 15:40:23 +08:00
parent 802fd7319e
commit 3153dd8838
3 changed files with 14 additions and 7 deletions
+3 -3
View File
@@ -8,14 +8,14 @@ async function checkInstallStatus(): Promise<boolean> {
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
}
}
+9
View File
@@ -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',
+2 -4
View File
@@ -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),
})