Files
gochat/backend/internal/model/widget_theme_config.go
T
rogee aeddedf2a3 Reorganize repo: backend/, deploy/, docs/ layout + AGENTS.md
Restructure the monorepo into clear top-level directories:
- backend/: Go module root (cmd, internal, pkg, configs, migrations,
  docs/swagger, scripts, tests, go.mod, Makefile, .air.toml)
- deploy/: Docker (Dockerfile, docker-compose*), quickstart, fluentd
- docs/: project documentation + reports/ (moved from repo root)
- AGENTS.md: new AI coding-agent guide at repo root

Update all references to the new layout:
- Dockerfile: COPY backend/go.mod, COPY backend/ (context = repo root)
- docker-compose files: context ../.., dockerfile deploy/docker/Dockerfile,
  env_file ../../.env, volume mounts ../../backend:/app
- deploy/quickstart/compose.yaml: dockerfile deploy/docker/Dockerfile
- CI: working-directory: backend for go commands, file deploy/docker/Dockerfile,
  coverage path backend/coverage.out, health_check backend/scripts/
- backend/Makefile: docker target uses -f ../deploy/docker/Dockerfile ../
- README: architecture tree, quickstart, config paths updated

Move root stray scripts (rename_models.*, run_m11_tests.sh, verify_build.sh,
gorm_bool_main.go) to backend/scripts/legacy/. All moves via git mv to
preserve history. Build, vet, SQLite tests, and docker compose config verified.
2026-07-07 14:44:12 +08:00

57 lines
3.2 KiB
Go

package model
import "gorm.io/datatypes"
// WidgetThemeConfig stores custom theme configuration for a web widget inbox.
// Reference: Chatwoot app/models/channel/web_widget.rb — custom_theme attribute
// Stores advanced branding, layout, and visual customization beyond basic widget_color.
type WidgetThemeConfig struct {
Base
InboxID uint `gorm:"index;not null" json:"inbox_id"`
// === Branding ===
PrimaryColor string `gorm:"size:20;default:'#1f93ff'" json:"primary_color"` // Primary brand color (hex)
SecondaryColor string `gorm:"size:20;default:''" json:"secondary_color,omitempty"` // Secondary brand color (hex)
BackgroundColor string `gorm:"size:20;default:'#ffffff'" json:"background_color"` // Widget background color
TextColor string `gorm:"size:20;default:'#1f1f1f'" json:"text_color"` // Primary text color
LinkColor string `gorm:"size:20" json:"link_color,omitempty"` // Link color
// === Typography ===
FontFamily string `gorm:"size:100;default:'Inter, sans-serif'" json:"font_family"` // CSS font-family stack
FontSize string `gorm:"size:10;default:'14px'" json:"font_size"` // Base font size
HeadingFont string `gorm:"size:100" json:"heading_font,omitempty"` // Heading font-family (if different)
// === Layout ===
WidgetPosition string `gorm:"size:20;default:'right'" json:"widget_position"` // "left" or "right"
WidgetAlignment string `gorm:"size:20;default:'bottom'" json:"widget_alignment"` // "bottom" or "center"
AvatarRadius string `gorm:"size:10;default:'50%'" json:"avatar_radius"` // CSS border-radius for avatars
ButtonRadius string `gorm:"size:10;default:'8px'" json:"button_radius"` // CSS border-radius for buttons
// === Custom CSS ===
CustomCSS string `gorm:"type:text" json:"custom_css,omitempty"` // Raw CSS overrides injected into widget
// === Images ===
BrandLogoURL string `gorm:"size:512" json:"brand_logo_url,omitempty"` // Brand logo image URL
FaviconURL string `gorm:"size:512" json:"favicon_url,omitempty"` // Custom favicon URL
AvatarURL string `gorm:"size:512" json:"avatar_url,omitempty"` // Default agent avatar URL
WelcomeAvatarURL string `gorm:"size:512" json:"welcome_avatar_url,omitempty"` // Welcome screen avatar URL
// === Advanced ===
HideMessageBubble bool `gorm:"default:false" json:"hide_message_bubble"` // Hide the unread message bubble
ShowPopUpWindow bool `gorm:"default:false" json:"show_pop_up_window"` // Auto-pop-up widget window on load
DarkMode string `gorm:"size:10;default:'light'" json:"dark_mode"` // "light", "dark", or "auto"
DarkModeColors datatypes.JSON `gorm:"type:jsonb" json:"dark_mode_colors,omitempty"` // Dark mode overrides (JSON object)
Inbox Inbox `gorm:"foreignKey:InboxID" json:"inbox,omitempty"`
}
func (WidgetThemeConfig) TableName() string { return "widget_theme_configs" }
// WidgetThemeDarkColors holds the dark mode color overrides.
type WidgetThemeDarkColors struct {
PrimaryColor string `json:"primary_color"`
BackgroundColor string `json:"background_color"`
TextColor string `json:"text_color"`
LinkColor string `json:"link_color"`
ButtonColor string `json:"button_color"`
}