fix: 添加安装路由,修复环境变量校验和路由守卫
- 注册/install路由,安装向导页面可访问 - env.ts: VITE_SERVER_API_URL默认空字符串(相对路径) - 路由守卫: API失败时默认跳转安装页面
This commit is contained in:
@@ -8,14 +8,14 @@ async function checkInstallStatus(): Promise<boolean> {
|
|||||||
try {
|
try {
|
||||||
const res = await fetch('/api/install/status')
|
const res = await fetch('/api/install/status')
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
isInstalled = data?.data?.installed || false
|
isInstalled = data?.data?.installed ?? false
|
||||||
installChecked = true
|
installChecked = true
|
||||||
return isInstalled
|
return isInstalled
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
installChecked = true
|
installChecked = true
|
||||||
isInstalled = true
|
isInstalled = false
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
import type { RouteRecordRaw } from 'vue-router'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
|
|
||||||
const routes: RouteRecordRaw[] = [
|
const routes: RouteRecordRaw[] = [
|
||||||
|
{
|
||||||
|
path: '/install',
|
||||||
|
name: 'Install',
|
||||||
|
component: () => import('@/pages/install/index.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '安装 - 管理平台',
|
||||||
|
layout: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
redirect: '/login',
|
redirect: '/login',
|
||||||
|
|||||||
@@ -9,10 +9,8 @@ import { z } from 'zod'
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const EnvSchema = z.object({
|
const EnvSchema = z.object({
|
||||||
// Add your environment variables here, for example:
|
VITE_SERVER_API_URL: z.string().default(''),
|
||||||
// VITE_API_BASE_URL: z.string().url(),
|
VITE_SERVER_API_PREFIX: z.string().default('/api'),
|
||||||
VITE_SERVER_API_URL: z.url(),
|
|
||||||
VITE_SERVER_API_PREFIX: z.string(),
|
|
||||||
VITE_SERVER_API_TIMEOUT: z.coerce.number().default(5000),
|
VITE_SERVER_API_TIMEOUT: z.coerce.number().default(5000),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user