Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
feat: Add theme manager and multiple card components with theme switching support
puji48109f91a770906c
diff --git a/internal/desktop/components.go b/internal/desktop/components.goindex 6ebdc06f..aef1178b 100644--- a/internal/desktop/components.go+++ b/internal/desktop/components.go@@ -9,12 +9,27 @@ import ("fyne.io/fyne/v2/canvas""fyne.io/fyne/v2/container""fyne.io/fyne/v2/layout"+ "fyne.io/fyne/v2/theme""fyne.io/fyne/v2/widget")+// 全局主题管理器实例+var globalThemeManager *ThemeManager++// SetGlobalThemeManager 设置全局主题管理器+func SetGlobalThemeManager(tm *ThemeManager) {+ globalThemeManager = tm+}++func GetCurrentThemeIsDark() bool {+ if globalThemeManager != nil {+ return globalThemeManager.IsDarkMode()+ }+ return false+}+// FadeAnimation 淡入淡出动画func FadeAnimation(content fyne.CanvasObject, duration time.Duration, startOpacity, endOpacity float64) {- // 使用更柔和的动画效果rect := canvas.NewRectangle(color.NRGBA{R: 240, G: 246, B: 252, A: 0})rect.FillColor = color.NRGBA{R: 240, G: 246, B: 252, A: uint8(startOpacity * 255)}@@ -30,32 +45,131 @@ func FadeAnimation(content fyne.CanvasObject, duration time.Duration, startOpacianim.Start()}-// PrimaryButton 创建主要按钮+// GlassmorphismCard 毛玻璃效果卡片+func GlassmorphismCard(title, subtitle string, content fyne.CanvasObject, isDark bool) *fyne.Container {+ var bgColor color.Color+ var titleColor color.Color+ var subtitleColor color.Color+ var borderColor color.Color++ if isDark {+ // 夜晚主题毛玻璃效果+ bgColor = color.NRGBA{R: 30, G: 41, B: 59, A: 180} // 半透明深色背景+ titleColor = color.NRGBA{R: 248, G: 250, B: 252, A: 255}+ subtitleColor = color.NRGBA{R: 148, G: 163, B: 184, A: 200}+ borderColor = color.NRGBA{R: 51, G: 65, B: 85, A: 100}+ } else {+ // 明亮主题毛玻璃效果+ bgColor = color.NRGBA{R: 255, G: 255, B: 255, A: 180} // 半透明白色背景+ titleColor = color.NRGBA{R: 17, G: 24, B: 39, A: 255}+ subtitleColor = color.NRGBA{R: 107, G: 114, B: 128, A: 200}+ borderColor = color.NRGBA{R: 209, G: 213, B: 219, A: 100}+ }++ // 创建毛玻璃背景+ glassBackground := canvas.NewRectangle(bgColor)+ glassBackground.CornerRadius = 16+ glassBackground.StrokeColor = borderColor+ glassBackground.StrokeWidth = 1++ // 标题+ titleLabel := canvas.NewText(title, titleColor)+ titleLabel.TextSize = 18+ titleLabel.TextStyle = fyne.TextStyle{Bold: true}++ // 副标题+ var subtitleLabel *canvas.Text+ if subtitle != "" {+ subtitleLabel = canvas.NewText(subtitle, subtitleColor)+ subtitleLabel.TextSize = 14+ }++ // 标题容器+ var headerContainer *fyne.Container+ if subtitleLabel != nil {+ headerContainer = container.NewVBox(titleLabel, subtitleLabel)+ } else {+ headerContainer = container.NewVBox(titleLabel)+ }++ // 分隔线+ dividerColor := color.NRGBA{R: 209, G: 213, B: 219, A: 100}+ if isDark {+ dividerColor = color.NRGBA{R: 51, G: 65, B: 85, A: 100}+ }+ divider := canvas.NewLine(dividerColor)+ divider.StrokeWidth = 1++ contentWithPadding := container.NewPadded(content)++ // 布局+ cardContent := container.NewBorder(+ container.NewVBox(container.NewPadded(headerContainer), divider),+ nil, nil, nil,+ contentWithPadding,+ )++ // 多层阴影效果+ shadow1 := canvas.NewRectangle(color.NRGBA{R: 0, G: 0, B: 0, A: 10})+ shadow1.Move(fyne.NewPos(2, 2))+ shadow1.CornerRadius = 16++ shadow2 := canvas.NewRectangle(color.NRGBA{R: 0, G: 0, B: 0, A: 5})+ shadow2.Move(fyne.NewPos(4, 4))+ shadow2.CornerRadius = 16++ return container.NewStack(shadow2, shadow1, glassBackground, cardContent)+}++// TransparentCard 透明效果卡片+func TransparentCard(content fyne.CanvasObject, isDark bool) *fyne.Container {+ var bgColor color.Color+ var borderColor color.Color++ if isDark {+ bgColor = color.NRGBA{R: 30, G: 41, B: 59, A: 120}+ borderColor = color.NRGBA{R: 51, G: 65, B: 85, A: 80}+ } else {+ bgColor = color.NRGBA{R: 255, G: 255, B: 255, A: 120}+ borderColor = color.NRGBA{R: 209, G: 213, B: 219, A: 80}+ }++ background := canvas.NewRectangle(bgColor)+ background.CornerRadius = 12+ background.StrokeColor = borderColor+ background.StrokeWidth = 1++ return container.NewStack(background, container.NewPadded(content))+}+func PrimaryButton(text string, icon fyne.Resource, action func()) *widget.Button {btn := widget.NewButtonWithIcon(text, icon, action)btn.Importance = widget.HighImportancereturn btn}-// SecondaryButton 创建次要按钮func SecondaryButton(text string, icon fyne.Resource, action func()) *widget.Button {btn := widget.NewButtonWithIcon(text, icon, action)btn.Importance = widget.MediumImportancereturn btn}-// TitleText 创建标题文本+func GhostButton(text string, icon fyne.Resource, action func()) *widget.Button {+ btn := widget.NewButtonWithIcon(text, icon, action)+ btn.Importance = widget.LowImportance+ return btn+}+func TitleText(text string) *canvas.Text {- title := canvas.NewText(text, color.NRGBA{R: 88, G: 157, B: 246, A: 255})- title.TextSize = 22+ title := canvas.NewText(text, theme.Color(theme.ColorNamePrimary))+ title.TextSize = 24title.TextStyle = fyne.TextStyle{Bold: true}title.Alignment = fyne.TextAlignCenterreturn title}-// SubtitleText 创建副标题文本func SubtitleText(text string) *canvas.Text {- subtitle := canvas.NewText(text, color.NRGBA{R: 100, G: 120, B: 160, A: 255})+ subtitle := canvas.NewText(text, theme.Color(theme.ColorNameForeground))subtitle.TextSize = 16subtitle.TextStyle = fyne.TextStyle{Italic: true}subtitle.Alignment = fyne.TextAlignCenter@@ -69,57 +183,18 @@ func createShadowRectangle(fillColor color.Color, cornerRadius float32) *canvas.}func GlassCard(title, subtitle string, content fyne.CanvasObject) *fyne.Container {- glassBackground := createShadowRectangle(color.NRGBA{R: 255, G: 255, B: 255, A: 200}, 12)-- titleLabel := canvas.NewText(title, color.NRGBA{R: 60, G: 80, B: 120, A: 255})- titleLabel.TextSize = 16- titleLabel.TextStyle = fyne.TextStyle{Bold: true}-- // 副标题- var subtitleLabel *canvas.Text- if subtitle != "" {- subtitleLabel = canvas.NewText(subtitle, color.NRGBA{R: 100, G: 120, B: 150, A: 200})- subtitleLabel.TextSize = 12- }-- // 标题容器- var headerContainer *fyne.Container- if subtitleLabel != nil {- headerContainer = container.NewVBox(titleLabel, subtitleLabel)- } else {- headerContainer = container.NewVBox(titleLabel)- }-- // 分隔线- divider := canvas.NewLine(color.NRGBA{R: 220, G: 230, B: 240, A: 255})- divider.StrokeWidth = 1-- contentWithPadding := container.NewPadded(content)-- // 布局- cardContent := container.NewBorder(- container.NewVBox(container.NewPadded(headerContainer), divider),- nil, nil, nil,- contentWithPadding,- )-- // 阴影- shadow := canvas.NewRectangle(color.NRGBA{R: 0, G: 0, B: 0, A: 20})- shadow.Move(fyne.NewPos(3, 3))- shadow.Resize(fyne.NewSize(cardContent.Size().Width, cardContent.Size().Height))- shadow.CornerRadius = 12-- return container.NewStack(shadow, glassBackground, cardContent)+ return GlassmorphismCard(title, subtitle, content, false)}+// StyledCard 样式化卡片 - 优化版本func StyledCard(title string, content fyne.CanvasObject) *fyne.Container {- bg := createShadowRectangle(color.NRGBA{R: 250, G: 251, B: 254, A: 255}, 8)+ bg := createShadowRectangle(color.NRGBA{R: 250, G: 251, B: 254, A: 255}, 12)- titleLabel := canvas.NewText(title, color.NRGBA{R: 60, G: 80, B: 120, A: 255})+ titleLabel := canvas.NewText(title, color.NRGBA{R: 17, G: 24, B: 39, A: 255})titleLabel.TextSize = 16titleLabel.TextStyle = fyne.TextStyle{Bold: true}- divider := canvas.NewRectangle(color.NRGBA{R: 230, G: 235, B: 240, A: 255})+ divider := canvas.NewRectangle(color.NRGBA{R: 229, G: 231, B: 235, A: 255})divider.SetMinSize(fyne.NewSize(0, 1))// 组合@@ -135,18 +210,18 @@ func StyledCard(title string, content fyne.CanvasObject) *fyne.Container {shadow := canvas.NewRectangle(color.NRGBA{R: 0, G: 0, B: 0, A: 15})shadow.Move(fyne.NewPos(2, 2))shadow.SetMinSize(fyne.NewSize(contentContainer.Size().Width+4, contentContainer.Size().Height+4))- shadow.CornerRadius = 8+ shadow.CornerRadius = 12return container.NewStack(shadow, bg, contentContainer)}+// StyledSelect 样式化选择器func StyledSelect(options []string, selected func(string)) *widget.Select {sel := widget.NewSelect(options, selected)// 针对包含"翻译后字幕"的选项增加宽度for _, option := range options {if len(option) > 8 {-extraOptions := make([]string, len(options))copy(extraOptions, options)@@ -171,18 +246,21 @@ func StyledSelect(options []string, selected func(string)) *widget.Select {return sel}+// StyledEntry 样式化输入框func StyledEntry(placeholder string) *widget.Entry {entry := widget.NewEntry()entry.SetPlaceHolder(placeholder)return entry}+// StyledPasswordEntry 样式化密码输入框func StyledPasswordEntry(placeholder string) *widget.Entry {entry := widget.NewPasswordEntry()entry.SetPlaceHolder(placeholder)return entry}+// DividedContainer 分隔容器func DividedContainer(vertical bool, items ...fyne.CanvasObject) *fyne.Container {if len(items) <= 1 {if len(items) == 1 {@@ -210,8 +288,9 @@ func DividedContainer(vertical bool, items ...fyne.CanvasObject) *fyne.Containerreturn container.New(layout.NewHBoxLayout(), objects...)}+// createDivider 创建分隔线func createDivider(vertical bool) fyne.CanvasObject {- divider := canvas.NewRectangle(color.NRGBA{R: 210, G: 220, B: 240, A: 255})+ divider := canvas.NewRectangle(color.NRGBA{R: 209, G: 213, B: 219, A: 255})if vertical {divider.SetMinSize(fyne.NewSize(0, 1))} else {@@ -220,6 +299,7 @@ func createDivider(vertical bool) fyne.CanvasObject {return divider}+// ProgressWithLabel 进度条带标签func ProgressWithLabel(initial float64) (*widget.ProgressBar, *widget.Label, *fyne.Container) {progress := widget.NewProgressBar()progress.SetValue(initial)@@ -237,13 +317,15 @@ func UpdateProgressLabel(progress *widget.ProgressBar, label *widget.Label) {label.SetText(fmt.Sprintf("%d%%", percentage))}+// AnimatedContainer 动画容器func AnimatedContainer() *fyne.Container {return container.NewStack()}+// SwitchContent 切换内容func SwitchContent(container *fyne.Container, content fyne.CanvasObject, duration time.Duration) {if container == nil || content == nil {- return+ return}if len(container.Objects) > 0 {@@ -268,3 +350,69 @@ func SwitchContent(container *fyne.Container, content fyne.CanvasObject, duratioFadeAnimation(content, duration/2, 0.0, 1.0)}}++// ModernCard 现代卡片组件+func ModernCard(title string, content fyne.CanvasObject, isDark bool) *fyne.Container {+ var bgColor color.Color+ var titleColor color.Color+ var borderColor color.Color++ if isDark {+ bgColor = color.NRGBA{R: 30, G: 41, B: 59, A: 255}+ titleColor = color.NRGBA{R: 248, G: 250, B: 252, A: 255}+ borderColor = color.NRGBA{R: 51, G: 65, B: 85, A: 255}+ } else {+ bgColor = color.NRGBA{R: 255, G: 255, B: 255, A: 255}+ titleColor = color.NRGBA{R: 17, G: 24, B: 39, A: 255}+ borderColor = color.NRGBA{R: 209, G: 213, B: 219, A: 255}+ }++ background := canvas.NewRectangle(bgColor)+ background.CornerRadius = 12+ background.StrokeColor = borderColor+ background.StrokeWidth = 1++ titleLabel := canvas.NewText(title, titleColor)+ titleLabel.TextSize = 16+ titleLabel.TextStyle = fyne.TextStyle{Bold: true}++ divider := canvas.NewRectangle(color.NRGBA{R: 229, G: 231, B: 235, A: 255})+ if isDark {+ divider.FillColor = color.NRGBA{R: 51, G: 65, B: 85, A: 255}+ }+ divider.SetMinSize(fyne.NewSize(0, 1))++ contentContainer := container.NewBorder(+ container.NewVBox(+ container.NewPadded(titleLabel),+ divider,+ ),+ nil, nil, nil,+ container.NewPadded(content),+ )++ // 阴影效果+ shadow := canvas.NewRectangle(color.NRGBA{R: 0, G: 0, B: 0, A: 10})+ shadow.Move(fyne.NewPos(2, 2))+ shadow.CornerRadius = 12++ return container.NewStack(shadow, background, contentContainer)+}++// ThemeToggleButton 主题切换按钮+func ThemeToggleButton(isDark bool, onToggle func()) *widget.Button {+ var icon fyne.Resource+ var text string++ if isDark {+ icon = theme.ColorPaletteIcon()+ text = "明亮模式"+ } else {+ icon = theme.ColorPaletteIcon()+ text = "夜晚模式"+ }++ btn := widget.NewButtonWithIcon(text, icon, onToggle)+ btn.Importance = widget.MediumImportance+ return btn+}diff --git a/internal/desktop/desktop.go b/internal/desktop/desktop.goindex d90c2f40..18cda779 100644--- a/internal/desktop/desktop.go+++ b/internal/desktop/desktop.go@@ -34,23 +34,25 @@ func createNavButton(text string, icon fyne.Resource, isSelected bool, onTap fun// Show 展示桌面func Show() {myApp := app.New()+ myWindow := myApp.NewWindow("Klic Studio")- // 自定义主题- myApp.Settings().SetTheme(NewCustomTheme(false))+ // 创建主题管理器+ themeManager := NewThemeManager(myApp, myWindow)- myWindow := myApp.NewWindow("Klic Studio")+ // 设置全局主题管理器+ SetGlobalThemeManager(themeManager)logoContainer := container.NewVBox()- logo := canvas.NewText("Klic Studio", color.NRGBA{R: 88, G: 157, B: 246, A: 255})+ logo := canvas.NewText("Klic Studio", color.NRGBA{R: 59, G: 130, B: 246, A: 255})logo.TextSize = 28logo.TextStyle = fyne.TextStyle{Bold: true}logo.Alignment = fyne.TextAlignCenter- separator := canvas.NewRectangle(color.NRGBA{R: 210, G: 225, B: 245, A: 255})+ separator := canvas.NewRectangle(color.NRGBA{R: 209, G: 213, B: 219, A: 255})separator.SetMinSize(fyne.NewSize(0, 2))- slogan := canvas.NewText("智能内容创作助手", color.NRGBA{R: 100, G: 120, B: 160, A: 255})+ slogan := canvas.NewText("智能内容创作助手", color.NRGBA{R: 107, G: 114, B: 128, A: 255})slogan.TextSize = 12slogan.Alignment = fyne.TextAlignCenter@@ -58,42 +60,52 @@ func Show() {logoContainer.Add(separator)logoContainer.Add(slogan)- // 创建左侧导航栏navItems := []string{"工作台 Workbench", "配置 Config"}navIcons := []fyne.Resource{theme.DocumentIcon(), theme.SettingsIcon()}- // 存储导航按钮列表var navButtons []*widget.ButtonnavContainer := container.NewVBox()- // 创建内容区域,使用Stack容器来叠放多个内容contentStack := container.NewStack()+ currentSelectedIndex := 0- // 预先创建两个tab的内容- workbenchContent := CreateSubtitleTab(myWindow)- configContent := CreateConfigTab(myWindow)+ var workbenchContent, configContent fyne.CanvasObject- // 默认显示工作台内容- contentStack.Add(workbenchContent)- contentStack.Add(configContent)+ var refreshContent = func() {+ contentStack.Objects = []fyne.CanvasObject{}- configContent.Hide()+ workbenchContent = CreateSubtitleTab(myWindow)+ configContent = CreateConfigTab(myWindow)- currentSelectedIndex := 0+ if currentSelectedIndex == 0 {+ contentStack.Add(workbenchContent)+ contentStack.Add(configContent)+ configContent.Hide()+ } else {+ contentStack.Add(workbenchContent)+ contentStack.Add(configContent)+ workbenchContent.Hide()+ }++ contentStack.Refresh()+ }++ refreshContent()++ // 添加主题切换回调来刷新内容+ themeManager.AddThemeChangeCallback(func(isDark bool) {+ refreshContent()+ })- // 创建导航项for i, item := range navItems {index := i // 捕获变量isSelected := i == currentSelectedIndex- // 创建导航按钮以及点击处理函数navBtn := createNavButton(item, navIcons[i], isSelected, func() {- // 如果已经是当前选中项,不做任何操作if currentSelectedIndex == index {return}- // 更新所有导航项的状态for j, btn := range navButtons {if j == index {btn.Importance = widget.HighImportance@@ -103,10 +115,8 @@ func Show() {}if index == 0 {- // tab切换出去就保存和重新加载配置err := config.SaveConfig()if err != nil {- // 保存配置失败,弹出提示框dialog.ShowError(fmt.Errorf("保存配置失败: %v", err), myWindow)log.GetLogger().Error("保存配置失败 Failed to save config", zap.Error(err))return@@ -114,7 +124,6 @@ func Show() {log.GetLogger().Info("配置已保存 Config saved successfully")workbenchContent.Show()configContent.Hide()- // 确保进度条和下载区域状态正确显示workbenchContent.Refresh()FadeAnimation(workbenchContent, 300*time.Millisecond, 0.0, 1.0)} else {@@ -123,46 +132,66 @@ func Show() {FadeAnimation(configContent, 300*time.Millisecond, 0.0, 1.0)}- // 更新当前选中的索引currentSelectedIndex = indexnavContainer.Refresh()contentStack.Refresh()})- // 将导航按钮添加到列表和容器中navButtons = append(navButtons, navBtn)navContainer.Add(container.NewPadded(navBtn))}- navBackground := canvas.NewRectangle(color.NRGBA{R: 250, G: 251, B: 254, A: 255})+ themeToggleContainer := themeManager.CreateThemeToggleButton()++ navBottomContainer := container.NewVBox(+ layout.NewSpacer(),+ themeToggleContainer,+ )++ navBackground := themeManager.CreateGlassmorphismBackground()navWithBackground := container.NewStack(navBackground,container.NewBorder(container.NewPadded(logoContainer),- nil, nil, nil,+ container.NewPadded(navBottomContainer),+ nil, nil,container.NewPadded(navContainer),),)- // 主布局split := container.NewHSplit(navWithBackground, container.NewPadded(contentStack))- split.SetOffset(0.2)+ split.SetOffset(0.25)mainContainer := container.NewPadded(split)- // 底部状态栏- statusText := canvas.NewText("就绪", color.NRGBA{R: 100, G: 120, B: 160, A: 180})+ var statusTextColor, statusBgColor color.Color+ if themeManager.IsDarkMode() {+ statusTextColor = color.NRGBA{R: 148, G: 163, B: 184, A: 180}+ statusBgColor = color.NRGBA{R: 30, G: 41, B: 59, A: 150}+ } else {+ statusTextColor = color.NRGBA{R: 107, G: 114, B: 128, A: 180}+ statusBgColor = color.NRGBA{R: 255, G: 255, B: 255, A: 150}+ }++ statusText := canvas.NewText("就绪", statusTextColor)statusText.TextSize = 12- statusBar := container.NewHBox(- layout.NewSpacer(),- statusText,++ statusBarBackground := canvas.NewRectangle(statusBgColor)+ statusBarBackground.CornerRadius = 8++ statusBar := container.NewStack(+ statusBarBackground,+ container.NewHBox(+ layout.NewSpacer(),+ statusText,+ ),)finalContainer := container.NewBorder(nil, container.NewPadded(statusBar), nil, nil, mainContainer)myWindow.SetContent(finalContainer)- myWindow.Resize(fyne.NewSize(1000, 700))+ myWindow.Resize(fyne.NewSize(1200, 800))myWindow.CenterOnScreen()myWindow.ShowAndRun()diff --git a/internal/desktop/theme.go b/internal/desktop/theme.goindex 669483f7..f7efa875 100644--- a/internal/desktop/theme.go+++ b/internal/desktop/theme.go@@ -7,153 +7,165 @@ import ("fyne.io/fyne/v2/theme")+// ThemeMode 主题模式+type ThemeMode int++const (+ ThemeModeLight ThemeMode = iota+ ThemeModeDark+ ThemeModeAuto+)+// customTheme 自定义主题type customTheme struct {baseTheme fyne.Theme+ mode ThemeModeforceDark bool+ // 添加主题变化回调+ onThemeChange []func(ThemeMode)}-func NewCustomTheme(forceDark bool) fyne.Theme {- if forceDark {- return &customTheme{baseTheme: theme.DefaultTheme(), forceDark: true}+func NewCustomTheme(mode ThemeMode) fyne.Theme {+ forceDark := mode == ThemeModeDark+ return &customTheme{+ baseTheme: theme.DefaultTheme(),+ mode: mode,+ forceDark: forceDark,+ onThemeChange: make([]func(ThemeMode), 0),}- return &customTheme{baseTheme: theme.DefaultTheme(), forceDark: false}}func (t *customTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {- if t.forceDark || variant == theme.VariantDark {+ if t.forceDark || (t.mode == ThemeModeAuto && variant == theme.VariantDark) || t.mode == ThemeModeDark {return t.darkColors(name)}return t.lightColors(name)}-// lightColors 浅色主题配色方案+// lightColors 明亮主题配色方案func (t *customTheme) lightColors(name fyne.ThemeColorName) color.Color {switch name {- // 主色系+ // 主色系 - 更现代的蓝色case theme.ColorNamePrimary:- return color.NRGBA{R: 100, G: 150, B: 240, A: 255}+ return color.NRGBA{R: 59, G: 130, B: 246, A: 255} // 更鲜艳的蓝色// 背景与前景case theme.ColorNameBackground:- return color.NRGBA{R: 248, G: 249, B: 252, A: 255} // 极浅灰背景+ return color.NRGBA{R: 248, G: 250, B: 252, A: 255} // 极浅灰背景case theme.ColorNameForeground:- return color.NRGBA{R: 30, G: 35, B: 45, A: 255} // 深灰文字+ return color.NRGBA{R: 17, G: 24, B: 39, A: 255} // 深灰文字case theme.ColorNameDisabled:- return color.NRGBA{R: 180, G: 185, B: 190, A: 150} // 柔和禁用色+ return color.NRGBA{R: 156, G: 163, B: 175, A: 150} // 柔和禁用色// 按钮状态case theme.ColorNameButton:- return color.NRGBA{R: 70, G: 130, B: 230, A: 255}+ return color.NRGBA{R: 59, G: 130, B: 246, A: 255}case theme.ColorNameHover:- return color.NRGBA{R: 90, G: 150, B: 240, A: 255} // 浅蓝悬停+ return color.NRGBA{R: 37, G: 99, B: 235, A: 255} // 深蓝悬停case theme.ColorNamePressed:- return color.NRGBA{R: 50, G: 110, B: 210, A: 255} // 深蓝按下+ return color.NRGBA{R: 29, G: 78, B: 216, A: 255} // 更深蓝按下// 输入组件case theme.ColorNameInputBackground:return color.NRGBA{R: 255, G: 255, B: 255, A: 255} // 纯白输入框case theme.ColorNameInputBorder:- return color.NRGBA{R: 210, G: 215, B: 220, A: 255} // 浅灰边框+ return color.NRGBA{R: 209, G: 213, B: 219, A: 255} // 浅灰边框case theme.ColorNamePlaceHolder:- return color.NRGBA{R: 160, G: 165, B: 170, A: 200} // 灰占位符+ return color.NRGBA{R: 156, G: 163, B: 175, A: 200} // 灰占位符// 其他case theme.ColorNameSelection:- return color.NRGBA{R: 200, G: 225, B: 255, A: 180} // 淡蓝选中+ return color.NRGBA{R: 219, G: 234, B: 254, A: 180} // 淡蓝选中case theme.ColorNameScrollBar:- return color.NRGBA{R: 200, G: 205, B: 210, A: 200}+ return color.NRGBA{R: 209, G: 213, B: 219, A: 200}case theme.ColorNameShadow:return color.NRGBA{R: 0, G: 0, B: 0, A: 25} // 柔和阴影// 状态色case theme.ColorNameError:- return color.NRGBA{R: 230, G: 70, B: 70, A: 255} // 红色错误+ return color.NRGBA{R: 239, G: 68, B: 68, A: 255} // 红色错误case theme.ColorNameWarning:- return color.NRGBA{R: 245, G: 160, B: 50, A: 255} // 橙色警告+ return color.NRGBA{R: 245, G: 158, B: 11, A: 255} // 橙色警告case theme.ColorNameSuccess:- return color.NRGBA{R: 60, G: 180, B: 120, A: 255} // 绿色成功+ return color.NRGBA{R: 34, G: 197, B: 94, A: 255} // 绿色成功case theme.ColorNameFocus:- return color.NRGBA{R: 70, G: 130, B: 230, A: 100} // 半透明焦点+ return color.NRGBA{R: 59, G: 130, B: 246, A: 100} // 半透明焦点default:return t.baseTheme.Color(name, theme.VariantLight)}}-// darkColors 深色主题配色方案+// darkColors 夜晚主题配色方案func (t *customTheme) darkColors(name fyne.ThemeColorName) color.Color {switch name {// 主色系case theme.ColorNamePrimary:- return color.NRGBA{R: 90, G: 150, B: 250, A: 255} // 稍亮的蓝色+ return color.NRGBA{R: 96, G: 165, B: 250, A: 255} // 亮蓝色// 背景与前景case theme.ColorNameBackground:- return color.NRGBA{R: 20, G: 22, B: 30, A: 255} // 更深的灰蓝背景+ return color.NRGBA{R: 15, G: 23, B: 42, A: 255} // 深蓝灰背景case theme.ColorNameForeground:- return color.NRGBA{R: 230, G: 235, B: 240, A: 255} // 浅灰文字+ return color.NRGBA{R: 248, G: 250, B: 252, A: 255} // 浅灰文字case theme.ColorNameDisabled:- return color.NRGBA{R: 100, G: 105, B: 110, A: 150} // 深色禁用+ return color.NRGBA{R: 100, G: 116, B: 139, A: 150} // 深色禁用// 按钮状态case theme.ColorNameButton:- return color.NRGBA{R: 50, G: 55, B: 65, A: 255} // 更深的按钮背景+ return color.NRGBA{R: 30, G: 41, B: 59, A: 255} // 深按钮背景case theme.ColorNameHover:- return color.NRGBA{R: 70, G: 75, B: 85, A: 255} // 浅灰悬停+ return color.NRGBA{R: 51, G: 65, B: 85, A: 255} // 浅灰悬停case theme.ColorNamePressed:- return color.NRGBA{R: 30, G: 35, B: 45, A: 255} // 更深按下+ return color.NRGBA{R: 15, G: 23, B: 42, A: 255} // 更深按下// 输入组件case theme.ColorNameInputBackground:- return color.NRGBA{R: 35, G: 38, B: 48, A: 255} // 更深的输入框背景+ return color.NRGBA{R: 30, G: 41, B: 59, A: 255} // 深输入框背景case theme.ColorNameInputBorder:- return color.NRGBA{R: 60, G: 65, B: 75, A: 255} // 更深的边框+ return color.NRGBA{R: 51, G: 65, B: 85, A: 255} // 深边框case theme.ColorNamePlaceHolder:- return color.NRGBA{R: 120, G: 125, B: 130, A: 200} // 灰占位符+ return color.NRGBA{R: 148, G: 163, B: 184, A: 200} // 灰占位符// 其他case theme.ColorNameSelection:- return color.NRGBA{R: 70, G: 130, B: 230, A: 180} // 蓝色选中+ return color.NRGBA{R: 59, G: 130, B: 246, A: 180} // 蓝色选中case theme.ColorNameScrollBar:- return color.NRGBA{R: 60, G: 65, B: 75, A: 200} // 更深的滚动条+ return color.NRGBA{R: 51, G: 65, B: 85, A: 200} // 深滚动条case theme.ColorNameShadow:return color.NRGBA{R: 0, G: 0, B: 0, A: 50} // 深色阴影// 状态色(更鲜艳)case theme.ColorNameError:- return color.NRGBA{R: 240, G: 80, B: 80, A: 255}+ return color.NRGBA{R: 248, G: 113, B: 113, A: 255}case theme.ColorNameWarning:- return color.NRGBA{R: 255, G: 170, B: 60, A: 255}+ return color.NRGBA{R: 251, G: 191, B: 36, A: 255}case theme.ColorNameSuccess:- return color.NRGBA{R: 70, G: 190, B: 130, A: 255}+ return color.NRGBA{R: 74, G: 222, B: 128, A: 255}case theme.ColorNameFocus:- return color.NRGBA{R: 80, G: 140, B: 240, A: 100}+ return color.NRGBA{R: 96, G: 165, B: 250, A: 100}default:return t.baseTheme.Color(name, theme.VariantDark)}}-// Icon 主题图标func (t *customTheme) Icon(name fyne.ThemeIconName) fyne.Resource {return t.baseTheme.Icon(name)}-// Font 主题字体func (t *customTheme) Font(style fyne.TextStyle) fyne.Resource {return t.baseTheme.Font(style)}-// Size 主题尺寸设置func (t *customTheme) Size(name fyne.ThemeSizeName) float32 {switch name {case theme.SizeNamePadding:- return 10+ return 12case theme.SizeNameInlineIcon:return 20case theme.SizeNameScrollBar:- return 10+ return 8case theme.SizeNameScrollBarSmall:return 4case theme.SizeNameSeparatorThickness:@@ -163,8 +175,30 @@ func (t *customTheme) Size(name fyne.ThemeSizeName) float32 {case theme.SizeNameInputBorder:return 1.5case theme.SizeNameInputRadius:- return 5+ return 6default:return t.baseTheme.Size(name)}}++// GetThemeMode 获取当前主题模式+func (t *customTheme) GetThemeMode() ThemeMode {+ return t.mode+}++// SetThemeMode 设置主题模式+func (t *customTheme) SetThemeMode(mode ThemeMode) {+ if t.mode != mode {+ t.mode = mode+ t.forceDark = mode == ThemeModeDark+ // 通知所有回调函数+ for _, callback := range t.onThemeChange {+ callback(mode)+ }+ }+}++// AddThemeChangeCallback 添加主题变化回调+func (t *customTheme) AddThemeChangeCallback(callback func(ThemeMode)) {+ t.onThemeChange = append(t.onThemeChange, callback)+}diff --git a/internal/desktop/theme_manager.go b/internal/desktop/theme_manager.gonew file mode 100644index 00000000..3d96b0b5--- /dev/null+++ b/internal/desktop/theme_manager.go@@ -0,0 +1,166 @@+package desktop++import (+ "image/color"++ "fyne.io/fyne/v2"+ "fyne.io/fyne/v2/canvas"+ "fyne.io/fyne/v2/container"+ "fyne.io/fyne/v2/widget"+)++// ThemeManager 主题管理器+type ThemeManager struct {+ app fyne.App+ window fyne.Window+ theme *customTheme+ isDarkMode bool+ callbacks []func(bool)+}++// NewThemeManager 创建主题管理器+func NewThemeManager(app fyne.App, window fyne.Window) *ThemeManager {+ theme := NewCustomTheme(ThemeModeLight).(*customTheme)+ app.Settings().SetTheme(theme)++ return &ThemeManager{+ app: app,+ window: window,+ theme: theme,+ isDarkMode: false,+ callbacks: make([]func(bool), 0),+ }+}++// IsDarkMode 检查是否为夜晚模式+func (tm *ThemeManager) IsDarkMode() bool {+ return tm.isDarkMode+}++// ToggleTheme 切换主题+func (tm *ThemeManager) ToggleTheme() {+ tm.isDarkMode = !tm.isDarkMode++ if tm.isDarkMode {+ tm.theme.SetThemeMode(ThemeModeDark)+ } else {+ tm.theme.SetThemeMode(ThemeModeLight)+ }++ // 更新应用主题+ tm.app.Settings().SetTheme(tm.theme)++ for _, callback := range tm.callbacks {+ callback(tm.isDarkMode)+ }++ tm.window.Canvas().Refresh(tm.window.Content())+}++// AddThemeChangeCallback 添加主题变化回调+func (tm *ThemeManager) AddThemeChangeCallback(callback func(bool)) {+ tm.callbacks = append(tm.callbacks, callback)+}++// CreateGlassmorphismCard 创建毛玻璃卡片(主题感知)+func (tm *ThemeManager) CreateGlassmorphismCard(title, subtitle string, content fyne.CanvasObject) *fyne.Container {+ return GlassmorphismCard(title, subtitle, content, tm.isDarkMode)+}++// CreateModernCard 创建现代卡片(主题感知)+func (tm *ThemeManager) CreateModernCard(title string, content fyne.CanvasObject) *fyne.Container {+ return ModernCard(title, content, tm.isDarkMode)+}++// CreateTransparentCard 创建透明卡片(主题感知)+func (tm *ThemeManager) CreateTransparentCard(content fyne.CanvasObject) *fyne.Container {+ return TransparentCard(content, tm.isDarkMode)+}++// CreateThemeToggleButton 创建主题切换按钮+func (tm *ThemeManager) CreateThemeToggleButton() *fyne.Container {+ var themeToggleBtn *widget.Button++ updateButton := func() {+ if tm.isDarkMode {+ themeToggleBtn.SetText("明亮模式")+ } else {+ themeToggleBtn.SetText("夜晚模式")+ }+ themeToggleBtn.Refresh()+ }++ themeToggleBtn = ThemeToggleButton(tm.isDarkMode, func() {+ tm.ToggleTheme()+ updateButton()+ })++ // 添加主题变化回调来更新按钮文本+ tm.AddThemeChangeCallback(func(isDark bool) {+ updateButton()+ })++ return container.NewPadded(themeToggleBtn)+}++// CreateGlassmorphismBackground 创建毛玻璃背景+func (tm *ThemeManager) CreateGlassmorphismBackground() *canvas.Rectangle {+ var bgColor color.Color+ var borderColor color.Color++ if tm.isDarkMode {+ bgColor = color.NRGBA{R: 30, G: 41, B: 59, A: 180}+ borderColor = color.NRGBA{R: 51, G: 65, B: 85, A: 100}+ } else {+ bgColor = color.NRGBA{R: 255, G: 255, B: 255, A: 180}+ borderColor = color.NRGBA{R: 209, G: 213, B: 219, A: 100}+ }++ background := canvas.NewRectangle(bgColor)+ background.CornerRadius = 16+ background.StrokeColor = borderColor+ background.StrokeWidth = 1++ return background+}++// CreateTransparentBackground 创建透明背景+func (tm *ThemeManager) CreateTransparentBackground() *canvas.Rectangle {+ var bgColor color.Color+ var borderColor color.Color++ if tm.isDarkMode {+ bgColor = color.NRGBA{R: 30, G: 41, B: 59, A: 120}+ borderColor = color.NRGBA{R: 51, G: 65, B: 85, A: 80}+ } else {+ bgColor = color.NRGBA{R: 255, G: 255, B: 255, A: 120}+ borderColor = color.NRGBA{R: 209, G: 213, B: 219, A: 80}+ }++ background := canvas.NewRectangle(bgColor)+ background.CornerRadius = 12+ background.StrokeColor = borderColor+ background.StrokeWidth = 1++ return background+}++// CreateGradientBackground 创建渐变背景+func (tm *ThemeManager) CreateGradientBackground() *canvas.LinearGradient {+ var startColor, endColor color.Color++ if tm.isDarkMode {+ startColor = color.NRGBA{R: 15, G: 23, B: 42, A: 255}+ endColor = color.NRGBA{R: 30, G: 41, B: 59, A: 255}+ } else {+ startColor = color.NRGBA{R: 248, G: 250, B: 252, A: 255}+ endColor = color.NRGBA{R: 241, G: 245, B: 249, A: 255}+ }++ return canvas.NewLinearGradient(startColor, endColor, 0.0)+}++// UpdateAllComponents 更新所有组件+func (tm *ThemeManager) UpdateAllComponents() {+ tm.window.Canvas().Refresh(tm.window.Content())+}diff --git a/internal/desktop/ui.go b/internal/desktop/ui.goindex 9f99d33a..c1619fa2 100644--- a/internal/desktop/ui.go+++ b/internal/desktop/ui.go@@ -25,7 +25,6 @@ import (// 创建配置界面func CreateConfigTab(window fyne.Window) fyne.CanvasObject {- // 创建页面标题pageTitle := TitleText("应用配置")appGroup := createAppConfigGroup()@@ -34,14 +33,25 @@ func CreateConfigTab(window fyne.Window) fyne.CanvasObject {transcribeGroup := createTranscribeConfigGroup()ttsGroup := createTtsConfigGroup()- // 创建一个背景效果- background := canvas.NewRectangle(color.NRGBA{R: 248, G: 250, B: 253, A: 255})+ var background *canvas.LinearGradient+ if GetCurrentThemeIsDark() {+ background = canvas.NewLinearGradient(+ color.NRGBA{R: 15, G: 23, B: 42, A: 255},+ color.NRGBA{R: 30, G: 41, B: 59, A: 255},+ 0.0,+ )+ } else {+ background = canvas.NewLinearGradient(+ color.NRGBA{R: 248, G: 250, B: 252, A: 255},+ color.NRGBA{R: 241, G: 245, B: 249, A: 255},+ 0.0,+ )+ }- // 添加一些视觉分隔和间距spacer1 := canvas.NewRectangle(color.NRGBA{R: 0, G: 0, B: 0, A: 0})- spacer1.SetMinSize(fyne.NewSize(0, 10))+ spacer1.SetMinSize(fyne.NewSize(0, 15))spacer2 := canvas.NewRectangle(color.NRGBA{R: 0, G: 0, B: 0, A: 0})- spacer2.SetMinSize(fyne.NewSize(0, 10))+ spacer2.SetMinSize(fyne.NewSize(0, 15))configContainer := container.NewVBox(container.NewPadded(pageTitle),@@ -56,7 +66,6 @@ func CreateConfigTab(window fyne.Window) fyne.CanvasObject {scroll := container.NewScroll(configContainer)- // 使用一个Stack将背景和滚动内容组合configStack := container.NewStack(background, scroll)return container.NewPadded(configStack)@@ -66,43 +75,42 @@ func CreateConfigTab(window fyne.Window) fyne.CanvasObject {func CreateSubtitleTab(window fyne.Window) fyne.CanvasObject {sm := NewSubtitleManager(window)- // 创建标题title := TitleText("视频翻译配音Video Translate & Dubbing")- // 创建视频输入区域videoInputContainer := createVideoInputContainer(sm)-- // 创建字幕设置区域subtitleSettingsCard := createSubtitleSettingsCard(sm)-- // 创建配音设置区域voiceSettingsCard := createVoiceSettingsCard(sm)-- // 创建视频合成区域embedSettingsCard := createEmbedSettingsCard(sm)- // 创建进度和下载区域progress, downloadContainer, tipsLabel := createProgressAndDownloadArea(sm)- // 创建开始按钮startButton := createStartButton(window, sm, videoInputContainer, embedSettingsCard, progress, downloadContainer)startButtonContainer := container.NewHBox(layout.NewSpacer(), startButton, layout.NewSpacer())- // 创建一个背景效果- background := canvas.NewRectangle(color.NRGBA{R: 248, G: 250, B: 253, A: 255})+ var background *canvas.LinearGradient+ if GetCurrentThemeIsDark() {+ background = canvas.NewLinearGradient(+ color.NRGBA{R: 15, G: 23, B: 42, A: 255},+ color.NRGBA{R: 30, G: 41, B: 59, A: 255},+ 0.0,+ )+ } else {+ background = canvas.NewLinearGradient(+ color.NRGBA{R: 248, G: 250, B: 252, A: 255},+ color.NRGBA{R: 241, G: 245, B: 249, A: 255},+ 0.0,+ )+ }- // 添加一些视觉分隔和间距spacer1 := canvas.NewRectangle(color.NRGBA{R: 0, G: 0, B: 0, A: 0})- spacer1.SetMinSize(fyne.NewSize(0, 10))+ spacer1.SetMinSize(fyne.NewSize(0, 15))spacer2 := canvas.NewRectangle(color.NRGBA{R: 0, G: 0, B: 0, A: 0})- spacer2.SetMinSize(fyne.NewSize(0, 10))+ spacer2.SetMinSize(fyne.NewSize(0, 15))spacer3 := canvas.NewRectangle(color.NRGBA{R: 0, G: 0, B: 0, A: 0})- spacer3.SetMinSize(fyne.NewSize(0, 10))+ spacer3.SetMinSize(fyne.NewSize(0, 15))- // 创建进度区域容器progressArea := container.NewVBox(progress)- // 创建主布局mainContent := container.NewVBox(container.NewPadded(title),spacer1,@@ -219,7 +227,7 @@ func createAppConfigGroup() *fyne.Container {widget.NewFormItem("网络代理地址 proxy", appProxyEntry),)- return GlassCard("应用配置 App Config", "基本参数 Basic config", form)+ return GlassmorphismCard("应用配置 App Config", "基本参数 Basic config", form, GetCurrentThemeIsDark())}// 创建server配置组@@ -245,9 +253,10 @@ func createServerConfigGroup() *fyne.Container {widget.NewFormItem("服务器端口 Server port", serverPortEntry),)- return GlassCard("服务器配置 Server Config", "API服务器设置 API server settings", form)+ return GlassmorphismCard("服务器配置 Server Config", "API服务器设置 API server settings", form, GetCurrentThemeIsDark())}+// 创建LLM配置组func createLlmConfigGroup() *fyne.Container {baseUrlEntry := StyledEntry("API Base URL")baseUrlEntry.Bind(binding.BindString(&config.Conf.Llm.BaseUrl))@@ -263,9 +272,10 @@ func createLlmConfigGroup() *fyne.Container {widget.NewFormItem("API Key", apiKeyEntry),widget.NewFormItem("模型名称 Model name", modelEntry),)- return GlassCard("LLM 配置 LLM Config", "LLM配置 LLM config", form)+ return GlassmorphismCard("LLM 配置 LLM Config", "LLM配置 LLM config", form, GetCurrentThemeIsDark())}+// 创建语音识别配置组func createTranscribeConfigGroup() *fyne.Container {providerOptions := []string{"openai", "fasterwhisper", "whisperkit", "whispercpp", "aliyun"}providerSelect := widget.NewSelect(providerOptions, func(value string) {@@ -325,9 +335,10 @@ func createTranscribeConfigGroup() *fyne.Container {widget.NewFormItem("阿里云语音 Aliyun Speech App Key", aliyunSpeechAppKeyEntry),)- return GlassCard("语音识别配置 Transcribe Config", "语音识别配置 Transcribe config", form)+ return GlassmorphismCard("语音识别配置 Transcribe Config", "语音识别配置 Transcribe config", form, GetCurrentThemeIsDark())}+// 创建文本转语音配置组func createTtsConfigGroup() *fyne.Container {providerOptions := []string{"openai", "aliyun"}providerSelect := widget.NewSelect(providerOptions, func(value string) {@@ -372,12 +383,11 @@ func createTtsConfigGroup() *fyne.Container {widget.NewFormItem("阿里云 Aliyun Speech App Key", aliyunSpeechAppKeyEntry),)- return GlassCard("文本转语音配置 TTS Config", "文本转语音配置 TTS config", form)+ return GlassmorphismCard("文本转语音配置 TTS Config", "文本转语音配置 TTS config", form, GetCurrentThemeIsDark())}// 创建视频输入容器func createVideoInputContainer(sm *SubtitleManager) *fyne.Container {- // 视频输入方式选择inputTypeRadio := widget.NewRadioGroup([]string{"本地视频 Local video", "视频链接 Video link"}, nil)inputTypeRadio.Horizontal = trueinputTypeContainer := container.NewHBox(@@ -385,20 +395,17 @@ func createVideoInputContainer(sm *SubtitleManager) *fyne.Container {inputTypeRadio,)- // 视频链接输入框urlEntry := StyledEntry("请输入视频链接Please enter the video link")urlEntry.Hide()urlEntry.OnChanged = func(text string) {sm.SetVideoUrl(text)}- // 视频选择按钮(支持多文件选择)selectButton := PrimaryButton("选择视频文件 Choose video files", theme.FolderOpenIcon(), sm.ShowFileDialog)selectedVideoLabel := widget.NewLabel("")selectedVideoLabel.Hide()- // 设置视频选择回调sm.SetVideoSelectedCallback(func(path string) { // 设置视频地址+控制信息展示if path != "" {sm.SetVideoUrl(path)@@ -409,19 +416,15 @@ func createVideoInputContainer(sm *SubtitleManager) *fyne.Container {}})- // 设置多视频选择回调sm.SetVideosSelectedCallback(func(paths []string) {if len(paths) > 0 {- // 设置第一个视频的URLsm.SetVideoUrl(paths[0])- // 显示已选择的文件数量fileNames := make([]string, 0, len(paths))for _, path := range paths {fileNames = append(fileNames, filepath.Base(path))}- // 构建文件列表,每行显示一个文件displayText := fmt.Sprintf("已选择 %d 个文件:\n", len(paths))for i, name := range fileNames {displayText += fmt.Sprintf("%d. %s\n", i+1, name)@@ -434,11 +437,9 @@ func createVideoInputContainer(sm *SubtitleManager) *fyne.Container {}})- // 视频输入容器videoInputContainer := container.NewVBox()videoInputContainer.Objects = []fyne.CanvasObject{selectButton, selectedVideoLabel}- // 切换输入方式inputTypeRadio.SetSelected("本地视频 Local video")inputTypeRadio.OnChanged = func(value string) {if value == "本地视频 Local video" {@@ -456,13 +457,12 @@ func createVideoInputContainer(sm *SubtitleManager) *fyne.Container {videoInputContainer.Refresh()}- // 创建容器content := container.NewVBox(container.NewPadded(inputTypeContainer),container.NewPadded(videoInputContainer),)- return GlassCard("1. 视频源设置 Video Source", "选择视频和语言 Choose video & language", content)+ return GlassmorphismCard("1. 视频源设置 Video Source", "选择视频和语言 Choose video & language", content, GetCurrentThemeIsDark())}// 创建字幕设置卡片@@ -534,7 +534,7 @@ func createSubtitleSettingsCard(sm *SubtitleManager) *fyne.Container {positionSelect,)- return StyledCard("2. 字幕设置 Subtitle setting", content)+ return ModernCard("2. 字幕设置 Subtitle setting", content, GetCurrentThemeIsDark())}// 创建配音设置卡片@@ -546,8 +546,8 @@ func createVoiceSettingsCard(sm *SubtitleManager) *fyne.Container {}voiceCodeEntry.Disable()- // todo 限制为仅阿里云- audioSampleButton := SecondaryButton("选择音色克隆样本(仅支持阿里云tts) Choose voice clone sample(Aliyun tts only)", theme.MediaMusicIcon(), sm.ShowAudioFileDialog)+ // 音色克隆功能 - 当前支持阿里云TTS,未来可扩展其他提供商+ audioSampleButton := SecondaryButton("选择音色克隆样本 Choose voice clone sample (Currently supports Aliyun TTS)", theme.MediaMusicIcon(), sm.ShowAudioFileDialog)audioSampleButton.Disable()voiceoverCheck := widget.NewCheck("启用配音 Enable dubbing", func(checked bool) {@@ -566,20 +566,18 @@ func createVoiceSettingsCard(sm *SubtitleManager) *fyne.Container {container.NewHBox(container.NewBorder(voiceCodeEntry, nil, nil, audioSampleButton)),)- return StyledCard("3. 配音设置 Dubbing setting", grid)+ return ModernCard("3. 配音设置 Dubbing setting", grid, GetCurrentThemeIsDark())}// 视频合成卡片func createEmbedSettingsCard(sm *SubtitleManager) *fyne.Container {embedCheck := widget.NewCheck("合成视频 Composite video", nil)- // 创建视频类型选择embedTypeSelect := StyledSelect([]string{"横屏视频 Landscape video", "竖屏视频 Portrait video", "横屏+竖屏视频 Landscape+Portrait video",}, nil)embedTypeSelect.Disable()- // 创建标题输入区域mainTitleEntry := StyledEntry("请输入主标题 Enter main title")subTitleEntry := StyledEntry("请输入副标题 Enter sub title")@@ -595,7 +593,6 @@ func createEmbedSettingsCard(sm *SubtitleManager) *fyne.Container {)titleInputContainer.Hide()- // 设置复选框行为embedCheck.OnChanged = func(checked bool) {if checked {embedTypeSelect.Enable()@@ -606,7 +603,6 @@ func createEmbedSettingsCard(sm *SubtitleManager) *fyne.Container {}}- // 更新标题输入区域的显示状态embedTypeSelect.OnChanged = func(value string) {switch value {case "横屏视频 Landscape video":@@ -621,34 +617,28 @@ func createEmbedSettingsCard(sm *SubtitleManager) *fyne.Container {}}- // 创建顶部控制区域topContainer := container.NewHBox(embedCheck, embedTypeSelect)- // 创建主容器mainContainer := container.NewVBox(topContainer,container.NewPadded(titleInputContainer),)- return StyledCard("视频合成设置 Subtitle embed setting", mainContainer)+ return ModernCard("视频合成设置 Subtitle embed setting", mainContainer, GetCurrentThemeIsDark())}// 创建进度和下载区域func createProgressAndDownloadArea(sm *SubtitleManager) (*widget.ProgressBar, *fyne.Container, *fyne.Container) {- // 创建进度条progress := widget.NewProgressBar()progress.Hide()- //进度百分比标签percentLabel := widget.NewLabel("0%")percentLabel.Hide()percentLabel.Alignment = fyne.TextAlignTrailing- // 进度条容器progressContainer := container.NewBorder(nil, nil, nil, percentLabel, progress)progressContainer.Hide()- // 添加半透明背景和阴影progressBg := canvas.NewRectangle(color.NRGBA{R: 240, G: 245, B: 250, A: 230})progressBg.SetMinSize(fyne.NewSize(0, 40))progressBg.CornerRadius = 8@@ -665,27 +655,22 @@ func createProgressAndDownloadArea(sm *SubtitleManager) (*widget.ProgressBar, *f)progressWithBg.Hide()- // 设置进度条和标签sm.SetProgressBar(progress)sm.SetProgressLabel(percentLabel)- // 创建下载容器背景downloadBg := canvas.NewRectangle(color.NRGBA{R: 240, G: 250, B: 255, A: 230})downloadBg.CornerRadius = 10- // 创建下载容器downloadContainer := container.NewVBox()downloadContainer.Hide()sm.SetDownloadContainer(downloadContainer)- // 包装下载容器和背景downloadWithBg := container.NewStack(downloadBg,container.NewPadded(downloadContainer),)downloadWithBg.Hide()- // 创建提示标签tipsLabel := widget.NewLabel("")tipsLabel.Hide()tipsLabel.Alignment = fyne.TextAlignCenter@@ -704,13 +689,12 @@ func createProgressAndDownloadArea(sm *SubtitleManager) (*widget.ProgressBar, *freturn progress, downloadWithBg, tipsWithBg}-// 创建开始按钮+// 开始按钮func createStartButton(window fyne.Window, sm *SubtitleManager, videoInputContainer *fyne.Container, embedSettingsCard *fyne.Container, progress *widget.ProgressBar, downloadContainer *fyne.Container) *widget.Button {btn := widget.NewButtonWithIcon("开始任务 Start task", theme.MediaPlayIcon(), nil)btn.Importance = widget.HighImportancebtn.OnTapped = func() {- // 按钮动画效果替换为简单的刷新originalImportance := btn.Importancebtn.Importance = widget.DangerImportancebtn.Refresh()@@ -725,14 +709,12 @@ func createStartButton(window fyne.Window, sm *SubtitleManager, videoInputContaiif embedSettingsCard != nil && len(embedSettingsCard.Objects) > 1 {if titleContainer, ok := embedSettingsCard.Objects[1].(*fyne.Container); ok && titleContainer != nil && len(titleContainer.Objects) >= 2 {- // 获取主标题if mainTitleRow, ok := titleContainer.Objects[0].(*fyne.Container); ok && mainTitleRow != nil && len(mainTitleRow.Objects) >= 2 {if mainTitleEntry, ok := mainTitleRow.Objects[1].(*widget.Entry); ok {mainTitle = mainTitleEntry.Text}}- // 获取副标题if subTitleRow, ok := titleContainer.Objects[1].(*fyne.Container); ok && subTitleRow != nil && len(subTitleRow.Objects) >= 2 {if subTitleEntry, ok := subTitleRow.Objects[1].(*widget.Entry); ok {subTitle = subTitleEntry.Text@@ -743,14 +725,12 @@ func createStartButton(window fyne.Window, sm *SubtitleManager, videoInputContaism.SetVerticalTitles(mainTitle, subTitle)- // 显示进度条并隐藏下载容器progress.Show()- sm.progressBar.SetValue(0) // 直接访问进度条+ sm.progressBar.SetValue(0)downloadContainer.Hide()- // 检查是否有视频URLif sm.GetVideoUrl() == "" {- inputType := "本地视频" // 默认值+ inputType := "本地视频"if videoInputContainer != nil && len(videoInputContainer.Objects) > 0 {for i := 0; i < len(videoInputContainer.Objects); i++ {@@ -775,7 +755,6 @@ func createStartButton(window fyne.Window, sm *SubtitleManager, videoInputContaireturn}- // 桌面端的启动之前要check configerr := config.CheckConfig()if err != nil {dialog.ShowError(fmt.Errorf("配置不正确: %v", err), window)@@ -791,11 +770,9 @@ func createStartButton(window fyne.Window, sm *SubtitleManager, videoInputContaiprogress.Hide()return}- // 隐藏开始按钮btn.Hide()if config.ConfigBackup != config.Conf {- // 重启后端服务以刷新配置if err = server.StopBackend(); err != nil {dialog.ShowError(fmt.Errorf("停止后端服务失败: %v", err), window)log.GetLogger().Error("停止后端服务失败", zap.Error(err))@@ -813,7 +790,6 @@ func createStartButton(window fyne.Window, sm *SubtitleManager, videoInputContai}}()- // 延迟一段时间以确保后端服务启动time.Sleep(1 * time.Second)config.ConfigBackup = config.Conf}@@ -824,23 +800,19 @@ func createStartButton(window fyne.Window, sm *SubtitleManager, videoInputContaireturn}- // 监听进度条go func() {for {time.Sleep(1 * time.Second)if sm.progressBar.Value < 1 {continue}- // 多任务时防抖time.Sleep(1 * time.Second)if sm.progressBar.Value < 1 {continue}break}- // 显示下载按钮btn.Show()- // 显示下载容器downloadContainer.Show()}()sm.progressBar.Refresh()