feat: 添加安装向导功能

- 后端:安装状态检测API、数据库连接测试、配置文件生成
- 后端:支持SQLite/MySQL数据库选择
- 后端:JWT密钥自动生成或手动设置
- 前端:安装向导界面(数据库配置、安全配置、管理员账号)
- 前端:路由守卫检测安装状态,未安装自动跳转安装页面
This commit is contained in:
2026-05-03 11:52:34 +08:00
parent 507e00df52
commit 41fe48e128
8 changed files with 880 additions and 27 deletions
+29 -1
View File
@@ -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')