feat: 支持数据库运行时配置与多数据库,重构设置页并完善打包
- 数据库支持 SQLite / MySQL 运行时配置与切换,未配置时仍可启动,配置后自动建表 - 新增默认分类与标签初始化,注册用户自动创建 - 新增注册开关(默认关闭,可在系统设置开启;无用户时允许创建首个账号) - 合并数据库、注册与 AI 配置为「系统设置」页,拆分「模型使用情况」独立页面 - AI 一键设置支持新建分类与标签 - 前端构建产物打包进可执行 jar,后端增加 SPA 路由回退 - jar 更名为 finance-app,补全 Gradle Wrapper,移除 archive 任务 - 更新 DeepSeek 模型说明文案
This commit is contained in:
+39
-17
@@ -31,6 +31,8 @@ dependencies {
|
||||
implementation 'com.baomidou:mybatis-plus-spring-boot3-starter:3.5.12'
|
||||
implementation 'com.baomidou:mybatis-plus-jsqlparser:3.5.12'
|
||||
runtimeOnly 'com.mysql:mysql-connector-j'
|
||||
// SQLite 驱动,用于本地文件数据库
|
||||
runtimeOnly 'org.xerial:sqlite-jdbc:3.46.1.3'
|
||||
|
||||
implementation 'com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:4.5.0'
|
||||
|
||||
@@ -54,24 +56,44 @@ tasks.named('test') {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
// ===== 前端构建与打包 =====
|
||||
def frontendDir = file("${projectDir}/frontend")
|
||||
def frontendDistDir = file("${frontendDir}/dist")
|
||||
|
||||
task archive(type: Tar) {
|
||||
def timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
|
||||
archiveFileName = "finance-app-${version}-${timestamp}.tar.gz"
|
||||
destinationDirectory = file("${projectDir}/distributions")
|
||||
compression = Compression.GZIP
|
||||
// 解析 npm 可执行文件:优先使用 NODE_HOME,其次使用 PATH 中的 npm
|
||||
def resolveNpm = {
|
||||
def nodeHome = System.getenv('NODE_HOME')
|
||||
return nodeHome ? "${nodeHome}/bin/npm" : 'npm'
|
||||
}
|
||||
|
||||
from(projectDir) {
|
||||
exclude 'build/**'
|
||||
exclude '.gradle/**'
|
||||
exclude 'distributions/**'
|
||||
exclude 'frontend/node_modules/**'
|
||||
exclude 'frontend/node_modules*/**'
|
||||
exclude 'frontend/node_modules*.zip'
|
||||
exclude 'frontend/dist/**'
|
||||
exclude '**/*.log'
|
||||
exclude 'logs/**'
|
||||
// 安装前端依赖(node_modules 存在且 package.json 未变化时自动跳过)
|
||||
tasks.register('npmInstall', Exec) {
|
||||
group = 'frontend'
|
||||
description = '安装前端依赖'
|
||||
workingDir frontendDir
|
||||
commandLine resolveNpm(), 'install'
|
||||
inputs.file("${frontendDir}/package.json")
|
||||
outputs.dir("${frontendDir}/node_modules")
|
||||
}
|
||||
|
||||
// 构建前端产物
|
||||
tasks.register('frontendBuild', Exec) {
|
||||
group = 'frontend'
|
||||
description = '构建前端产物(npm run build)'
|
||||
dependsOn 'npmInstall'
|
||||
workingDir frontendDir
|
||||
commandLine resolveNpm(), 'run', 'build'
|
||||
inputs.dir("${frontendDir}/src")
|
||||
inputs.file("${frontendDir}/package.json")
|
||||
inputs.file("${frontendDir}/index.html")
|
||||
inputs.file("${frontendDir}/vite.config.ts")
|
||||
outputs.dir(frontendDistDir)
|
||||
}
|
||||
|
||||
// 将前端产物打入可执行 jar 的静态资源目录,实现前后端一体化部署
|
||||
tasks.named('bootJar') {
|
||||
dependsOn 'frontendBuild'
|
||||
from(frontendDistDir) {
|
||||
into 'BOOT-INF/classes/static'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user