Skip to content

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.

fix: can not see language option in desktop ui when use dark theme

沈浩603ad8cb7cae
diff --git a/internal/desktop/desktop.go b/internal/desktop/desktop.go
index ab5ef668..44c6969a 100644
--- a/internal/desktop/desktop.go
+++ b/internal/desktop/desktop.go
@@ -31,7 +31,7 @@ func Show() {
myApp := app.New()
// 自定义主题
- myApp.Settings().SetTheme(NewCustomTheme())
+ myApp.Settings().SetTheme(NewCustomTheme(false))
myWindow := myApp.NewWindow("Krillin AI")
@@ -72,7 +72,6 @@ func Show() {
contentStack.Add(workbenchContent)
contentStack.Add(configContent)
- // 默认隐藏配置内容
configContent.Hide()
currentSelectedIndex := 0
@@ -101,19 +100,15 @@ func Show() {
// 更新当前选中的索引
currentSelectedIndex = index
- // 刷新容器
navContainer.Refresh()
- // 切换显示内容而不是重新创建
if index == 0 {
- // 显示工作台内容
workbenchContent.Show()
configContent.Hide()
// 确保进度条和下载区域状态正确显示
workbenchContent.Refresh()
FadeAnimation(workbenchContent, 300*time.Millisecond, 0.0, 1.0)
} else {
- // 显示配置内容
workbenchContent.Hide()
configContent.Show()
FadeAnimation(configContent, 300*time.Millisecond, 0.0, 1.0)
@@ -159,19 +154,3 @@ func Show() {
myWindow.CenterOnScreen()
myWindow.ShowAndRun()
}
-
-// 这个函数现在不再使用,因为我们预先创建了所有内容
-// 保留它是为了兼容性
-func updateContent(index int, content *fyne.Container) {
- var newContent fyne.CanvasObject
-
- switch index {
- case 0:
- newContent = CreateSubtitleTab(fyne.CurrentApp().Driver().AllWindows()[0])
- case 1:
- newContent = CreateConfigTab(fyne.CurrentApp().Driver().AllWindows()[0])
- }
-
- // 使用淡入淡出动画切换内容
- SwitchContent(content, newContent, 300*time.Millisecond)
-}
diff --git a/internal/desktop/theme.go b/internal/desktop/theme.go
index f09b090f..669483f7 100644
--- a/internal/desktop/theme.go
+++ b/internal/desktop/theme.go
@@ -7,79 +7,164 @@ import (
"fyne.io/fyne/v2/theme"
)
-// CustomTheme 自定义主题
-type CustomTheme struct {
+// customTheme 自定义主题
+type customTheme struct {
baseTheme fyne.Theme
+ forceDark bool
}
-func NewCustomTheme() fyne.Theme {
- return &CustomTheme{baseTheme: theme.DefaultTheme()}
+func NewCustomTheme(forceDark bool) fyne.Theme {
+ if forceDark {
+ return &customTheme{baseTheme: theme.DefaultTheme(), forceDark: true}
+ }
+ 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 {
+ return t.darkColors(name)
+ }
+ return t.lightColors(name)
}
-// Color 返回主题颜色
-func (t *CustomTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
+// lightColors 浅色主题配色方案
+func (t *customTheme) lightColors(name fyne.ThemeColorName) color.Color {
switch name {
+ // 主色系
case theme.ColorNamePrimary:
- return color.NRGBA{R: 88, G: 157, B: 246, A: 255} // 清新蓝色
+ return color.NRGBA{R: 100, G: 150, B: 240, A: 255}
+
+ // 背景与前景
case theme.ColorNameBackground:
- return color.NRGBA{R: 250, G: 251, B: 254, A: 255} // 浅白色背景
- case theme.ColorNameButton:
- return color.NRGBA{R: 88, G: 157, B: 246, A: 255} // 同主色
- case theme.ColorNameDisabled:
- return color.NRGBA{R: 200, G: 210, B: 230, A: 128} // 柔和禁用色
+ return color.NRGBA{R: 248, G: 249, B: 252, A: 255} // 极浅灰背景
case theme.ColorNameForeground:
- return color.NRGBA{R: 40, G: 45, B: 60, A: 255} // 深蓝灰色文字
+ return color.NRGBA{R: 30, G: 35, B: 45, A: 255} // 深灰文字
+ case theme.ColorNameDisabled:
+ return color.NRGBA{R: 180, G: 185, B: 190, A: 150} // 柔和禁用色
+
+ // 按钮状态
+ case theme.ColorNameButton:
+ return color.NRGBA{R: 70, G: 130, B: 230, A: 255}
case theme.ColorNameHover:
- return color.NRGBA{R: 129, G: 186, B: 249, A: 255} // 淡蓝色悬停
- case theme.ColorNamePlaceHolder:
- return color.NRGBA{R: 160, G: 170, B: 185, A: 255} // 柔和占位符颜色
+ return color.NRGBA{R: 90, G: 150, B: 240, A: 255} // 浅蓝悬停
case theme.ColorNamePressed:
- return color.NRGBA{R: 56, G: 136, B: 239, A: 255} // 深蓝色按下效果
+ return color.NRGBA{R: 50, G: 110, B: 210, 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} // 浅灰边框
+ case theme.ColorNamePlaceHolder:
+ return color.NRGBA{R: 160, G: 165, B: 170, A: 200} // 灰占位符
+
+ // 其他
+ case theme.ColorNameSelection:
+ return color.NRGBA{R: 200, G: 225, B: 255, A: 180} // 淡蓝选中
case theme.ColorNameScrollBar:
- return color.NRGBA{R: 210, G: 220, B: 240, A: 255} // 淡蓝色滚动条
+ return color.NRGBA{R: 200, G: 205, B: 210, A: 200}
case theme.ColorNameShadow:
- return color.NRGBA{R: 0, G: 10, B: 30, A: 40} // 淡蓝色阴影
- case theme.ColorNameInputBackground:
- return color.NRGBA{R: 240, G: 246, B: 252, A: 255} // 淡蓝色输入框背景
+ 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} // 红色错误
+ case theme.ColorNameWarning:
+ return color.NRGBA{R: 245, G: 160, B: 50, A: 255} // 橙色警告
+ case theme.ColorNameSuccess:
+ return color.NRGBA{R: 60, G: 180, B: 120, A: 255} // 绿色成功
case theme.ColorNameFocus:
- return color.NRGBA{R: 88, G: 157, B: 246, A: 180} // 半透明主色焦点
+ return color.NRGBA{R: 70, G: 130, B: 230, A: 100} // 半透明焦点
+
+ default:
+ return t.baseTheme.Color(name, theme.VariantLight)
+ }
+}
+
+// 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} // 稍亮的蓝色
+
+ // 背景与前景
+ case theme.ColorNameBackground:
+ return color.NRGBA{R: 20, G: 22, B: 30, A: 255} // 更深的灰蓝背景
+ case theme.ColorNameForeground:
+ return color.NRGBA{R: 230, G: 235, B: 240, A: 255} // 浅灰文字
+ case theme.ColorNameDisabled:
+ return color.NRGBA{R: 100, G: 105, B: 110, A: 150} // 深色禁用
+
+ // 按钮状态
+ case theme.ColorNameButton:
+ return color.NRGBA{R: 50, G: 55, B: 65, A: 255} // 更深的按钮背景
+ case theme.ColorNameHover:
+ return color.NRGBA{R: 70, G: 75, B: 85, A: 255} // 浅灰悬停
+ case theme.ColorNamePressed:
+ return color.NRGBA{R: 30, G: 35, B: 45, A: 255} // 更深按下
+
+ // 输入组件
+ case theme.ColorNameInputBackground:
+ return color.NRGBA{R: 35, G: 38, B: 48, A: 255} // 更深的输入框背景
+ case theme.ColorNameInputBorder:
+ return color.NRGBA{R: 60, G: 65, B: 75, A: 255} // 更深的边框
+ case theme.ColorNamePlaceHolder:
+ return color.NRGBA{R: 120, G: 125, B: 130, A: 200} // 灰占位符
+
+ // 其他
case theme.ColorNameSelection:
- return color.NRGBA{R: 180, G: 215, B: 250, A: 128} // 淡蓝色选择背景
+ return color.NRGBA{R: 70, G: 130, B: 230, A: 180} // 蓝色选中
+ case theme.ColorNameScrollBar:
+ return color.NRGBA{R: 60, G: 65, B: 75, A: 200} // 更深的滚动条
+ case theme.ColorNameShadow:
+ return color.NRGBA{R: 0, G: 0, B: 0, A: 50} // 深色阴影
+
+ // 状态色(更鲜艳)
case theme.ColorNameError:
- return color.NRGBA{R: 242, G: 84, B: 91, A: 255} // 柔和错误色
+ return color.NRGBA{R: 240, G: 80, B: 80, A: 255}
+ case theme.ColorNameWarning:
+ return color.NRGBA{R: 255, G: 170, B: 60, A: 255}
case theme.ColorNameSuccess:
- return color.NRGBA{R: 88, G: 214, B: 141, A: 255} // 清新绿色成功提示
+ return color.NRGBA{R: 70, G: 190, B: 130, A: 255}
+ case theme.ColorNameFocus:
+ return color.NRGBA{R: 80, G: 140, B: 240, A: 100}
+
+ default:
+ return t.baseTheme.Color(name, theme.VariantDark)
}
- return t.baseTheme.Color(name, variant)
}
// Icon 主题图标
-func (t *CustomTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
+func (t *customTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
return t.baseTheme.Icon(name)
}
// Font 主题字体
-func (t *CustomTheme) Font(style fyne.TextStyle) fyne.Resource {
+func (t *customTheme) Font(style fyne.TextStyle) fyne.Resource {
return t.baseTheme.Font(style)
}
-// Size 主题元素尺寸
-func (t *CustomTheme) Size(name fyne.ThemeSizeName) float32 {
+// Size 主题尺寸设置
+func (t *customTheme) Size(name fyne.ThemeSizeName) float32 {
switch name {
case theme.SizeNamePadding:
- return 8
+ return 10
case theme.SizeNameInlineIcon:
- return 24
+ return 20
case theme.SizeNameScrollBar:
- return 8
+ return 10
case theme.SizeNameScrollBarSmall:
- return 3
+ return 4
case theme.SizeNameSeparatorThickness:
return 1
case theme.SizeNameText:
- return 14
+ return 14
case theme.SizeNameInputBorder:
- return 1
+ return 1.5
+ case theme.SizeNameInputRadius:
+ return 5
+ default:
+ return t.baseTheme.Size(name)
}
- return t.baseTheme.Size(name)
}