Files
ai-agent/internal/bootstrap/init.go
T
mlogclub f827a7471c refactor: remove LocaleSwitcher component and update locale handling
- Removed LocaleSwitcher from NavUser, SiteHeader, and WorkbenchHeader components.
- Updated tests to reflect the removal of LocaleSwitcher.
- Changed default locale from "en-US" to "zh-CN" in i18n configuration.
- Refactored locale resolution logic to read configured locale without relying on browser language detection.
- Updated AgentDesk SDK to support language configuration from public API.
- Cleaned up unused auth options fetching in the auth API.
2026-06-26 14:46:01 +08:00

55 lines
1.2 KiB
Go

package bootstrap
import (
"agent-desk/internal/ai/rag/vectordb"
"agent-desk/internal/oidcclient"
"agent-desk/internal/pkg/config"
"agent-desk/internal/pkg/i18nx"
"agent-desk/internal/pkg/logx"
"agent-desk/internal/services/cronx"
"agent-desk/internal/wxwork"
"context"
"log/slog"
_ "agent-desk/internal/services/event_handlers"
)
func Init(configPath string) error {
cfg, err := config.Load(configPath)
if err != nil {
slog.Error("init config failed", "error", err)
return err
}
config.SetCurrent(cfg)
i18nx.SetDefaultLocale(cfg.LanguageOrDefault())
logx.Init(logx.Config{
Level: cfg.Logger.Level,
Format: cfg.Logger.Format,
AddSource: cfg.Logger.AddSource,
})
if _, err := InitDB(cfg.DB); err != nil {
slog.Error("init db failed", "error", err)
return err
}
if err := InitMigrations(); err != nil {
slog.Error("init migrations failed", "error", err)
return err
}
if err := vectordb.Init(&cfg.VectorDB); err != nil {
slog.Error("init vector db failed", "error", err)
return err
}
// 启动任务调度器
cronx.Init()
wxwork.Init()
if err := oidcclient.Init(context.Background()); err != nil {
slog.Error("init oidc failed", "error", err)
return err
}
return nil
}