feat: 添加安装向导功能
- 后端:安装状态检测API、数据库连接测试、配置文件生成 - 后端:支持SQLite/MySQL数据库选择 - 后端:JWT密钥自动生成或手动设置 - 前端:安装向导界面(数据库配置、安全配置、管理员账号) - 前端:路由守卫检测安装状态,未安装自动跳转安装页面
This commit is contained in:
@@ -1,7 +1,35 @@
|
||||
import type { Router } from 'vue-router'
|
||||
|
||||
let installChecked = false
|
||||
let isInstalled = false
|
||||
|
||||
async function checkInstallStatus(): Promise<boolean> {
|
||||
if (installChecked) return isInstalled
|
||||
try {
|
||||
const res = await fetch('/api/install/status')
|
||||
const data = await res.json()
|
||||
isInstalled = data?.data?.installed || false
|
||||
installChecked = true
|
||||
return isInstalled
|
||||
}
|
||||
catch {
|
||||
installChecked = true
|
||||
isInstalled = true
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
export function createRouterGuard(router: Router) {
|
||||
router.beforeEach((to) => {
|
||||
router.beforeEach(async (to) => {
|
||||
if (to.path === '/install') {
|
||||
return true
|
||||
}
|
||||
|
||||
const installed = await checkInstallStatus()
|
||||
if (!installed) {
|
||||
return '/install'
|
||||
}
|
||||
|
||||
const token = localStorage.getItem('token')
|
||||
const userStr = localStorage.getItem('user')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user