feat: custom terminal background image + theme editor hardening

- settings: backgroundImage/backgroundImageOpacity (10..100, default 60)
- main: otimg:// protocol serves only the configured background file
  (path-allowlisted, 403 otherwise); dev http origin cannot load file:
- TerminalView: allowTransparency + transparent theme background while an
  image is set; .term-bg-image layer behind the xterm surface
- terminal.css: .has-bg-image keeps .xterm-viewport transparent — the old
  chrome-bg pin covered the image layer (root cause of image not showing)
- ThemeSettingsTab: image picker + opacity slider
- ThemeEditor: duplicate-name hint now covers builtin names too; seed
  colors normalized to #rrggbb
- settingsStore: sanitize theme colors, reject non-hex values
This commit is contained in:
Bill committed 2026-09-20 23:24:43 +08:00
1 parent c94e0fbac7
commit 481f54ed59
13 files changed
+187 -17

No files matched your search

+6
View File
@@ -139,12 +139,18 @@ const settings: Record<string, string> = {
'settings.highlight.builtin.url': 'Web links',
'settings.theme.accent': 'Tab accent color',
'settings.theme.accentDesc': 'Accent color for the active tab border, the sidebar indicator, and SSH badges',
'settings.theme.backgroundImage': 'Background image',
'settings.theme.backgroundImageDesc': 'Show an image behind the terminal; remove it to go back to a solid background',
'settings.theme.chooseImage': 'Choose image',
'settings.theme.clearImage': 'Remove',
'settings.theme.imageOpacity': 'Image opacity',
'settings.theme.customBadge': 'Custom',
'settings.theme.deleteTitle': 'Delete custom theme',
'settings.theme.create': 'New theme',
'settings.theme.editTitle': 'Edit theme',
'settings.themeEditor.name': 'Name',
'settings.themeEditor.namePlaceholder': 'Theme name',
'settings.themeEditor.duplicateName': 'Same name as another theme (saving is still allowed)',
'settings.themeEditor.copySuffix': ' (copy)',
'settings.about.currentVersion': 'Current version',
'settings.about.statusIdle': 'Click to check for updates',
+6
View File
@@ -136,12 +136,18 @@ const settings: Record<string, string> = {
'settings.highlight.builtin.url': 'ウェブリンク',
'settings.theme.accent': 'タブのアクセントカラー',
'settings.theme.accentDesc': 'アクティブなタブの枠線、サイドバーのインジケーター、SSH バッジのアクセントカラー',
'settings.theme.backgroundImage': '背景画像',
'settings.theme.backgroundImageDesc': 'ターミナルの背後に画像を表示します。削除すると無地の背景に戻ります',
'settings.theme.chooseImage': '画像を選択',
'settings.theme.clearImage': '削除',
'settings.theme.imageOpacity': '画像の不透明度',
'settings.theme.customBadge': 'カスタム',
'settings.theme.deleteTitle': 'カスタムテーマを削除',
'settings.theme.create': '新しいテーマ',
'settings.theme.editTitle': 'テーマを編集',
'settings.themeEditor.name': '名前',
'settings.themeEditor.namePlaceholder': 'テーマ名',
'settings.themeEditor.duplicateName': '他のテーマと同名です(保存は可能)',
'settings.themeEditor.copySuffix': '(コピー)',
'settings.about.currentVersion': '現在のバージョン',
'settings.about.statusIdle': 'クリックして更新を確認',
+6
View File
@@ -133,12 +133,18 @@ const settings: Record<string, string> = {
'settings.highlight.builtin.url': '网址链接',
'settings.theme.accent': '标签强调色',
'settings.theme.accentDesc': '活动标签边框、侧栏指示条与 SSH 徽章的强调颜色',
'settings.theme.backgroundImage': '背景图片',
'settings.theme.backgroundImageDesc': '为终端设置一张背景图片;移除后恢复纯色背景',
'settings.theme.chooseImage': '选择图片',
'settings.theme.clearImage': '移除图片',
'settings.theme.imageOpacity': '图片不透明度',
'settings.theme.customBadge': '自定义',
'settings.theme.deleteTitle': '删除自定义主题',
'settings.theme.create': '新建主题',
'settings.theme.editTitle': '编辑主题',
'settings.themeEditor.name': '名称',
'settings.themeEditor.namePlaceholder': '主题名称',
'settings.themeEditor.duplicateName': '与其他主题重名,仍可保存',
'settings.themeEditor.copySuffix': '(副本)',
'settings.about.currentVersion': '当前版本',
'settings.about.statusIdle': '点击检查更新',
+6
View File
@@ -133,12 +133,18 @@ const settings: Record<string, string> = {
'settings.highlight.builtin.url': '網址連結',
'settings.theme.accent': '標籤強調色',
'settings.theme.accentDesc': '作用中標籤的邊框、側邊欄指示條與 SSH 徽章的強調顏色',
'settings.theme.backgroundImage': '背景圖片',
'settings.theme.backgroundImageDesc': '為終端設定一張背景圖片;移除後恢復純色背景',
'settings.theme.chooseImage': '選擇圖片',
'settings.theme.clearImage': '移除圖片',
'settings.theme.imageOpacity': '圖片不透明度',
'settings.theme.customBadge': '自訂',
'settings.theme.deleteTitle': '刪除自訂主題',
'settings.theme.create': '新增主題',
'settings.theme.editTitle': '編輯主題',
'settings.themeEditor.name': '名稱',
'settings.themeEditor.namePlaceholder': '主題名稱',
'settings.themeEditor.duplicateName': '與其他主題同名,仍可儲存',
'settings.themeEditor.copySuffix': '(副本)',
'settings.about.currentVersion': '目前版本',
'settings.about.statusIdle': '點擊檢查更新',
+7 -1
View File
@@ -49,6 +49,10 @@ export interface TerminalSettings {
showOpenCwdButton: boolean
/** accent color for the active tab outline, rail indicator and SSH badges */
tabAccentColor: string
/** absolute path to an image rendered behind the terminal; '' = none */
backgroundImage: string
/** background image layer opacity, 10..100 (%) */
backgroundImageOpacity: number
}
export interface SystemSettings {
@@ -132,7 +136,9 @@ export const DEFAULT_SETTINGS: AppSettings = {
showRecButton: false,
showOpenLogsButton: false,
showOpenCwdButton: true,
tabAccentColor: '#3fb950'
tabAccentColor: '#3fb950',
backgroundImage: '',
backgroundImageOpacity: 60
},
customThemes: [],
highlightRules: DEFAULT_HIGHLIGHT_RULES,