feat(web): 初始化前端基础架构和样式
- 新增.gitignore,忽略日志、node_modules、dist及编辑器配置文件 - 创建基础React应用及组件App,集成React、Vite和样式 - 设计响应式CSS变量和全局样式,支持暗黑模式 - 新增图标SVG符号定义,用于社交及文档链接展示 - 配置TypeScript项目(tsconfig)和ESLint规则保障代码质量 - 配置Vite开发服务器,支持代理接口与模块别名 - 增加前端API客户端封装与健康检查接口定义 - 增加类型定义文件,映射后端数据模型接口 - 创建index.html作为前端入口页面 - 新增package.json定义依赖和运行脚本,包含React及Ant Design等库
This commit is contained in:
@@ -5,10 +5,11 @@ import (
|
||||
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
"synoth.com/janus/internal/model"
|
||||
)
|
||||
|
||||
// DatabaseConfig
|
||||
type DatabaseConfig struct {
|
||||
// Config 数据库配置
|
||||
type Config struct {
|
||||
Host string
|
||||
Port int
|
||||
Username string
|
||||
@@ -17,7 +18,8 @@ type DatabaseConfig struct {
|
||||
SSLMode string
|
||||
}
|
||||
|
||||
func Connect(cfg DatabaseConfig) (*gorm.DB, error) {
|
||||
// Connect 连接数据库
|
||||
func Connect(cfg Config) (*gorm.DB, error) {
|
||||
dsn := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s",
|
||||
cfg.Host, cfg.Port, cfg.Username, cfg.Password, cfg.DBName, cfg.SSLMode,
|
||||
)
|
||||
@@ -29,3 +31,8 @@ func Connect(cfg DatabaseConfig) (*gorm.DB, error) {
|
||||
|
||||
return db, nil
|
||||
}
|
||||
|
||||
// AutoMigrate 自动迁移数据库表结构
|
||||
func AutoMigrate(db *gorm.DB) error {
|
||||
return db.AutoMigrate(&model.Provider{}, &model.APIKey{}, &model.Channel{}, &model.Model{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user