From 1fb9bd195cb25d62aa75d35e28c967961da1900f Mon Sep 17 00:00:00 2001 From: Baobhan Sith <80159437+Heavrnl@users.noreply.github.com> Date: Sat, 19 Apr 2025 11:30:38 +0800 Subject: [PATCH] update --- .../src/components/StyleCustomizer.vue | 20 ++++++++++++++----- packages/frontend/src/locales/en.json | 4 +++- packages/frontend/src/locales/zh.json | 4 +++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/packages/frontend/src/components/StyleCustomizer.vue b/packages/frontend/src/components/StyleCustomizer.vue index 74c9dbc..4b34e8a 100644 --- a/packages/frontend/src/components/StyleCustomizer.vue +++ b/packages/frontend/src/components/StyleCustomizer.vue @@ -369,12 +369,22 @@ const handleAddNewTheme = () => { }; -// 开始编辑现有主题 +// 开始编辑主题 (用户主题或基于预设创建副本) const handleEditTheme = (theme: TerminalTheme) => { - if (theme.isPreset) return; // 不允许编辑预设 saveThemeError.value = null; // 清除旧错误 - // 深拷贝以避免直接修改列表中的对象 - editingTheme.value = JSON.parse(JSON.stringify(theme)); + if (theme.isPreset) { + // 基于预设创建副本 + const themeCopy = JSON.parse(JSON.stringify(theme)); + themeCopy._id = undefined; // 清除 ID,表示是新建 + themeCopy.name = `${theme.name} (${t('styleCustomizer.copySuffix', '副本')})`; // 添加后缀,需要添加翻译 '副本' + themeCopy.isPreset = false; // 副本不再是预设 + editingTheme.value = themeCopy; + console.log('创建预设主题副本进行编辑:', editingTheme.value); + } else { + // 编辑用户自己的主题 + editingTheme.value = JSON.parse(JSON.stringify(theme)); + console.log('编辑用户主题:', editingTheme.value); + } isEditingTheme.value = true; }; @@ -662,7 +672,7 @@ const formatXtermLabel = (key: keyof ITheme): string => {