fix: JWT密钥同步、地图初始化时序、API中间件错误处理
- 修复安装完成后JWT密钥未同步到viper内存的问题 - 修复地图在loading状态时DOM元素不存在导致的初始化错误 - 修复AppCryptoMiddleware中数据库错误时未正确返回错误响应的问题 - 添加数据库未初始化检查 - 移除调试日志输出
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/glebarez/sqlite"
|
||||
"github.com/spf13/viper"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
@@ -232,6 +233,16 @@ func handleSetup(c *gin.Context) {
|
||||
log.Printf("Warning: failed to save config file: %v", err)
|
||||
}
|
||||
|
||||
viper.Set("app.jwt_secret", jwtSecret)
|
||||
viper.Set("database.type", req.DbType)
|
||||
if req.DbType == "mysql" {
|
||||
viper.Set("database.host", req.DbHost)
|
||||
viper.Set("database.port", req.DbPort)
|
||||
viper.Set("database.name", req.DbName)
|
||||
viper.Set("database.username", req.DbUsername)
|
||||
viper.Set("database.password", req.DbPassword)
|
||||
}
|
||||
|
||||
database.DB = newDB
|
||||
|
||||
response.Success(c, gin.H{
|
||||
|
||||
Reference in New Issue
Block a user