feat: 支持数据库运行时配置与多数据库,重构设置页并完善打包

- 数据库支持 SQLite / MySQL 运行时配置与切换,未配置时仍可启动,配置后自动建表
- 新增默认分类与标签初始化,注册用户自动创建
- 新增注册开关(默认关闭,可在系统设置开启;无用户时允许创建首个账号)
- 合并数据库、注册与 AI 配置为「系统设置」页,拆分「模型使用情况」独立页面
- AI 一键设置支持新建分类与标签
- 前端构建产物打包进可执行 jar,后端增加 SPA 路由回退
- jar 更名为 finance-app,补全 Gradle Wrapper,移除 archive 任务
- 更新 DeepSeek 模型说明文案
This commit is contained in:
2026-09-18 12:33:41 +08:00
parent 16e4c30456
commit c1f5d02564
63 changed files with 3783 additions and 573 deletions
+52 -5
View File
@@ -1,11 +1,18 @@
// 路由配置文件:定义应用的所有路由及导航守卫
import { createRouter, createWebHistory } from 'vue-router'
import { useUserStore } from '../store/user'
import { useDatabaseStore } from '../store/database'
import { useRegistrationStore } from '../store/registration'
// 创建路由实例,使用 HTML5 History 模式
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/database-setup',
name: 'DatabaseSetup',
component: () => import('../views/DatabaseSettings.vue'), // 首次数据库配置引导页(无需登录)
},
{
path: '/login',
name: 'Login',
@@ -42,17 +49,57 @@ const router = createRouter({
component: () => import('../views/TagManage.vue'), // 标签管理
},
{
path: 'ai-settings',
name: 'AiSettings',
component: () => import('../views/AiSettings.vue'), // AI 设置
path: 'settings',
name: 'Settings',
component: () => import('../views/Settings.vue'), // 系统设置(数据库 + AI 模型)
},
{
path: 'ai-usage',
name: 'AiUsage',
component: () => import('../views/AiUsage.vue'), // 模型使用情况
},
],
},
],
})
// 全局前置守卫:未登录时拦截跳转至登录页
router.beforeEach((to, _from, next) => {
// 全局前置守卫:优先校验数据库配置,再校验登录状态
router.beforeEach(async (to, _from, next) => {
const databaseStore = useDatabaseStore()
// 首次进入时从后端加载数据库配置状态
if (!databaseStore.loaded) {
await databaseStore.load()
}
// 数据库未配置:强制引导到配置页,避免用户卡在无法登录的状态
if (!databaseStore.configured) {
if (to.path === '/database-setup') {
next()
} else {
next('/database-setup')
}
return
}
// 已配置数据库:配置引导页不再需要,跳转到登录或首页
if (to.path === '/database-setup') {
const userStore = useUserStore()
next(userStore.token ? '/dashboard' : '/login')
return
}
// 注册功能关闭且已有用户时,不允许访问注册页
if (to.path === '/register') {
const registrationStore = useRegistrationStore()
if (!registrationStore.loaded) {
await registrationStore.load()
}
if (!registrationStore.status?.allowed) {
next('/login')
return
}
}
const userStore = useUserStore()
// 如果目标页面不是登录/注册页,且没有 token,则重定向到登录页
if (to.path !== '/login' && to.path !== '/register' && !userStore.token) {